1
我有一个具有ICommand
属性的泛型类。这是一个用作子对象的组合对象,具有ICommand
属性。动态属性分配传递接口属性
我正在搜索一个系统,以在运行时定义与此类一起使用的接口和必须“使用”的子对象的命令属性,如泛型的ICommand
属性。
最后有这样的事情:
public TestDynamic<T>
{
public ICommand ChildCommand;
public T CompositeChild;
...
}
public interface ITestOne{
ICommand DoSomethin{get;set;}
}
public interface ITestTwo{
ICommand DoSomethingMore{get;set;}
}
ITestOne MyObj1=...
ITestTwo MyObj2=...
TestDynamic<ITestOne> TD1=...
TD1.DynamicRegistration((i)=>i.DoSomething);
TD1.ChildCommand.Execute();//DoSomething execution
TestDynamic<ITestTwo> TD2=...
TD2.CompositeChild=MyObj2;
TD2.DynamicRegistration((i)=>i.DoSomethingMore);
TD2.ChildCommand.Execute();//DoSomethingMore execution
//Those are done in a different moment. Where i can't simply set the property
TD1.CompositeChild=MyObj1;
TD1.CompositeChild=MyObj1;
实际上Action<T,ICommand>
我定义了返回子类的“正确” ICommand
的委托。
什么可能是更好的方式来实现你的意见呢?
我试图想通过你的问题,但我你想要做什么卡住的理解。你能编辑你的问题并详细说明吗? – Enigmativity 2010-11-05 06:14:38