CustomAttributes in Reflection and CodeDOM

  • Thread starter Thread starter MarkoH
  • Start date Start date
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 ?
 
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.

?
 
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
 
Back
Top