2009-09-21 75 views
1

我想包括在运行时生成类型采用它自己的类型作为参数拷贝的方法 - 我敢肯定,我失去了一些东西很明显,但我看不出如何做到这一点如何在运行时构建类型的方法中引用包含类型?

TypeBuilder recordTypeBuilder = 
    moduleBuilder.DefineType("_" + tableSpec.Name + "Record", TypeAttributes.Sealed,); 

recordTypeBuilder.DefineMethod("CopyFrom", MethodAttributes.Public, null, new[] { typeof(???) }); 

???是我遇到问题的地方。我还无法构造该类型,因为我还没有完成它的创建!

有什么想法?

的问候,从System.Type

+1

你能只需将'recordTypeBuilder'呢? – 2009-09-21 16:58:52

回答

1

TypeBuilder继承,可以在Reflection.Emit定义在使用前已经实际创建:

recordTypeBuilder.DefineMethod(
    "CopyFrom", MethodAttributes.Public, null, new Type[] { recordTypeBuilder }); 
+0

哦。我的。那很简单!非常感谢! – headsling 2009-09-21 17:34:37

相关问题