CustomAttribute Class
Specifies a custom attribute for a class or a class member.
Namespace: DevExpress.Xpo
Assembly: DevExpress.Xpo.v24.1.dll
NuGet Packages: DevExpress.Win.PivotGrid, DevExpress.Win.TreeMap, DevExpress.Xpo
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
The code below shows how to declare this attribute:
using DevExpress.Xpo;
namespace DXSample {
public class Person :XPObject {
public Person(Session session) : base(session) { }
//...
private int fAge;
[Custom("Validation", "Age between (20, 40)|The age can be between 20 and 40 years old")]
public int Age {
get {
return fAge;
}
set {
SetPropertyValue("Age", ref fAge, value);
}
}
}
}
To get the attribute value, use the following code:
using DevExpress.Xpo;
using DevExpress.Xpo.DB;
//...
var uow = new UnitOfWork();
var person = new Person(uow);
var ageMember = person.ClassInfo.FindMember(nameof(Person.Age));
CustomAttribute attribute = (CustomAttribute)ageMember.FindAttributeInfo("Validation");
string attributeValue = attribute.Value;
See Also