在使用Relection.Emit動態創建的類上有什麼方法可以使用擴展方法嗎?例如:在運行時程序集中使用擴展方法
class somewhere
{
somewhere()
{
// define the type here using ReflectionEmit, etc.
Type tableType = CreateTableType(...table parameters...);
var table = Activator.CreateInstance(tableType);
table.Shuffle();
}
}
//... elsewhere
public class static TableTypeExtensions
{
public static Table Shuffle(this Table t)
{
...
}
}
但是我沒有名字「Table」的類,只有Type tableType available。
有沒有辦法解決這個問題?
謝謝
我更喜歡界面建議,但這也不錯。 – 2010-09-16 21:25:40
同意。 Upvoted它。 – 2010-09-17 06:22:40
我在最終的代碼中使用了這個。對我來說,添加功能到類比接口更有意義。 – 2010-10-19 16:23:52