最好的免费的方式来使用业务逻辑AOP风格MVC般授权 [英] Best free way to use AOP style MVC-like authorization in business logic

查看:124
本文介绍了最好的免费的方式来使用业务逻辑AOP风格MVC般授权的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我喜欢在ASP.NET MVC的授权属性。与其说属性本身,而是你申请的方式。

I like the authorization attribute in ASP.NET MVC. Not so much the attribute itself, but the way you apply it.

我想在我的非ASP MVC服务层preferably在我的纯C#业务逻辑库,或者至少但不preferably在我的WCF服务端点的端点使用它。 PostSharp 我唯一的答案还是有一个免费的类似的解决方案?

I want to use it in my non-ASP MVC services layer preferably in my plain C# business logic library or at least but less preferably at the endpoints of my WCF service endpoints. Is PostSharp my only answer or is there a free similar solution?

推荐答案

我在一个类似的情况,最近研究了不少选择。

I am in a similar situation and have recently researched quite a few options.

有几个开源项目的AOP使用.NET但多数似乎被抛弃或不是很活跃。 PostSharp是目前最成熟的人。有一个社区版是免费​​的,可用于商业的发展。

There are a few open source projects for AOP with .NET but most seems to be abandoned or not very active. PostSharp is by far the most mature of them. There is a community edition which is free and can be used for commercial development.

其他静态编织(如PostSharp):

Other static weavers (such as PostSharp):


  • AspectDNG(放弃)

  • 爪织机(自2008年以来未更新)

  • AOP.NET(似乎被抛弃)

另一个选择是使用动态代理代替。有使用这种技术,但与Spring.NET除外他们似乎或多或少死以及几个库。

The other option would be to used Dynamic Proxies instead. There are a few libraries which uses this technique but with the exception of Spring.NET they seem to be more or less dead as well.

我相信Spring.NET AOP可以不Spring.NET栈的其余部分使用,但我不能完全肯定。

I believe Spring.NET AOP can be used without the rest of the Spring.NET stack but I'm not entirely sure.

如果你不介意在一个较低的水平工作,总是有Mono.Cecil能做到,它允许你重写组件就像PostSharp没有,但我不会推荐它。这将是一个大量的工作和努力来获得的权利。

If you don't mind to work on a lower level there are always Mono.Cecil which allows you to rewrite assemblies just like PostSharp does but I wouldn't recommend it. It will be a lot of work and hard to get right.

生成具有例如Castle.DynamicProxy或李林甫可能是一个更好的办法,然后动态代理,但它仍然是相当多的管道,使一切工作。同样,除非你已经在使用一个IoC容器,你可能要考虑的,因为这将使它更容易注入在需要的地方代理。相比于使用从PostSharp的OnMethodInvocationAspect或类似这将是一个大量的工作。

Generating dynamic proxies with for example Castle.DynamicProxy or LinFu is probably a better approach then but it will still be quite a lot of plumbing to make everything to work. Also, unless you are already using an IoC-container you might want to consider that as it will make it much easier to inject the proxies where needed. Compared to using an OnMethodInvocationAspect or similar from PostSharp it will be a lot more work.

我目前倾向于使用PostSharp(社区版),因为它做的一切我需要的,是非常容易使用。 Spring.NET似乎有些有趣的,但一个动态的基于代理的解决方案将不会是相当优雅或容易PostSharp使用。

I currently leaning towards using PostSharp (Community Edition) since it does everything I need and is very easy to use. Spring.NET seems somewhat interesting but a dynamic proxy based solution won't be quite as elegant or easy to use as PostSharp.

这篇关于最好的免费的方式来使用业务逻辑AOP风格MVC般授权的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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