在使用NHibernate,您通过虚拟方式定义你的entites,和NHibernate将创建跟踪更改的对象的代理对象。
When using NHibernate, you define your entites with virtual methods, and NHibernate will create a proxy object that tracks changes to your object.
在起订量,框架会奇迹般地创造派生类型从一个接口或基类。例如
In Moq, the framework will magically create a derived type from an interface or a base class. e.g.
var mock = new Mock<IFoo>();
IFoo magicFoo = mock.Object;
这是真的很酷。如何将这些框架做呢?他们是否使用反射,泛型,某种动态编译的,还是其他什么东西?
This is really cool. How do these frameworks do it? Do they use reflection, generics, some kind of dynamic compilation, or something else?
我知道这些都是开源的项目,我可以去通过code洞穴探险,但是我想有一个简洁的答案在这里 - 可能与替代品的
起订量使用城堡动态代理,但是,只是认为这将是值得加入也有一些其他的框架,允许你创建代理对象。由于NHibernate的2.1还允许您使用以下任何一项:
Moq uses Castle Dynamic Proxy, however, just thought it would be worth adding there are also a number of other frameworks that allow you to create Proxy objects. As of NHibernate 2.1 it also allows you to use any one of the following:
城堡动态代理 李林甫框架 Spring.NET Castle Dynamic Proxy LinFu Framework Spring.NET每个这些项目都有他们是如何做到这一点的一个简短的解释,这是希望的那种,你要寻找的答案。
Each of these projects has a brief explaination of how they achieve this, which is hopefully the kind of answer you're looking for.
上一篇:无法更新我在谷歌Play应用程式:AAPT错误我在、程式、错误、Play
下一篇:FB SDK,requestNewPublishPermissions()不调用任何回调回调、FB、SDK、requestNewPublishPermissions