Dynamically creating a proxy class

后端 未结 4 1277
深忆病人
深忆病人 2020-11-30 21:39

I am trying to create a proxy class dynamically. I know there are some very good frameworks out there to do this but this is purely a pet project as a learning exercise so

4条回答
  •  隐瞒了意图╮
    2020-11-30 22:16

    You can use dynamic objects as described in this question, but for a dynamically-generated, strongly-typed object you'll have to use Reflection.Emit, as you suspected. This blog has example code showing the dynamic creation and instantiation of a Type.

    I have read that Roslyn has features which make creation of dynamic proxies easier, so maybe take a look there, too.

提交回复
热议问题