For example, I cannot remove the attributes from typeInfo, memberInfo, etc., but XPO allows this (e.g. the RemoveAttribute method). So, I think it would be a good addition here.
See Also:
B39650
Thanks,
Dennis
Proposed Solution:
Provide the RemoveAttribute method into the IBaseInfo interface
Core - Make it possible to remove attributes information stored in the types info system
Answers
Starting from version 10.2, we will provide more flexibility with regard to customizing underlying object types metadata (OBSOLETE - How to customize a Business Model at runtime).
Consider an example, showing the use of a newly introduced BaseInfo.RemoveAttribute method:
C#public override void CustomizeTypesInfo(DevExpress.ExpressApp.DC.ITypesInfo typesInfo) {
base.CustomizeTypesInfo(typesInfo);
ITypeInfo ti = typesInfo.FindTypeInfo(typeof(ITest));
BaseInfo bi = ti.FindMember("Name") as BaseInfo;
BrowsableAttribute attr = bi.FindAttribute<BrowsableAttribute>();
bi.RemoveAttribute(attr);
}
This method removes information about an attribute from the types info system used in XAF to store object types metadata. This method does not modify the underlying metadata available through the .NET Reflection, and so its use is applicable only in the context of the types info system and at certain moments only (e.g. when the CustomizeTypesInfo method is called).
Currently, the RemoveAttribute method is a part of the internal BaseInfo class, because this method is helpful only in a limited number of scenarios, for instance, the ones needed for the eXpand framework, and which assume highly advanced, low-level customizations of our framework.
I would ask all the Support Center users reading this, and who will be using this method in their projects, contact us and describe their specific scenarios. If there is a good demand, it is possible that we will move the RemoveAttribute method into the IBaseInfo interface and support a wider set of scenarios.
Thanks,
Dennis
Hi
There is some issue. Maybe this is bug.
RemoveAttribute metthod really removes attribute but if you add after that some other attribute the removed one is added back. See code:
C#public override void CustomizeTypesInfo(DevExpress.ExpressApp.DC.ITypesInfo typesInfo) {
base.CustomizeTypesInfo(typesInfo);
ITypeInfo ti = typesInfo.FindTypeInfo(typeof(ITest));
BaseInfo bi = ti.FindMember("Name") as BaseInfo;
BrowsableAttribute attr = bi.FindAttribute<BrowsableAttribute>();
bi.RemoveAttribute(attr);
//here bi.FindAttribute<BrowsableAttribute>() == null
bi.AddAttribute(new DisplayNameAttribute("The name"));
//here bi.FindAttribute<BrowsableAttribute>() != null
}
>> I would ask all the Support Center users reading this, and who will be using this method in their projects, contact us and describe their specific scenarios.
I use this method in solution I proposed in ticket Non persistent type doesn't appear in combobox for targettypes with SecurityComplex
Hello Sargis,
To process your post more efficiently, I created a separate ticket on your behalf: T310890: An attribute removed through the BaseInfo.RemoveAttribute method is added back after adding another attribute. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.