0

我有一个类 A,它实现了接口 I:

class A: I
{
  // implementation of I
}

还有另一个接口 J,它扩展了 I:

interface J : I
{
  // J methods and properties.
}

我想发出一个动态类 B,它看起来像这样:

class B : A, J
{
  // All the constructors of A
  // All the methods of J, which are not implemented by A. Their implementation would just throw NotImplementedException()
}

我在 Reflection.Emit 方面有足够的知识,可以从头开始,但是,唉,我真的不希望这样做。有谁知道图书馆,可以做到这一点?

谢谢。

附言

我知道 Castle 项目,但从未真正使用过它,也不知道他们是否有适合我的现成解决方案。

4

2 回答 2

0

当您通过 DefineType 创建类型定义时,会覆盖基类和实现的接口:http: //msdn.microsoft.com/en-us/library/f53tx4x8.aspx

于 2010-03-10T12:25:02.017 回答
0

Castle DynamicProxy可以用来做这件事

于 2010-03-10T14:01:37.297 回答