HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/TDijk1/erp-apps.eu/wwwroot/App_Code/ERPApps/ERPSystemCustomizationModule.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using CMS.SettingsProvider;
using CMS.Base;
using CMS.Membership;
using CMS.DataEngine;

/// <summary>
/// Extends UserInfo with attributes of custom VendorInfo
/// </summary>
[ERPSystemCustomizationModuleLoader]
public partial class CMSModuleLoader
{
    private class ERPSystemCustomizationModuleLoaderAttribute : CMSLoaderAttribute
    {
        /// <summary>
        /// Initializes the module
        /// </summary>
        public override void Init()
        {
            UserInfo.TYPEINFO.OnLoadRelatedData += new ObjectTypeInfo.ObjectLoadRelatedDataEventHandler(TYPEINFO_OnLoadRelatedData);
            ClassHelper.OnGetCustomClass += GetCustomClass;
        }

        object TYPEINFO_OnLoadRelatedData(BaseInfo infoObj)
        {
            if ( infoObj is UserInfo )
            {
                // extend UserInfo with custom attributes in VendorInfo
                return new VendorInfo(infoObj as UserInfo);
            }

            return null;
        }

        private static void GetCustomClass(object sender, ClassEventArgs e)
        {
            if (e.Object == null)
            {
                switch (e.ClassName.ToLower())
                {
                    case "erp.buckaroopaymentgateway.buckaroopaymentgatewayprovider":
                        e.Object = new ERP.BuckarooPaymentGateway.BuckarooPaymentGatewayProvider();
                        break;
                }
            }
        }
    }
}