This is a migrated thread and some comments may be shown as answers.

Multiple template files

5 Answers 72 Views
Feature Requests
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
RICHARD FRIEND
Top achievements
Rank 2
RICHARD FRIEND asked on 03 Nov 2009, 09:46 AM
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

5 Answers, 1 is accepted

Sort by
0
PetarP
Telerik team
answered on 05 Nov 2009, 03:50 PM
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.
0
RICHARD FRIEND
Top achievements
Rank 2
answered on 05 Nov 2009, 04:52 PM
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
0
PetarP
Telerik team
answered on 09 Nov 2009, 02:46 PM
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.
0
richard
Top achievements
Rank 1
answered on 30 Jan 2010, 04:53 PM
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,
0
PetarP
Telerik team
answered on 01 Feb 2010, 07:16 PM
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.
Tags
Feature Requests
Asked by
RICHARD FRIEND
Top achievements
Rank 2
Answers by
PetarP
Telerik team
RICHARD FRIEND
Top achievements
Rank 2
richard
Top achievements
Rank 1
Share this question
or