CSLA .NET

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

Welcome to CSLA .NET Sign in | Join | Help
in Search

Updating a PropertyInfo<p> in a static constructor?

Last post 01-05-2009, 9:12 AM by dlabar. 7 replies.
Sort Posts: Previous Next
  •  10-27-2008, 2:46 PM 27683

    Updating a PropertyInfo<p> in a static constructor?

    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?
  •  10-28-2008, 9:37 AM 27696 in reply to 27683

    Re: Updating a PropertyInfo<p> in a static constructor?

    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.
  •  10-28-2008, 10:16 AM 27697 in reply to 27696

    Re: Updating a PropertyInfo<p> in a static constructor?

    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.

     

     

  •  10-29-2008, 10:26 AM 27732 in reply to 27697

    Re: Updating a PropertyInfo<p> in a static constructor?

    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).
  •  12-18-2008, 7:58 AM 29221 in reply to 27697

    Re: Updating a PropertyInfo<p> in a static constructor?

    Hi dlabar,

    Can you please share out your template ?

    Thanks in advance.

    Jason

  •  12-20-2008, 10:03 PM 29292 in reply to 29221

    Re: Updating a PropertyInfo<p> in a static constructor?

    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.
  •  12-21-2008, 5:21 AM 29295 in reply to 29292

    Re: Updating a PropertyInfo<p> in a static constructor?

    Hi dlabar,

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

    Thank you.
  •  01-05-2009, 9:12 AM 29469 in reply to 29295

    Re: Updating a PropertyInfo<p> in a static constructor?

    I don't have any codesmith templates for 3.6
View as RSS news feed in XML

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?
Powered by Community Server, by Telligent Systems