DTO Template for v2.5

Posts   
 
    
greenstone
User
Posts: 132
Joined: 20-Jun-2007
# Posted on: 23-Oct-2007 14:21:23   

I've used the templatebindings, template, and task files outline in: http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=10504, but am getting the following error when I Project/Generate/Start Generator (in LLBLGenPro v2.5 Final version):

Generator process results Task execution log. Task execution started on: 23-Oct-2007 07:44.26 Task group: SD.Presets.Adapter.General2005ChangedAA Task group: DTO Templates Task group: Create Directories Task: DTODirectoryCreator Directory 'C:\Source\Pear\Prototype\ORMapping\LlblGenPro\ImportExport\DTO' created/preserved successfully. Task group: Create DTO Classes Task: DTOClassCreator Could not find template 'Dto'. It is not defined in the templatebindings or is empty.

Can you spot what might be causing the error?


Following are my templatebindings, template, and tasks files. The only changes I had to make to the forum's posted steps were:

C:\Program Files\Solutions Design\LLBLGen Pro v2.5\Tasks\DTO.Tasks: Added a missing line:
<taskGroup xmlns="http://sd/llblgen/pro/taskGroupElementDefinitions.xsd"

C:\Program Files\Solutions Design\LLBLGen Pro v2.5\Tasks\DTO.Tasks: CHANGED FROM: <supportedTemplateGroups> <templateGroup name="SelfServicing" /> </supportedTemplateGroups>

CHANGED TO:
<supportedTemplateGroups>
    <templateGroup name="Adapter" />
</supportedTemplateGroups>

C:\Program Files\Solutions Design\LLBLGen Pro v2.5\Templates\DTO.templatebindings...

<?xml version="1.0"?> <templateBindings xmlns="http://sd/llblgen/pro/templateBindingsDefinition.xsd" name="My DTO template bindings" description="My Monday DTO template bindings" precedenceLevel="11" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http:/ /sd/llblgen/pro/templateBindingsDefinition.xsd C:\PROGRA~1\SOLUTI~1\LLBLGE~1.5\Tasks\XSDs\templateBindingsDefinition.xsd"> <supportedPlatforms> <platform name=".NET 2.0"/> </supportedPlatforms> <language name="C#"> <templateBinding templateID="Dto" filename="SharedTemplates\Net2.x\C#\Dto.template"/> </language> <language name="VB.NET"> <!-- If you're using VB.NET, you've should add the binding above here instead. --> </language> </templateBindings>


C:\Program Files\Solutions Design\LLBLGen Pro v2.5\SharedTemplates\Net2.x\C#\dto.template...

using System; using System.ComponentModel; using System.Collections; using System.Runtime.Serialization;

using <[RootNamespace]>.EntityClasses;

namespace <[RootNamespace]>.DTOClasses { /// <summary> /// DTO class for the entity '<[CurrentEntityName]>'. /// </summary> [Serializable] public <[If UsePartialClasses]>partial <[EndIf]>class <[CurrentEntityName]>DTO <[ If IsSubType ]>: <[ SuperTypeName ]>DTO<[ EndIf]> { #region Class Member Declarations <[Foreach EntityField CrLf]> private <[If IsNullable]><[If IsValueType]>Nullable<<[TypeOfField]>><[Else]><[TypeOfField]><[EndIf]><[Else]><[TypeOfField]><[EndIf]> _<[CaseCamel EntityFieldName]>;<[NextForeach]> #endregion

    /// <summary>
    /// CTor
    /// </summary>
    public <[CurrentEntityName]>DTO()
    {       
    }


    /// <summary>
    /// CTor which initializes the DTO with values from its corresponding entity
    /// </summary>
    /// <param name="entityInstance">The entity instance which holds the values for this DTO</param>
    public <[CurrentEntityName]>DTO(<[CurrentEntityName]>Entity entityInstance)<[ If IsSubType ]> : base(entityInstance)<[ EndIf]>
    {

<[Foreach EntityField CrLf]> _<[CaseCamel EntityFieldName]> = entityInstance.<[EntityFieldName]>;<[NextForeach]> }

    /// <summary>
    /// Creates a new entity instance and copies over the values of this DTO
    /// </summary>
    public <[CurrentEntityName]>Entity ToEntity()
    {
        return ToEntity(new <[CurrentEntityName]>Entity());
    }


    /// <summary>
    /// Copies over the values of this DTO into the entity passed in.
    /// </summary>
    public <[CurrentEntityName]>Entity ToEntity(<[CurrentEntityName]>Entity toFill)
    {

<[Foreach EntityField CrLf]> toFill.<[EntityFieldName]> = _<[CaseCamel EntityFieldName]>;<[NextForeach]> <[ If IsSubType ]> base.ToEntity(toFill);<[ EndIf]> return toFill; }

<[Foreach EntityField CrLf]> /// <summary> The <[EntityFieldName]> property of the Entity <[CurrentEntityName]></summary> public <[If EntityFieldOverrides]>override<[Else]>virtual<[EndIf]> <[If IsNullable]><[If IsValueType]>Nullable<<[TypeOfField]>><[Else]><[TypeOfField]><[EndIf]><[Else]><[TypeOfField]><[EndIf]> <[EntityFieldName]> { get { return _<[CaseCamel EntityFieldName]>;} set { _<[CaseCamel EntityFieldName]> = value; } }<[NextForeach]> } }


C:\Program Files\Solutions Design\LLBLGen Pro v2.5\Tasks\DTO.Tasks...

<?xml version="1.0"?> <taskGroup xmlns="http://sd/llblgen/pro/taskGroupElementDefinitions.xsd" name="DTO Templates" isOptional ="false" description="General group of tasks which are used DTO templates."> <supportedPlatforms> <platform name=".NET 2.0" /> </supportedPlatforms> <supportedTemplateGroups> <templateGroup name="Adapter" /> </supportedTemplateGroups>

<taskGroup name="Create Directories">
    <task name="DTODirectoryCreator" assemblyFilename="SD.LLBLGen.Pro.TaskPerformers.dll" taskPerformerClass="SD.LLBLGen.Pro.TaskPerformers.DirectoryCreator">
        <parameters>
            <parameter name="folderToCreate" defaultValue="DTO" isOptional="false" description="The folder to create"/>
            <parameter name="failWhenExistent" defaultValue="false" isOptional="true" description="Flag to signal what to do when the folder already exists. Overrules clearWhenExistent" valueType="boolean"/>
            <parameter name="clearWhenExistent" defaultValue="false" isOptional="true" description="Flag to signal if an existing folder has to be cleared first. Overruled by failWhenExistent" valueType="boolean"/>
        </parameters>
    </task>
</taskGroup>

<taskGroup name="Create DTO Classes" description="Create DTO Classes">
    <!--<task name="DTOClassCreator" assemblyFilename="SD.LLBLGen.Pro.LptParser.dll" taskPerformerClass="SD.LLBLGen.Pro.LptParser.DotNetTemplateEngine">-->
    <task name="DTOClassCreator" assemblyFilename="SD.LLBLGen.Pro.TaskPerformers.dll" taskPerformerClass="SD.LLBLGen.Pro.TaskPerformers.CodeEmitter">
        <parameters>
            <parameter isOptional="false" name="destinationFolder" defaultValue="DTO"/>
            <parameter isOptional="false" name="failWhenExistent" defaultValue="false"/>
            <parameter isOptional="false" name="filenameFormat" defaultValue="[elementName]DTO.[extension]"/>
            <!--<parameter isOptional="false" name="templateID" defaultValue="SD_DTOTemplate"/>-->
            <parameter isOptional="false" name="templateID" defaultValue="Dto"/>
            <parameter isOptional="false" name="emitType" defaultValue="allEntities"/>
        </parameters>
    </task>
</taskGroup>

</taskGroup>

greenstone
User
Posts: 132
Joined: 20-Jun-2007
# Posted on: 25-Oct-2007 02:17:50   

I figured out the issue:

The path for the template should have been: C:\Program Files\Solutions Design\LLBLGen Pro v2.5*Templates*SharedTemplates\Net2.x\C#\dto.template

NOT: C:\Program Files\Solutions Design\LLBLGen Pro v2.5\SharedTemplates\Net2.x\C#\dto.template