building a self referencing class using System.Reflection.Emit

D

Darren

Here is a sample of what I'm trying to build using a dynamic module

public class Thing
{
public Thing() {}
public Thing childThing { get; set; }
}

PropertyBuilder propertyBuilder = typeBuilder.DefineProperty( propertyName, PropertyAttributes.HasDefault, propertyType, null);

How do I get a reference to type Thing before typeBuilder.CreateType() is called?
 
Joined
Mar 31, 2011
Messages
1
Reaction score
0
The TypeBuilder inherits System.Type class.
So we can use the typeBuilder instance as propertyType.

PropertyBuilder propertyBuilder = typeBuilder.DefineProperty( propertyName, PropertyAttributes.HasDefault, typeBuilder, null);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top