小编kar*_*rma的帖子

使用Reflection.Emit创建实现接口的类

我需要使用Reflection.Emit生成一个实现以下接口的类.

public interface IObject
{
    T Get<T>(string propertyName); 
}
Run Code Online (Sandbox Code Playgroud)

有没有人有一个例子,我将如何发出以下作为一个简单的测试用例?

class GeneratedObject : IObject
{
    public T Get<T>(string propertyName)
    {
        // this is the simplest possible implementation
        return default(T);
    }
}
Run Code Online (Sandbox Code Playgroud)

.net c# reflection interface reflection.emit

13
推荐指数
1
解决办法
2万
查看次数

标签 统计

.net ×1

c# ×1

interface ×1

reflection ×1

reflection.emit ×1