.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+

CustomAttribute Class

Specifies a custom attribute for a class or a class member.

Namespace: DevExpress.Xpo

Assembly: DevExpress.Xpo.v21.2.dll

Declaration

[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Interface, Inherited = true, AllowMultiple = true)]
public sealed class CustomAttribute :
    Attribute
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Field | AttributeTargets.Interface | AttributeTargets.Property, 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;
}

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the CustomAttribute class.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

Inheritance

Object
Attribute
CustomAttribute
See Also