Attribute question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Zoltan Hernyak

    #1

    Attribute question

    How can I reach the holder of the attribute?

    I want to define an attribute which is like the WebMethod, but it can
    have a string parameter which may store a different method name, if
    it is different as the method name bellow

    [myWebMethod(dif ferentName)]
    public string Hello(string name)
    {
    ....
    }

    [AttributeUsage( AttributeTarget s.Method, Inherited = false,
    AllowMultiple = true)]
    public class myWebMethod:Sys tem.Attribute
    {
    public string mehodName;
    public myWebMethod(str ing diffName)
    {
    methodname = diffName;
    }
    public myWebMethod()
    {
    // in this case the name is the same as the method name
    methodName = ?????
    }
    }

    How can I set the "methodName " there. What I need is something like
    this:
    methodName = attributeHolder .MethodName;

Working...