I am creating a factory which uses a delegate to call a static method on each registred type in order to create an instance of the type.
In the factory I have the delegate definition:
public delegate GridColumnBase ColumnFactoryMethod();
and I would like each type inheriting from GridColumnBase
to implement a static CreateInstance()
method. I can't make CreateInstance
a static abstract
member of GridColumnBase
, so how do I enforce that each class implement this method?
Edit: Thinking about this a little more I reached a conclution that CreateInstance()
is not a feature of a class inhereting GridColumnBase
, but is a feature of a class wanting to be included in the factory. Maybe I don't need to enforce this on the base class level. Maybe I need to leave it to the implementing class to decide how it whishes to participate in the factory process, i.e. passing in to the factory any function it whishes to delegate.
Does this make sense to anyone but me? :)