首页 > 其他 > 详细

PostSharp Aop(安装)

时间:2015-02-11 16:16:27      阅读:525      评论:0      收藏:0      [点我收藏+]

项目中 Business层,大多数代码都是public static fun(string xx) 这样的代码,没有接口。AOP 对象都是依赖于接口的,对于这种无接口的类有没有办法AOP。
答案有肯定的。可以用PostSharp。

AOP 依赖接口的我称之为动态AOP,编译时(MSIL)称之为静态AOP。

PostSharp,mono.cecil 都是商业版的,都可以静态AOP。

castle,微软企业库,spring.net 都是动态AOP。

引用星爷的一句话:谁说没有枪头就捅不死人(谁说非要接口才能AOP)。


下载
https://www.postsharp.net/purchase
技术分享 


技术分享     技术分享

 

 



所有的Project 必须Add postSharp to Project只引用DLL是无法使用AOP的

技术分享 技术分享

 


添加完毕后.csproj文件用文本打开,会有Msbuild信息。


<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\..\..\packages\PostSharp.4.0.41\tools\PostSharp.targets" Condition="Exists(‘..\..\..\packages\PostSharp.4.0.41\tools\PostSharp.targets‘)" />
<Target Name="EnsurePostSharpImported" BeforeTargets="BeforeBuild" Condition="‘$(PostSharp30Imported)‘ == ‘‘">
  <Error Condition="!Exists(‘..\..\..\packages\PostSharp.4.0.41\tools\PostSharp.targets‘)" Text="This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them.  For more information, see http://www.postsharp.net/links/nuget-restore." />
  <Error Condition="Exists(‘..\..\..\packages\PostSharp.4.0.41\tools\PostSharp.targets‘)" Text="The build restored NuGet packages. Build the project again to include these packages in the build. For more information, see http://www.postsharp.net/links/nuget-restore." />
</Target>


postsharp 2.0之前没有Msbuild,2.0之后会存在Msbuild信息。

PostSharp Aop(安装)

原文:http://www.cnblogs.com/kfsmqoo/p/4286109.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!