PropertyInfo{T} is killing the IPropertyInfo thunder.

PropertyInfo{T} is killing the IPropertyInfo thunder.

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


rxelizondo posted on Sunday, December 06, 2009

It appears that PropertyInfo{T} is used very liberally through the CSLA. Most notorious is that the implementation of all the RegisterProperty() methods return PropertyInfo{P} when they really should be returning the IPropertyInfo interface.... at least I think that is what supposed to be returned.


For this, I will quote the book (page 227 right at the top):
----------------------------
The PropertyInfo class is declared like this:

public class PropertyInfo{T} : Core.IPropertyInfo, IComparable

Notice that it implements an IPropertyInfo interface from the Csla.Core namespace. Technically, CSLA .NET accepts IPropertyInfo parameters everywhere, and this PropertyInfo class is just
one possible implementation. This is an intentional extensibility point for CSLA .NET, allowing you to create other IPropertyInfo implementations (or subclasses of PropertyInfo) that store other metadata
about each property.

One scenario where you might do this is if you want to store data access metadata, such as the database, table, and column name where the property value is stored.
----------------------------

To me, this sounds that you are not obligated to inherit from PropertyInfo but you are obligated to inherit from IPropertyInfo.

There may be more to this issue, but before I go there, I would be interested to know if I am complete missing the point here.

Thanks.

RockfordLhotka replied on Sunday, December 06, 2009

My primary focus in the implementation was performance, which requires the use of generics to avoid boxing/unboxing through the process of storing field values. It is tricky.

As a secondary concern I wanted to make it possible to create your own subclass of PropertyInfo<T> to add extra metadata.

As a tertiary concern I wanted to let you create your own IPropertyInfo. I'm not entirely sure what the scenario is for this, but there's limited support for the concept if you really need it. I think it might work, but it isn't part of my test model, and no one has really pursued this to my knowledge.

Arguably this is a case of building something nobody asked for - which is never good. On the other hand there's the basic need for polymorphic behaviors that you can't get with a generic type, so the interface is necessary at some level regardless.

Copyright (c) Marimer LLC