CustomAttributes in Reflection and CodeDOM

M

MarkoH

I want to copy CustomAttributes of a type in assembly (particularly Web
Service method attributes) to a new file which I'm generating through the
use of CodeDOM (particularly CodeAttributeDeclarationCollection). But
MethodInfo.CustomAttributes in System.Reflection and
CodeMemberMethod.CustomAttributes are two completely different properties of
totally different types.

What way can I copy those attributes over to my CodeDOM tree ?
 
M

MarkoH

Mistake there..MethodInfo.GetCustomAttributes() method to get custom
attributes, there is no property. Still, this method returns object[] so I
can't do much with it.

?
 
M

Mattias Sjögren

Mistake there..MethodInfo.GetCustomAttributes() method to get custom
attributes, there is no property.
Still, this method returns object[] so I can't do much with it.

One of the objects in that a rray should be an instance of the
attribute type you're looking for. Just cast it to the attribute type
and read its properties.



Mattias
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top