CSLA .NET

Vibrant discussion about CSLA .NET and using the framework to build great business applications.

Coderush templates - Property template

rated by 0 users
This post has 2 Replies | 1 Follower

Not Ranked
Posts 2
GunnarIF Posted: Wed, Dec 3 2008 11:56 AM

Hi!

Does anyone know about any Coderush templates for CSLA and is willing to share them?

I created some Coderush templates to create CSLA 3.5 properties. Hope it is usefull for someone.

I named this one "cslap" (CSLA Property)

private «Link(string)» «Link(PropertyName,FormatFieldName,PropertyNameFromField)»;
private static PropertyInfo<«Link(string)»> «Link(PropertyName)»Property = RegisterProperty<«Link(string)»>(typeof(«Class»), new PropertyInfo<«Link(string)»>("«Link(PropertyName)»"));
public «FieldStart»«Caret»«Link(string)»«BlockAnchor»«FieldEnd» «FieldStart»«Caret»«Link(PropertyName)»«BlockAnchor»«FieldEnd»
{
 get { return GetProperty<«Link(string)»>(«Link(PropertyName)»Property, «Link(PropertyName,FormatFieldName,PropertyNameFromField)»); }
  set { SetProperty<«Link(string)»>(«Link(PropertyName)»Property, ref «Link(PropertyName,FormatFieldName,PropertyNameFromField)», value); }

This one is named "cslap?Type?". So you can type for example "cslai" to create CSLA integer property.

private «Link(«?Get(Type)»)» «Link(PropertyName,FormatFieldName,PropertyNameFromField)»;
private static PropertyInfo<«Link(«?Get(Type)»)»> «Link(PropertyName)»Property = RegisterProperty<«Link(«?Get(Type)»)»>(typeof(«Class»), new PropertyInfo<«Link(«?Get(Type)»)»>("«Link(PropertyName)»"));
public «FieldStart»«Caret»«Link(«?Get(Type)»)»«BlockAnchor»«FieldEnd» «FieldStart»«Caret»«Link(PropertyName)»«BlockAnchor»«FieldEnd»
{
 get { return GetProperty<«Link(«?Get(Type)»)»>(«Link(PropertyName)»Property, «Link(PropertyName,FormatFieldName,PropertyNameFromField)»); }
  set { SetProperty<«Link(«?Get(Type)»)»>(«Link(PropertyName)»Property, ref «Link(PropertyName,FormatFieldName,PropertyNameFromField)», value); }
}

Regards,

Gunnar

Not Ranked
Posts 9
martin_s replied on Thu, Apr 30 2009 3:35 AM
Thank you, very useful

Is there any chance of updating the template to the new property code style introduced in CSLA.NET 3.6 ?
I'm having a go at the moment, but I'm on the steep edge of the CSLA learning curve so I'm not sure it's correct.

Cheers
Martin.
Not Ranked
Posts 2
GunnarIF replied on Thu, Apr 30 2009 11:50 AM
This should work, I think

--- cslap?Type? (A property of a type, cslaps is as string type)

private «Link(«?Get(Type)»)» «Link(PropertyName,FormatFieldName,PropertyNameFromField)» = «Link(PropertyName)»Property.DefaultValue;
private static PropertyInfo «Link(PropertyName)»Property = RegisterProperty(p => p.«Link(PropertyName)»);
public «FieldStart»«Caret»«Link(«?Get(Type)»)»«BlockAnchor»«FieldEnd» «FieldStart»«Caret»«Link(PropertyName)»«BlockAnchor»«FieldEnd»
{
get { return GetProperty(«Link(PropertyName)»Property, «Link(PropertyName,FormatFieldName,PropertyNameFromField)»); }
set { SetProperty(«Link(PropertyName)»Property, ref «Link(PropertyName,FormatFieldName,PropertyNameFromField)», value); }
}


----- cslasdp (Smardate Property)-----

private SmartDate «Link(PropertyName,FormatFieldName,PropertyNameFromField)» = «Link(PropertyName)»Property.DefaultValue;
private static PropertyInfo «Link(PropertyName)»Property = RegisterProperty(p => p.«Link(PropertyName)»);
public string «FieldStart»«Caret»«Link(PropertyName)»«BlockAnchor»«FieldEnd»
{
get { return GetPropertyConvert(«Link(PropertyName)»Property, «Link(PropertyName,FormatFieldName,PropertyNameFromField)»); }
set { SetPropertyConvert(«Link(PropertyName)»Property, ref «Link(PropertyName,FormatFieldName,PropertyNameFromField)», value); }
}


-- cslacp (Child property using the fieldmanager)

private static PropertyInfo «Link(Child)»Property = RegisterProperty(typeof(«Class»), new PropertyInfo("«Link(Child)»"));
public «FieldStart»«Caret»«Link(ChildType)»«BlockAnchor»«FieldEnd» «FieldStart»«Caret»«Link(Child)»«BlockAnchor»«FieldEnd»
{
get {
if(!FieldManager.FieldExists(«Link(Child)»Property))
LoadProperty(«Link(Child)»Property, «Link(ChildType)».NewChild());
return GetProperty(«Link(Child)»Property);
}
}
Page 1 of 1 (3 items) | RSS

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