Take these two code things: and looks like a class: Where First gives one of the two attributes, returns the second. What is the difference due to this? to: AttributeUsageAttribute.AllowMultiple Override should be asked "What" is this difference? ": The values returned by TypeDescriptor handles many features if you do not need this type of order detail, and the way
example.GetType () .GetCustomAttributes (true) . (Where object => is the object validation attribute);
TypeDescriptor.GetAttributes (example) .OfType & LT; ValidationAttribute & gt; ();
[RequiredIfOtherPropertyIsNotEmpty ("state", "city", error message = ErrorDescription.CreateAccount_CityRequiredWithState)] [RequiredIfOtherPropertyIsNotEmpty (" State "," address 1 ", error message = ErrorDescription.CreateAccount_Address1RequiredWithState)] Public class ManagePostModel {...}
RequiredIfOtherPropertyIsNotEmpty
is a ValidationAttribute < / Code> and
allow multilevel = true
. To return several instances of a
Attribute AttributeCollection from
,
Attribute.TypeId
property to answer your attribute. TypeDescriptor
can be extended to runtime, while this can not be in the type
MSDN page I add more to the related. P> is a problem, you are probably
Type.GetCustomAttributes .
Sunday, 15 August 2010
attributes - C#: What's the Difference Between TypeDescriptor.GetAttributes() and GetType() .GetCustomAttributes? -
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment