If you don't reuse that abstact base type as a base class for other final subclass types it should work fine.
The other option is to make your base class generic and use the generic type in the RegisterProperty call. For example:
public abstract Document<T> : Csla.Core.BusinessBase
where T : Document<T>
{
private static readonly PropertyInfo ChildProperty =
RegisterProperty(typeof(T), "Child");
public MyChild Child { get; private set; }
}
public sealed Quote : Document<Quote>
{
}
RockfordLhotka:If you don't reuse that abstact base type as a base class for other final subclass types it should work fine.
Why would this cause a problem? (Sorry if I'm missing something obvious, but I don't see why you would ever have an abstract base if you planned on deriving only one class from it)
Well let me put it another way.
Properties are registered to types. If you register your
properties with the type in which the property is actually declared you won’t
have a problem (inheritance or not). If you register a property for a type in
which it isn’t declared then things will break.
So declaring properties in an abstract base class, using the
RegisterProperty() overload that takes an explicit type is fine – as long as
the type you provide is the type of the abstract base class, and the property
is actually declared/implemented in that abstract base class.
RockfordLhotka:
So declaring properties in an abstract base class, using the
RegisterProperty() overload that takes an explicit type is fine – as long as
the type you provide is the type of the abstract base class, and the property
is actually declared/implemented in that abstract base class.
Copyright (c) Marimer LLC