Hi Rocky,
I really like the new feature in 3.6.2 that allows to use a Lambda Expression to register a Property instead of using a string Literal.
Unfortunately it's currently not possible to use this feature with subclasses of CslaIdentity, because of the missing type parameter.
On rare occations, I still use OnPropertyChanged. I added the following code to my own base classes:
protected
void OnPropertyChanged(Expression<Func<T, object>> propertyLambdaExpression){
PropertyInfo reflectedPropertyInfo = Reflect<T>.GetProperty(propertyLambdaExpression);
OnPropertyChanged(reflectedPropertyInfo.Name);
}
This allows me to use the feature also with OnPropertyChanged.
It would be very cool if this could be included in the Framework itself.
Regards Luzius
Did we miss that one?
You should be able to do RegisterProperty<MyIdentityType, string>(c => c.Name)
That is necessary in subclasses of CriteriaBase, CommandBase and (I think) CslaIdentity because the CSLA base classes are not generic and so RegisterProperty() needs you to provide the type of the actual business class.
Somehow I can't get that to work. When I specify the type of my CslsIdentity sub class I still only have access to the properties of CslaIdentity.
I tried to simply add a new RegisterProperty-Method to my class and it compiles perfectly but then I get the following runtime exception:
'Can not register property FullName after containing type (CslaIdentity) has been instantiated'
Luzius
I have the same problem. What can I do to to subclass CslaIdentity? Is there a quick fix or an alternate solution?
Just don't use the lambda expression syntax:
private static PropertyInfo<string> NameProperty =
RegisterProperty<string>(typeof(MyCustomIdentity), "Name");
Thanks, it works perfectly!
private
static readonly PropertyInfo<Guid> UserIdProperty = RegisterProperty<Guid>(typeof(FMIdentity), new PropertyInfo<Guid>("UserId"));Rocky:To be clear - RegisterProperty() in CslaIdentity will NEVER be the same as BusinessBase, because CslaIdentity isn't a generic type - so you will always have to explicitly provide the type name for your particular subclass.
Just curious, what design decisions are being considered that is preventing the CslaIdentity from adding a generic type?
I may make it generic in 4.0. Making it generic now is clearly a breaking change, so the design consideration is that I try to avoid breaking changes, especially at the business class level, in point releases of the framework.
Generally I was only making base classes generic when there was a pressing need for them to be generic. There didn't used to be a need for CriteriaBase, CslaIdentity or CommandBase to be generic, so making them generic seemed pointless - silly really.
When we added the generic overload for RegisterProperty() the value of having a generic base class materialized - but that level of change seemed (to me) to be too disruptive.
Copyright (c) Marimer LLC