简体   繁体   English

LinFu.DynamicProxy和Castle.DynamicProxy之间有什么区别?

[英]What are the differences between LinFu.DynamicProxy and Castle.DynamicProxy?

I am looking at adding logic to a library I am working on that would require the need for a Dynamic Proxy. 我正在寻找向我正在处理的库中添加逻辑,这需要动态代理。 I would like to get some advice from user's who have used these two library's in a production environment. 我想从在生产环境中使用这两个库的用户那里得到一些建议。 Does one out perform the other, were there any shortcoming's which made you have to switch to the other, etc. Basically tell me your experiences with the library's. 有没有人执行另一个,是否有任何缺点,使你必须切换到另一个,等等。基本上告诉我你的图书馆的经验。 The answers will help me decide which one to use. 答案将帮助我决定使用哪一个。

-- Edit -- - 编辑 -


I forgot to mention that the library I am developing will support Mono, therefore any knowledge you can share about the two libraries and their support for Mono would be great also. 我忘了提到我正在开发的图书馆将支持Mono,因此你可以分享关于这两个图书馆及其对Mono的支持的任何知识也会很棒。

I am a committer to Castle, contributing to Dynamic Proxy, so I may be biased, but I generally think Castle's Dynamic proxy is far better solution. 我是Castle的提交者,为动态代理做贡献,所以我可能有偏见,但我一般认为Castle的动态代理是更好的解决方案。 I'm talking here about LinFu DynamicProxy v1.0 because that's what I'm familiar with. 我在这里谈论LinFu DynamicProxy v1.0,因为这是我熟悉的。 LinFu.Proxy 2 is based on Mono.Cecil and is rewritten from the scratch. LinFu.Proxy 2基于Mono.Cecil并从头开始重写。

  • Castle covers wider range of scenarios. 城堡涵盖了更广泛的场景。
  • Castle has (a lot) larger user base, and is proven in many OSS and commercial applications Castle拥有(大量)更大的用户群,并在许多OSS和商业应用程序中得到验证
  • Castle is actually performing better ( link ) 城堡实际上表现更好( 链接
  • Castle has cleaner, easier to use API for example invoking target method to Castle DynamicProxy looks like this: Castle具有更清晰,更易于使用的API,例如调用Castle DynamicProxy的目标方法如下所示:

invocation.Proceed();

for LinFu, it looks like this (actual method/property name may vary as I'm writing it from memory) 对于LinFu来说,它看起来像这样(实际的方法/属性名称可能因我从内存中写入而有所不同)

//invocation.TargetMethod is MethodInfo, so you're using reflection
invocation.TargetMethod.Invoke(invocation.Target,invocation.Parameters);
  • Castle has an active user group where you can quickly get answers to your questions. Castle有一个活跃的用户组,您可以在其中快速获得问题的答案。

The performance issue, mentioned by the other answer are not DynamicProxy issue, but are result of bug in Microsoft's implementation of BCL (on Mono there is no such issue BTW). 另一个答案提到的性能问题不是DynamicProxy问题,而是微软实施BCL的bug(在Mono上没有这样的问题BTW)。 This only manifests itself when you have many (over 200+) proxy types in single ModuleScope. 这仅在单个ModuleScope中有许多(超过200个)代理类型时才会显现。

Solution is trivial - don't generate that many proxy types (usually you won't have to) or use many ModuleScopes/ProxyGenerators (for example Rhino.Mocks uses this approach) 解决方案是微不足道的 - 不要生成那么多代理类型(通常你不必)或使用很多ModuleScopes / ProxyGenerators(例如Rhino.Mocks使用这种方法)

Personally I do not develop on Mono, so I don't have firsthand experience, however there are libraries using Castle DP on Mono, and we didn't get any compliaints so i guess it works just fine. 我个人不用单声道开发,所以我没有第一手经验,但是在Mono上有使用Castle DP的库,我们没有得到任何compliaints所以我想它的工作正常。

Since my benchmark few months ago, there has been no new release of Castle DP (new version is targeted at the end of the year). 自几个月前我的基准测试以来,没有新版本的Castle DP(新版本的目标是年底)。 LiFu has a 2.0 version, but I'm not sure if it is trunk only, or released. LiFu有一个2.0版本,但我不确定它是仅仅是主干还是已发布。 I don't know about Spring or Unity. 我不知道Spring或Unity。

Linfu is a more lightweight proxy generator than the Castle proxy generator. Linfu是一个比Castle代理生成器更轻量级的代理生成器。

When deciding which to use, to be honest it doesn't make much difference. 在决定使用哪个时,说实话它并没有太大的区别。

According to the author, Linfu will greatly outperforms the Castle generator, but in my own observations of real world usage the difference in speed is marginal. 根据作者的说法,Linfu将大大优于Castle生成器,但在我自己对现实世界使用的观察中,速度的差异是微不足道的。

Having said that Linfu will outperform Castle, and I'm not aware of anything Castle has over it, and so I always use Linfu. 虽然说林府的表现会超过城堡,但我不知道Castle有什么东西,所以我总是使用Linfu。

We had some perf issues related to LinFu vs Castle in 2.0.1. 我们在2.0.1中遇到了与LinFu vs Castle相关的一些性能问题。 http://niemware.blogspot.com/2009/11/nhibernate-21-performance-issues-with.html http://niemware.blogspot.com/2009/11/nhibernate-21-performance-issues-with.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 具有拦截和Castle.DynamicProxy的StructureMap - StructureMap with Interception and Castle.DynamicProxy 用城堡装饰由结构图4返回的所有实例。 - Decorate all instances returned by structuremap 4 with castle.Dynamicproxy 如何从 Castle.DynamicProxy 中的 ProxyGenerationHook 访问自定义方法属性 - How to access custom method attributes from ProxyGenerationHook in Castle.DynamicProxy 城堡动态代理回购在哪里? - Where is the castle dynamicproxy repo? 在使用NHibernate的延迟加载场景中使用Castle.DynamicProxy实现IDataErrorInfo - Implementing IDataErrorInfo using Castle.DynamicProxy in lazy loading scenario using NHibernate 没有基类问题,如何在这种特殊情况下使用Castle.DynamicProxy Mixin? - No base class problem, How to use Castle.DynamicProxy Mixin in this particular case? Castle DynamicProxy - 'classToProxy'必须是一个类 - Castle DynamicProxy - 'classToProxy' must be a class DispatchProxy如何与Castle DynamicProxy进行比较? - How DispatchProxy compare to Castle DynamicProxy? Castle DynamicProxy:获取未经过代理的对象 - Castle DynamicProxy: Get unproxied object 如何在不引用Castle DynamicProxy的情况下检测Type是否是生成的DynamicProxy? - How to detect if a Type is a generated DynamicProxy without referencing Castle DynamicProxy?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM