当前位置:首页 > Web开发 > 正文

支持AOP横切关注点

2024-03-31 Web开发

Unity:微软patterns&practicest团队开发的IOC依赖注入框架,撑持AOP横切存眷点。

MEF(Managed Extensibility Framework):是一个用来扩展.NET应用措施的框架,可开发插件系统。

Spring.NET:依赖注入、面向方面编程(AOP)、数据访谒抽象,、以及ASP.NET集成。

Autofac:最风行的依赖注入和IOC框架,轻量且高性能,对项目代码几乎无任何侵入性。

Ninject:基于.NET轻量级开源的依赖注入IOC框架

AOP框架

Castle

Encase 是C#编写开发的为.NET平台供给的AOP框架。Encase 奇特的供给了把方面(aspects)部署到运行时代码,而其它AOP框架依赖配置文件的方法。这种部署方面(aspects)的要领辅佐缺少经验的开发人员提高开发效率。

NKalore 是一款编程语言,它扩展了C#允许在.net平台使用AOP。NKalore的语法简单、直不雅观,它的编译器是基于Mono C#编译器(MCS)。NKalore目前只能在命令行或#Develop内部使用。NKalore兼容大众语言规范CLS(Common Language Specification),它可以在任何.NET开发环境中使用,包孕微软的Visual Studio .NET。

PostSharp 读取.NET字节模块,,转换成东西模型。让插件分析和转换这个模型并写回到MSIL。PostSharp使开发措施分析应用措施容易得像分析代码法则和设计模式,它使措施开发的思想厘革为面向方面软件开发(AOSD/AOD)思想。

AspectDNG 的方针是为.NET开发人员供给简单而成果强大的AOP-GAOP实现。它效仿Java下的开源工具AspectJ 和 Spoon,成熟水平也很接近它们。

RAIL(Runtime Assembly Instrumentation Library) 开源项目可以在C#措施集加载和运行前进行措置惩罚惩罚控制调解和从头构建。C#在CLR中,我们已经能够动态加载措施集并且获得措施集中的类和要领,RAIL(Runtime Assembly Instrumentation Library)的呈现填补了CLR措置惩罚惩罚过程中的一些空白。

SetPoint是一款.NET框架下的全成果(full-featured)AOP引擎.它着重为称为语义切点(semantic pointcuts)的界说依赖RDF/OWL的使用.它的成果为一个IL-level,highly dynamic weaver&LENDL,一个引人注目的界说语言、、、、、、

DotNetAOP为 CLR language供给AOP 框架根本属性。

NAop是一个DotNet下的AOP框架。

AspectSharp是DotNet下的免费AOP框架,它以Dynamic Proxies和XML作为配置文件。

一个Castle的实现

//首先下载Castle.Windsor.dll //自界说Interceptor public class MyInterceptor : IInterceptor { public void Intercept(IInvocation invocation) { PreProceed(invocation); invocation.Proceed(); PostProceed(invocation); } public void PreProceed(IInvocation invocation) { Console.WriteLine("要领执行前"); } public void PostProceed(IInvocation invocation) { Console.WriteLine("要领执行后"); } } //用户注册接口和实现 public interface IUserProcessor { void RegUser(User user); } public class UserProcessor : IUserProcessor { public virtual void RegUser(User user) { Console.WriteLine("用户已注册。Name:{0},PassWord:{1}", user.Name, user.PassWord); } } //客户端挪用 public class Client { public static void Run() { try { ProxyGenerator generator = new ProxyGenerator(); MyInterceptor interceptor = new MyInterceptor(); UserProcessor userprocessor = generator.CreateClassProxy<UserProcessor>(interceptor); User user= new User() { Name = "lee", PassWord = "123123123123" }; userprocessor.RegUser(user); } catch (Exception ex) { throw ex; } } }

.Net常见的IOC框架及AOP框架

温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/file/web/33291.html