由网友(人情味儿)分享简介:可能重复: C#包通过属性方法 我想实现这样的功能:[Wrap]public void Foo(){ /* foo logic */}其中, [总结] 属性是一个属性,它封装内的一些外code函数的逻辑 - 只是举例让它成为一个事务范围:Where [Wrap] attribute i...
可能重复: C#包通过属性方法
我想实现这样的功能:
[Wrap]
public void Foo()
{
/* foo logic */
}
其中, [总结]
属性是一个属性,它封装内的一些外code函数的逻辑 - 只是举例让它成为一个事务范围:
Where [Wrap]
attribute is an attribute, which wraps function logic within some outer code - just for example let it be a transaction scope:
using(var scope = new TransactionScope())
{
/* foo logic */
scope.Complete();
}
如何写这样的属性?
How to write such an attribute ?
推荐答案
这就是 面向方面的编程的其中总结
是纵横的。
C#中没有内置的用于面向方面编程的支持,但也有插件,如 postsharp 支持它
C# has no built in support for aspect oriented programming, but there are addons such as postsharp that supports it.
相关推荐
最新文章