CustomAttribute Class
Specifies a custom attribute for a class or a class member.
Namespace: DevExpress.Xpo
Assembly: DevExpress.Xpo.v21.1.dll
NuGet Package: DevExpress.Xpo
Declaration
Remarks
The CustomAttribute class allows you to provide custom parameters for a class or a class member. The attribute’s name is specified by the CustomAttribute.Name property. Its value is specified by the CustomAttribute.Value property.
Example
This sample demonstrates how to load metadata from a string in XML format.
public bool IsDisplayNameAttributeSpecified(string className) {
string xmlMetaData =
"<Model xmlns=\"http://www.devexpress.com/products/xpo/schemas/1.9/xpometadata.xsd\">" +
"<Class assembly=\"" + "WindowsApplication" + "\" type=\"" + className + "\">" +
" <Attributes>" +
" <CustomAttribute Name=\"DisplayName\" Value=\"Test person\"/>" +
" <CustomAttribute Name=\"ReadOnly\" Value=\"true\"/>" +
" </Attributes>" +
"</Class>" +
"</Model>";
ReflectionDictionary dict = new ReflectionDictionary();
dict.LoadXmlMetadata(new System.IO.StringReader(xmlMetaData));
XPClassInfo ci = dict.GetClassInfo("WindowsApplication", className);
if (ci.HasAttribute("DisplayName"))
return true;
return false;
}
See Also