Open RIA Services User Support Slightly alter code generation  Viewed 18778 time(s), 2 post(s)., 7/2/2014 1:50:50 PM - by bengutt

bengutt
bengutt 7/2/2014 1:50:50 PM

Hi,

We have a Silverlight solution that is using t4 templates to generate our models on the server side. During this generation we are adding attributes to some of the properties. Usually these are the navigation properties, but not always. The attributes are available on both the client and server side by the use of *.Shared.cs.

These attributes are required both server side and client side. Is there a way to get the code generation on the client to generate these additional attributes when generating the related property?

Thanks,

Ben.

This content has not been rated yet. 
80 Reputation 9 Total posts
1
Daniel-Svensson
Daniel-Svensson 7/15/2014 8:27:43 PM

If you already use the T4 template, you could look into creating your own entitygenerator derived from CSharpClientCodeGenerator.

If I remember correctly there is a method returning which attributes to generate as well methods
</br>that are invoked when starting to generate a property.

You can hopefully be able to find them using visual studios intellisense,
</br>just start typing override so you get a list of methods to override.

I think it might be GenerateAttributes is used to write the attributes.
</br>You might also need to override GenerateProperty if you need to know which property you are currently generating attributes for,
</br> just save it in a member variable, call the base implementation and then restore the member variable.

Most of the interesting code details for the build in CSharpEntityGeneratoris probably found in https://openriaservices.codeplex.com/SourceControl/latest#OpenRiaServices.DomainServices.Tools.TextTemplate/Framework/CSharpGenerators/CSharpEntityGenerator.partial.cs

Please let me know if you require further assistance.

This content has not been rated yet. 
338 Reputation 44 Total posts
2