Skip to main content
A newer version of this page is available. .
.NET Framework 4.5.2+

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

[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Interface, Inherited = true, AllowMultiple = true)]
public sealed class CustomAttribute :
    Attribute

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;
}

Inheritance

Object
Attribute
CustomAttribute
See Also