Updating a PropertyInfo<p> in a static constructor?

Updating a PropertyInfo<p> in a static constructor?

Old forum URL: forums.lhotka.net/forums/t/5683.aspx


dlabar posted on Monday, October 27, 2008

I'm working on creating a code template for the Csla 3.6 framework with split partial classes. One file gets generated once and the other gets regenerated every time the Database is changed.

As I was working with the PropertyInfo on the Template, I realized that the I would want to manually edit the friendly name parameter in the PropertyInfo constructor, after the code is generated, but that declaration was going to get auto-generated constantly, and any manual changes I made, would get lost. Is there any issue with having a static constructor in my business objects class, and updating any PropertyInfos that I needed to in that constructor by creating new PropertyInfos? That way if I wanted to override them I could, but if I didn't need to, then I wouldn't have to.

Are there any better ideas?

Fintanv replied on Tuesday, October 28, 2008

I remove the setting of the friendly name from the code and use a resources file instead:

private static PropertyInfo MyDataProperty = RegisterProperty(new PropertyInfo("MyData", Properties.Resources.MyData));


Then you manage the resource files based on the location.
Would this work for you?

I am also curious as to what code generator you are targeting?
I have started using MyGeneration, creating the template using their C# engine, and love it.  So far I have it creating the stored procedures, grants, and audit tables.  Love the speed and consistency.

All the best.

dlabar replied on Tuesday, October 28, 2008

Thats a good idea.  I'll have to look into that.

I was using Code Smith, but it is a major pain to have to edit the templates.  I'm also having to connect to an Oracle Database, so alot of the normal CSLA codesmith Templates require extra configuring.

I've decided to try to make my own using T4 in VS.  I've never even looked at it before, but I'm tired of having to relay on third party software and not being able to have full control.

 

 

Fintanv replied on Wednesday, October 29, 2008

You should definitely take a look at MyGeneration then (MyGenerationSoftware.com).  It is open source, and you can write the templates using vbscript, jscript, vb.net or c#. 
The template I just completed is Oracle centric, written using c# 2.0 (i.e. includes generics).

jasonlaw replied on Thursday, December 18, 2008

Hi dlabar,

Can you please share out your template ?

Thanks in advance.

Jason

dlabar replied on Saturday, December 20, 2008

I ended up not using T4 as a Code Generator.  It didn't seem to be much better than Codesmith after I dived into it.

jasonlaw replied on Sunday, December 21, 2008

Hi dlabar,

I mean the Codesmith template for 3.6.
I am sorry that didn't mentioned clearly before.

Thank you.

dlabar replied on Monday, January 05, 2009

I don't have any codesmith templates for 3.6

Copyright (c) Marimer LLC