KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm tying to collect all Custom Attributes placed over a Property. There are more than one Attributes of the same type assigned to the Property, but when collecting them , the resulting collection only contains the first Attribute of the specific type: The Attribute class [AttributeUsage(System.AttributeTargets.Property, AllowMultiple = true)] public class ConditionAttribute : Attribute{...} Usage: [ConditionAttribute("Test1")] [ConditionAttribute("Test2")] [ConditionAttribute("Test3")] public Color BackColor{get; set;} Now when looping through all Props of the object 'value' whose class contains the Prop "BackColor": foreach (PropertyDescriptor property in TypeDescriptor.GetProperties(value)) { foreach (Attribute attribute in property.Attributes) { ... } .... } the collection property.Attributes only contains ONE Attribute of type "ConditionAttribute" : The one with "Test1". The others are ignored;-( So does AllowMultiple not work for Property Attributes ? Thanks in advance henrik
Tags (comma-separated)
Save Edits
Cancel