Ejemplo n.º 1
0
        public SimpleHandlerDispatchDelegateCacheProvider()
        {
            Type bridgeType = typeof(BridgeType);

            // PcTyped
            MethodInfo callPcTypedEventSubscriber_mi = bridgeType.GetMethod("CallPcTypedEventSubscriber", BindingFlags.Instance | BindingFlags.NonPublic);

            _callPcTypedEventSubsCache = new TwoTypesDelegateCache <CallPcTypedEventSubscriberDelegate>(callPcTypedEventSubscriber_mi);

            // PcGen
            MethodInfo callPcGenEventSubscriber_mi = bridgeType.GetMethod("CallPcGenEventSubscriber", BindingFlags.Instance | BindingFlags.NonPublic);

            _callPcGenEventSubsCache = new DelegateCache <CallPcGenEventSubscriberDelegate>(callPcGenEventSubscriber_mi);

            // PcObject
            MethodInfo callPcObjEventSubscriber_mi = bridgeType.GetMethod("CallPcObjectEventSubscriber", BindingFlags.Instance | BindingFlags.NonPublic);

            _callPcObjEventSubsCache = new DelegateCache <CallPcObjEventSubscriberDelegate>(callPcObjEventSubscriber_mi);

            // PcStandard
            MethodInfo callPcStEventSubscriber_mi = bridgeType.GetMethod("CallPcStEventSubscriber", BindingFlags.Instance | BindingFlags.NonPublic);

            _callPcStEventSubsCache = new DelegateCache <CallPcStandardEventSubscriberDelegate>(callPcStEventSubscriber_mi);

            // PcChanging
            MethodInfo callPChangingEventSubscriber_mi = bridgeType.GetMethod("CallPChangingEventSubscriber", BindingFlags.Instance | BindingFlags.NonPublic);

            _callPChangingEventSubsCache = new DelegateCache <CallPChangingEventSubscriberDelegate>(callPChangingEventSubscriber_mi);

            // PropStoreNode Parent Changed
            MethodInfo callPSNodeParentChangedEventSubscriber_mi = bridgeType.GetMethod("CallPSNodeParentChangedEventSubscriber", BindingFlags.Instance | BindingFlags.NonPublic);

            _callPSParentNodeChangedEventSubsCache = new DelegateCache <CallPSParentNodeChangedEventSubDelegate>(callPSNodeParentChangedEventSubscriber_mi);

            // Proxy -- Holds a copy of the original delegate but without the target.
            _delegateProxyCache = new DelegateProxyCache();
        }
Ejemplo n.º 2
0
        // TODO: instead of injecting types, inject objects that implement a specified interface.
        // Currently this is always called with typeof(PropBag), typeof(APFGenericMethodTemplates)
        public SimpleDelegateCacheProvider(Type propBagType, Type propCreatorType)
        {
            //long startBytes = System.GC.GetTotalMemory(true);
            //long curBytes = startBytes;


            #region Method on PropBag (DoSetDelegate, CVPropFromDsDelegate, and CViewManagerFromDsDelegate)

            // Changed to use Static Method. (DRM 2/6/2018)
            // DoSet (i.e., update) a PropItem's value.
            MethodInfo doSetMethodInfo = propBagType.GetMethod("DoSetBridge", BindingFlags.Static | BindingFlags.NonPublic);
            //curBytes = Sizer.ReportMemConsumption(startBytes, curBytes, "After GetMethod(DoSetBridge)");

            DoSetDelegateCache = new DelegateCache <DoSetDelegate>(doSetMethodInfo);
            //curBytes = Sizer.ReportMemConsumption(startBytes, curBytes, "After new DelegateCache<DoSetDelegate>");

            // Changed to use Static Method. (DRM 3/16/18)
            // CollectionView Manager using an optional MapperRequest.
            MethodInfo getOrAddCViewManager_mi = propBagType.GetMethod("CViewManagerFromDsBridge", BindingFlags.Static | BindingFlags.NonPublic);
            //curBytes = Sizer.ReportMemConsumption(startBytes, curBytes, "After GetMethod(CViewManagerFromDsBridge)");

            GetOrAddCViewManagerCache = new TwoTypesDelegateCache <CViewManagerFromDsDelegate>(getOrAddCViewManager_mi);
            //curBytes = Sizer.ReportMemConsumption(startBytes, curBytes, "After TwoTypesDelegateCache<CViewManagerFromDsDelegate>");

            // Changed to use Static Method. (DRM 3/16/18)
            // Collection View Manager Provider from a viewManagerProviderKey. Key consists of an optional MapperRequest and a Binding Path.)
            MethodInfo getOrAddCViewManagerProvider_mi = propBagType.GetMethod("CViewManagerProviderFromDsBridge", BindingFlags.Static | BindingFlags.NonPublic);
            GetOrAddCViewManagerProviderCache = new TwoTypesDelegateCache <CViewManagerProviderFromDsDelegate>(getOrAddCViewManagerProvider_mi);

            #endregion

            #region IEnumerable-Type Prop Creation MethodInfo
            #endregion

            #region ObservableCollection<T> Prop Creation MethodInfo

            // TODO: Consolidate these into a single Method, as was done for Scalar Props.

            // Create C Prop with no value
            MethodInfo createCPropNoVal_mi = propCreatorType.GetMethod("CreateCPropWithNoValue", BindingFlags.Static | BindingFlags.NonPublic);
            CreateCPropWithNoValCache = new TwoTypesDelegateCache <CreateCPropWithNoValueDelegate>(createCPropNoVal_mi);

            // Create C Prop From string
            MethodInfo createCPropFromString_mi = propCreatorType.GetMethod("CreateCPropFromString", BindingFlags.Static | BindingFlags.NonPublic);
            //curBytes = Sizer.ReportMemConsumption(startBytes, curBytes, "After GetMethod(CreateCPropFromString)");

            CreateCPropFromStringCache = new TwoTypesDelegateCache <CreateCPropFromStringDelegate>(createCPropFromString_mi);
            //curBytes = Sizer.ReportMemConsumption(startBytes, curBytes, "After new TwoTypesDelegateCache<CreateCPropFromStringDelegate>");

            // Create Prop From Object
            MethodInfo createCPropFromObject_mi = propCreatorType.GetMethod("CreateCPropFromObject", BindingFlags.Static | BindingFlags.NonPublic);
            CreateCPropFromObjectCache = new TwoTypesDelegateCache <CreateCPropFromObjectDelegate>(createCPropFromObject_mi);

            #endregion

            #region CollectionViewSource Prop Creation MethodInfo

            // NOTE: These don't require a Delegate since they are non-generic methods.
            //// CollectionViewSource
            //MethodInfo createCVSProp_mi = propCreatorType.GetMethod("CreateCVSProp", BindingFlags.Static | BindingFlags.NonPublic);
            //CreateCVSPropCache = new DelegateCache<CreateCVSPropDelegate>(createCVSProp_mi);

            //// CollectionView
            //MethodInfo createCVProp_mi = propCreatorType.GetMethod("CreateCVProp", BindingFlags.Static | BindingFlags.NonPublic);
            //CreateCVPropCache = new DelegateCache<CreateCVPropDelegate>(createCVProp_mi);

            #endregion

            #region DataSource Creation MethodInfo

            //MethodInfo createDSPProvider_mi = propCreatorType.GetMethod("CreateMappedDSPProvider", BindingFlags.Static | BindingFlags.NonPublic);
            //CreateDSPProviderCache = new TwoTypesDelegateCache<CreateMappedDSPProviderDelegate>(createDSPProvider_mi);

            #endregion

            #region Scalar Prop Creation MethodInfo

            // Create Prop
            MethodInfo createScalarProp_mi = propCreatorType.GetMethod("CreateProp", BindingFlags.Static | BindingFlags.NonPublic);
            //curBytes = Sizer.ReportMemConsumption(startBytes, curBytes, "After GetMethod(CreateProp)");

            CreateScalarPropCache = new DelegateCache <CreateScalarProp>(createScalarProp_mi);
            //curBytes = Sizer.ReportMemConsumption(startBytes, curBytes, "After new DelegateCache<CreatePropFromStringDelegate>");

            PropTemplateCache = new SimplePropTemplateCache();

            #endregion
        }