Back to Devexpress

IMemberInfo.AddAttribute(Attribute, Boolean) Method

expressappframework-devexpress-dot-expressapp-dot-dc-dot-imemberinfo-dot-addattribute-x28-system-dot-attribute-system-dot-boolean-x29.md

latest3.9 KB
Original Source

IMemberInfo.AddAttribute(Attribute, Boolean) Method

Dynamically associates the specified attribute with the current member.

Namespace : DevExpress.ExpressApp.DC

Assembly : DevExpress.ExpressApp.v25.2.dll

NuGet Package : DevExpress.ExpressApp

Declaration

csharp
IMemberInfo AddAttribute(
    Attribute attribute,
    bool skipRefresh
)
vb
Function AddAttribute(
    attribute As Attribute,
    skipRefresh As Boolean
) As IMemberInfo

Parameters

NameTypeDescription
attributeAttribute

An attribute to be associated with the current member.

| | skipRefresh | Boolean |

true to prevent the Types Info Subsystem from reloading XPDictionary information immediately. In this case, you need to call the XafMemberInfo.Refresh method for each updated member.
false to immediately refresh the type/member metadata.

|

Returns

TypeDescription
IMemberInfo

An object that allows you to further interact with member metadata information.

|

Remarks

csharp
public override void CustomizeTypesInfo(DevExpress.ExpressApp.DC.ITypesInfo typesInfo) {
    base.CustomizeTypesInfo(typesInfo);
    CalculatedPersistentAliasHelper.CustomizeTypesInfo(typesInfo);
    ITypeInfo pType = typesInfo.FindTypeInfo(typeof(PersistentObject1));
    pType.CreateMember("CustomDecimalField", typeof(decimal))
        .AddAttribute(new ModelDefaultAttribute("DisplayFormat", "n2"))
        .AddAttribute(new ModelDefaultAttribute("EditMask", "n2"));
    // ...
    typesInfo.RefreshInfo(typeof(PersistentObject1));
}

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the AddAttribute(Attribute, Boolean) method.

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.

xaf-customize-xpo-business-model-at-runtime/CS/CustomizeXPOModel/CustomizeXPOModel.Module/Module.cs#L55

csharp
memberInfo1 = typeInfo1.CreateMember("PersistentObject2s", typeof(DevExpress.Xpo.XPCollection<PersistentObject2>));
memberInfo1.AddAttribute(new DevExpress.Xpo.AssociationAttribute("PersistentObject1-PersistentObject2s", typeof(PersistentObject2)), true);
memberInfo1.AddAttribute(new DevExpress.Xpo.AggregatedAttribute(), true);

See Also

Use Metadata to Customize Business Classes Dynamically

Types Info Subsystem

IMemberInfo Interface

IMemberInfo Members

DevExpress.ExpressApp.DC Namespace