public SimplePropStoreAccessServiceProvider(int maxPropsPerObject, IProvideHandlerDispatchDelegateCaches handlerDispatchDelegateCacheProvider) { MaxPropsPerObject = maxPropsPerObject; MaxObjectsPerAppDomain = GetMaxObjectsPerAppDomain(maxPropsPerObject); _handlerDispatchDelegateCacheProvider = handlerDispatchDelegateCacheProvider; _store = new Dictionary <WeakRefKey <IPropBag>, BagNode>(); _storeByType = new Dictionary <PropItemSetKeyType, PropNodelCollectionSharedInterface>(); // TODO: Have the caller provide a PropTemplateCache. _propTemplateCache = new SimplePropTemplateCache(); //_timer = new Timer(PruneStore, null, NUMBER_OF_SECONDS_BETWEEN_PRUNE_OPS * 1000, NUMBER_OF_SECONDS_BETWEEN_PRUNE_OPS * 1000); }
// 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 }