开发者

PostSharp - Attach to WebMethod-attribute methods only

开发者 https://www.devze.com 2022-12-18 15:31 出处:网络
Using PostSharp, is it possible to only \"attach\" to methods having the WebMethod-attribute? Ex: [Trace][WebService]

Using PostSharp, is it possible to only "attach" to methods having the WebMethod-attribute?

Ex:

[Trace][WebService]
public partial class Service : System.Web.Services.WebService
{
    // Caught by PS(WebMethod-attribute)
    [WebMethod]
    public void MyMethod()
    {
        return;
    }

    // Not caught by PS
    public void MySecondMethod()
    {
        return;
    }
}

Have Goog开发者_如何学编程led and searched like a maniac through the PS-community. But havent found what I'm looking for yet. Any comments in the right direction are useful.

Thanks!


There's no real support for that; instead you should use a CompoundAspect (that you would use at assembly or class level) and you may test for the present of the WebMethod custom attribute from the CompoundAspect.ProvideAspects method.

0

精彩评论

暂无评论...
验证码 换一张
取 消