The requested page is not available for the requested platform. You are viewing the content for .NET Framework 4.5.2+ platform.
.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.v19.1.dll

Declaration

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

Examples

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