CSLA .NET

From Rockford Lhotka's Expert C# 2008 and VB 2008 Business Objects books

Updating a PropertyInfo<p> in a static constructor?

rated by 0 users
This post has 7 Replies | 0 Followers

Top 100 Contributor
Posts 59
dlabar Posted: Mon, Oct 27 2008 2:46 PM
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?
Top 50 Contributor
Posts 125
Fintanv replied on Tue, Oct 28 2008 9:37 AM
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.
Top 100 Contributor
Posts 59
dlabar replied on Tue, Oct 28 2008 10:16 AM

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.

 

 

Top 50 Contributor
Posts 125
Fintanv replied on Wed, Oct 29 2008 10:26 AM
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).
Top 500 Contributor
Posts 19
jasonlaw replied on Thu, Dec 18 2008 7:58 AM

Hi dlabar,

Can you please share out your template ?

Thanks in advance.

Jason

Top 100 Contributor
Posts 59
dlabar replied on Sat, Dec 20 2008 10:03 PM
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.
Top 500 Contributor
Posts 19
jasonlaw replied on Sun, Dec 21 2008 5:21 AM
Hi dlabar,

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

Thank you.
Top 100 Contributor
Posts 59
dlabar replied on Mon, Jan 5 2009 9:12 AM
I don't have any codesmith templates for 3.6
Page 1 of 1 (8 items) | RSS

Please contact Magenic for your .NET consulting
and CSLA .NET mentoring needs.
Please consider making a donation to help support the ongoing development of CSLA .NET.

Make donation through PayPal - it's fast, free and secure!
Why donate?
Copyright (c) 2006-2010 Marimer LLC. All rights reserved.
Email admin@lhotka.net for support.
Powered by Community Server (Non-Commercial Edition), by Telligent Systems