I need to generate a class using Reflection.Emit that implements the following interface.
public interface IObject
{
T Get(string propertyName);
It seems, you want to make fast access to object's properties by its name without reflection at run time. Using Yappi and its Property<> class you can implement given interface like this:
class GeneratedObject : IObject
{
public string Value { get { return "Test"; } }
public T Get(string propertyName)
{
return Property.Get(this,propertyName);
}
}
and then use it like this:
IObject obj = new GeneratedObject();
var value = obj.Get("Value"); //value contains "Test"
Do you still need IObject and dynamic type construction?