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