accessing WebInvoke UriTemplate in WCF, I need the template string

163 Views Asked by At

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?

1

There are 1 best solutions below

0
rahulaga-msft On BEST ANSWER

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.