Would like to use the bridge pattern with the PropertyInfo classes in 3.5

Would like to use the bridge pattern with the PropertyInfo classes in 3.5

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


bitburner posted on Monday, January 28, 2008

I am currently refactoring my classes to use CSLA 3.5.  However I hit a brick wall with the IPropertyInfo interface in the BusinessBase implementation of  GetProperty, LoadProperty, etc...

I was assuming the purpose of the IPropertyInfo interface is to allow developers to leverage the bridge pattern to change how a property info object behaves within the framework.  This would be nice to have - but you can't really use it since the BusinessBase classes are expecting an instance of PropertyInfo and not the interface itself (and I can't cast my implementation of the interface to the default PropertyInfo class since I am not directly inheriting from it).

What I was trying to do is change how FriendlyName returns a value (use a resource file instead of a string value from the PropertyInfo class) - just changing to another implementation of the property info class - or a simple virtual method would do the trick, but no such luck.

Now I did see that there is a virtual method being called for GetFieldData in the defalut propertyinfo class - puting this back into my implementation would be a snap - just copy and paste from reflector and were done!  Now we are ready to move forward with our stuff...

Would it be possible to change the Csla.BusinessBase Load/Read/Get property methods to use the interface instead of the default implementation of PropertyInfo?

Thanks,

Chase

 

 

 

RockfordLhotka replied on Monday, January 28, 2008

IPropertyInfo exists purely so I can use polymorphism when managing the PropertyInfo<T> objects. It is not an extensibility mechanism.

The extensibilty mechanism is to subclass PropertyInfo<T> with your own implementation. I hadn't made FriendlyName virtual, but I'll change that, since it does no harm and enables your scenario.

Copyright (c) Marimer LLC