.Net 中 AOP 的最佳实现是什么? [英] What is the best implementation for AOP in .Net?

查看:36
本文介绍了.Net 中 AOP 的最佳实现是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 C#、VB.net 中有很多 AOP 实现.这是一些 AOP 实现:

There is a lot of AOP implementation in C#, VB.net. this is some of AOP Implementations:

  • PostSharp
  • Castle DynamicProxy
  • LinFu
  • LOOM.NET
  • Aspect.NET
  • Enterprise Library 3.0 Policy Injection Application Block
  • AspectDNG
  • DotSpect (.SPECT)
  • The Spring.NET Framework as part of its functionality
  • Wicca and Phx.Morph
  • An exhaustive analysis on AOSD solutions for .NET is available from Twente University
  • Seasar.NET
  • Aspect#
  • Puzzle.NAspect
  • Compose*
  • SetPoint
  • NConcern .NET AOP Framework
  • ...

.Net 中 AOP 的最佳实现是什么?我应该使用什么?

What is the best implementation for AOP in .Net? What I should use?

推荐答案

我认为 Castle Dynamic Proxy<如果动态拦截可以满足您的需求,/a> 是首选的解决方案.许多其他想要提供 AOP 功能的框架在内部使用该框架.通常,大多数现有的 IoC 容器现在都提供了一些动态拦截机制(Spring.NET、Castle Windsor、StructureMap 等).如果您已经使用过 IoC 容器,那么查看它的建议可能会更容易.

I think that Castle Dynamic Proxy is the solution of choice if dynamic interception can handle your needs. This framework is used internally by a lot of other frameworks that want to offer AOP capabilities. Typically, most of existing IoC containers now provide some dynamic interception mechanisms (Spring.NET, Castle Windsor, StructureMap, etc.) If you already work with an IoC container, maybe it could be easier to look at what it proposes.

如果动态拦截不能满足你的需求(编织密封类,拦截非虚调用等),那你当然想要静态编织.PostSharp 是该域中的引用.

If dynamic interception can't address your needs (weaving sealed class, intercepting non-virtual call, etc.), then you certainly want static weaving. PostSharp is the reference in this domain.

请注意,它还存在 Linfu,可用于利用两种 AOP 方式.

Note that it also exists Linfu, that can be used to leverage both AOP fashions.

这篇关于.Net 中 AOP 的最佳实现是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆