Search code examples
c#.netwcfuritemplatewebinvoke

accessing WebInvoke UriTemplate in WCF, I need the template string


I have in WCF [WebInvoke(UriTemplate = "etcetc"

I need to access the string "etcetc" for use in some of my business logic, not sure if this is possible or not? Where is it stored in memory?


Solution

  • you can use something like below to access these attributes :

     MethodBase method = typeof(MyClass).GetMethod("MyMethod");
     WebInvoke attr = (UriTemplate )method.GetCustomAttributes(typeof(WebInvoke), true)[0] ;
     string value = attr.UriTemplate ;  
    

    And to answer your second question : where it is stored ? So it is basically part of your metadata in compiled assembly.