code_junkie

Problems finding an attribute attached to a Type

Nov 12th, 2011
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. Assembly a = Assembly.LoadFile(file);
  2. foreach (Type t in a.GetTypes())
  3. {
  4. object[] attr = t.GetCustomAttributes(typeof(SchemeNameAttribute), false);
  5.  
  6. foreach (object attribute in attr)
  7. {
  8. SchemeNameAttribute schemeName = attribute as SchemeNameAttribute;
  9. if (schemeName != null && schemeName.Name.ToLower() == brickName.ToLower() )
  10. {
  11. return t;
  12. }
  13. }
  14. }
  15.  
  16. object[] attr = t.GetCustomAttributes(false);
  17.  
  18. SchemeNameAttribute schemeName = attribute as SchemeNameAttribute;
Add Comment
Please, Sign In to add comment