views:

94

answers:

1

Hi,

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 Googled 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!

A: 

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.

Gael Fraiteur