This might be a stupid question, but I'm developing a component and I have a class with a property like the following
public class Grid()
{
..
public IDecorator Decorator { get; set;}
}
What I want is for user to specify their own custom class that implements IDecorator in the following way
...BuildGrid(
grid=>{
..
grid.Decorator = [CustomNameSpace].[DecoratorClass]
//as in
grid.Decorator = Com.MyCompany.DivDecorator
..
});
Com.MyCompany.DivDecorator implements IDecorator interface. So how should I do it without the end user to specify the "new" keyword as in
grid.Decorator = new Com.MyCompany.DivDecorator();
I know I'm missing some key c# concept here.
Thanks
[Edit]
I was trying to do something like the Java DisplayTag library located here
http://www.displaytag.org/1.2/tut_decorators.html
The way they do it is by
... decorator="org.displaytag.sample.Wrapper"
So I guess instead of
public IDecorator Decorator { get; set;}
I should do
public String Decorator (get; set;}
and then internally use TypeOf() to resolve it.... Just wondering if there is any other way to elegantly do it in C#.
Thanks