building a self referencing class using System.Reflection.Emit

  • Thread starter Thread starter Darren
  • Start date Start date
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?
 
The TypeBuilder inherits System.Type class.
So we can use the typeBuilder instance as propertyType.

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