Ticket S34769
Visible to All Users

How to customize a domain component interface (DC) type information at runtime, e.g. define a custom member

created 15 years ago
Show previous comments (4)
SR SR
Steven Rasmussen 11 years ago

    Hi Dennis, can you please comment on whether this new event will be in 13.2? Could you also please provide a short code snippet on how to accomplish this when it is released?

    Dennis Garavsky (DevExpress) 11 years ago

      @Steven: Thanks for your interest. Once we have news on this, we will surely provide additional details and code snippets.

      Dennis Garavsky (DevExpress) 11 years ago

        @Steven: I forgot to mention that currently you can already handle the XafApplication.SettingUp event as shown in DC - Provide the capability to change database mappings for domain components and their members.

        Answers approved by DevExpress Support

        created 10 years ago (modified 7 years ago)

        Hello,

        I want to close the current request with two possible solutions discussed earlier:

        1. Creating custom members (except for associations) in code within the XafApplication.SettingUp event handler as follows:

        C#
        using System; using DevExpress.ExpressApp; using DevExpress.ExpressApp.DC; using DevExpress.ExpressApp.Security; using DevExpress.ExpressApp.Win; using DevExpress.ExpressApp.Xpo; namespace XCRM.Win { public partial class XCRMWinApplication : WinApplication { public XCRMWinApplication() { InitializeComponent(); this.SettingUp += XCRMWinApplication_SettingUp; } void XCRMWinApplication_SettingUp(object sender, SetupEventArgs e) { string customMemberName = "CustomMemberForDomainComponent"; Type customMemberType = typeof(string); string customMemberExpression = "";//Dennis: Leave it empty if it is non-calcualted/persistent field. TypeInfo domainComponentTypeInfo = (TypeInfo)XafTypesInfo.Instance.FindTypeInfo(typeof(XCRM.Module.ICRMContact)); IMemberInfo memberInfo = domainComponentTypeInfo.FindMember(customMemberName); if(memberInfo == null) { memberInfo = domainComponentTypeInfo.CreateMember(customMemberName, customMemberType, customMemberExpression); } }

        2. Declaring custom members via the Model Editor using the feature described in eXpressApp Framework > Concepts > Business Model Design > Types Info Subsystem > Customize Business Object's Metadata. Using this feature, you can indirectly define custom IModelMember objects in the Application Model so that they are later used to customize the types metadata when the static DevExpress.ExpressApp.ApplicationModelManager.AddCustomMembersFromModelToTypeInfo  method (this particular API is internal and may be changed in the future) is called internally or from custom code.

        IMPORTANT NOTES

        1. Runtime associations between domain components are not currently supported. Defining reference properties whose type is another domain component will work in simple cases only when no shared parts are involved due to the runtime DC entities generation specifics.
        2. Do not mix the Domain Components (DC) technology with Non-Persistent Objects. This functionality is unsupported for POCO marked with the DomainComponentAttribute. If you attempt to call the ITypeInfo.CreateMember method for such a POCO, you will receive a meaningful exception. Refer to the How to create custom/dynamic properties for a non-persistent POCO marked with DomainComponentAttribute article for possible solutions.
          Show previous comments (3)
          Dennis Garavsky (DevExpress) 10 years ago

            @Peter: As far as I remember it is not currently possible to define collection properties via the ITypesInfo API for both DC and pure XPO. In the E250 example, it is done using the XPDictionary directly. I have not yet tested this approach with DC to say for sure whether it is supported as well, but I will do that and inform you of my results.

            Dennis Garavsky (DevExpress) 10 years ago

              @Peter: I have verified that adding a XPCollection<IPersistentObject2> type property is neither supposed to work for DC nor for pure DC.
              Please open a separate ticket in the Support Center and describe your business scenario from the end-user perspective in detail, so we can find a good technical solution for you.

              PK PK
              Peter Kieslinger 10 years ago

                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.