PC Review


Reply
Thread Tools Rate Thread

building a self referencing class using System.Reflection.Emit

 
 
Darren
Guest
Posts: n/a
 
      9th Jun 2009
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?

 
Reply With Quote
 
 
 
 
New Member
Join Date: Mar 2011
Posts: 1
 
      31st Mar 2011
The TypeBuilder inherits System.Type class.
So we can use the typeBuilder instance as propertyType.

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

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
hello.il to hello.exe using System.Reflection.Emit Volker Thebrath Microsoft Dot NET Framework 0 28th Nov 2007 01:10 PM
Reflection.Emit - Easy way to persist a class from ExecutingAssembly ? Desmond Cassidy Microsoft C# .NET 0 15th Sep 2006 02:17 PM
Reflection.Emit accessing a field in the base class of a dynamically constructed class Douglas Harber Microsoft Dot NET Framework 0 11th Feb 2006 11:28 PM
Creating DesignerVerbs for a Reflection.Emit-ed class for use in a PropertyGrid Lee Henson Microsoft Dot NET Framework Forms 3 31st Mar 2005 05:57 AM
where to ask question about using System.Reflection.Emit? Chuck Hartman Microsoft Dot NET Framework 4 16th Jan 2004 08:51 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:51 AM.