Ticket S33097
Visible to All Users

Core - Make it possible to remove attributes information stored in the types info system

created 16 years ago

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

Answers

created 14 years ago (modified 8 years ago)

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

    Comments (2)
    SG SG
    Sargis Gyulbaryan 9 years ago

      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

      Anatol (DevExpress) 9 years ago

        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.

        Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

        Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.