I will contact to collect all user attributes placed on top of the property. There are several attributes of the same type assigned to a property, but when they are collected, the resulting collection contains only the first attribute of a certain type:
Attribute class
[AttributeUsage(System.AttributeTargets.Property, AllowMultiple = true)] public class ConditionAttribute : Attribute{...}
Using:
[ConditionAttribute("Test1")] [ConditionAttribute("Test2")] [ConditionAttribute("Test3")] public Color BackColor{get; set;}
Now, when the cycle through all the details of the object "value", the class of which contains Prop "BackColor":
foreach (PropertyDescriptor property in TypeDescriptor.GetProperties(value)) { foreach (Attribute attribute in property.Attributes) { ... } .... }
the collection .Attributes property contains only one attribute of type "ConditionAttribute": the one who has "Test1". The rest are ignored ;-(
Does AllowMultiple not work for property attributes?
Thank you in advance
Henric
attributes custom-attributes
henrik May 11 '09 at 15:33 2009-05-11 15:33
source share