Multiple template files

6 posts, 0 answers
  1. RICHARD FRIEND
    RICHARD FRIEND avatar
    16 posts
    Member since:
    Nov 2008

    Posted 03 Nov 2009 Link to this post

    I have created various template files for my classes in different projects, normally to implement an interface or base class.

    What would be useful would be to have multiple templates which you can give a name to  and then select on a project or class basis, so you could have different classes generated with different templates.
    Currently i manually change my generated classes and this is fairly time consuming.


    Thanks
  2. PetarP
    Admin
    PetarP avatar
    754 posts

    Posted 05 Nov 2009 Link to this post

    Hello RICHARD FRIEND,

    The problem with the current implementation of the template usage is that only one template will be used and that would be the one that is first in an alphabetical order. Having that in mind you can just place the template that you are going to use in the template folder before running the reverse mapping wizard. Make sure that the name of your template is alphabetically first.
    We are considering the possibility of adding a combo box that will be containing all the available templates in the template folder. This combo box would allow the user to select which template will be used. However this has not yet made it in our TODO list so I cannot give you an exact time frame for when/if this will be available.

    Best wishes,
    Petar
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. DevCraft banner
  4. RICHARD FRIEND
    RICHARD FRIEND avatar
    16 posts
    Member since:
    Nov 2008

    Posted 05 Nov 2009 Link to this post

    Hi

    Thanks for your reply, maybe you could suggest a a workaround for my problem.

    All my tables have a LastUpdatedDate, LastUpdatedBy and some other common columns on them, because i display these on my UI i created an interface that they all implement (IEntity) and i have modified my template to expose these via the interface, this all works great.

    Now i have the need to map some views that use a linked server to some external data, now these views dont have my columns in them so i have to manually delete them from the generated class everytime i re-generate.

    Is there a way to edit the template so it doesnt add this code for certain conditions, eg if the class name begins with a specific word ?

    I see the syntax has support for  #if but i cant find any documentation on what is supported (eg would it support #if ($className.StartWith("")) etc...


    Regards
  5. PetarP
    Admin
    PetarP avatar
    754 posts

    Posted 09 Nov 2009 Link to this post

    Hello RICHARD FRIEND,

    Unfortunately this is not currently possible. The only workaround would be to generate your classes on two steps. First use the template that implements the interfaces to generate your classes, then place the one without the implementation and generate your views. Once again please not that if there are more than one template the one that is alphabetically first is respected.
    We are sorry for any inconvenience this might be causing.

    Kind regards,
    Petar
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  6. richard
    richard avatar
    9 posts
    Member since:
    Jul 2012

    Posted 30 Jan 2010 Link to this post

    I am currently "adapting" the Silverlight sales dashboard example and have over 40 tables. Seeing that these tables will change, I need a way to generate Interface classes for the "Common" module. I have messed with the templates, but was wondering if there was an easier method or if you guys had some pre-canned templates.

    If not, is this the correct path i should take ?

    thanks,
  7. PetarP
    Admin
    PetarP avatar
    754 posts

    Posted 01 Feb 2010 Link to this post

    Hello richard,

    Currently we are  providing templates only for generating INotifyPropertyChanged/Changing interfaces. These templates can be found in our code library. Editing the template files currently is the only way you can inject some custom code in our code generation process. Having that in mind - yes that is the best approach it is also the only way as for now.

    Kind regards,
    Petar
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top
DevCraft banner