Ejemplo n.º 1
0
        static PropStoreServicesForThisApp()
        {
            _mct.Measure("Begin PropStoreServicesForThisApp");

            //Person p = new Person();
            //    _mct.MeasureAndReport("New Person");

            // Build the PropFactory Provider and the two Delegate Caches on which it depends.

            ITypeDescBasedTConverterCache typeDescBasedTConverterCache = new TypeDescBasedTConverterCache();

            _mct.MeasureAndReport("After new TypeDescBasedTConverterCache");

            IProvideDelegateCaches delegateCacheProvider = new SimpleDelegateCacheProvider(typeof(PropBag), typeof(APFGenericMethodTemplates));

            _mct.MeasureAndReport("After new SimpleDelegateCacheProvider");

            IConvertValues      valueConverter = new PropFactoryValueConverter(typeDescBasedTConverterCache);
            ResolveTypeDelegate typeResolver   = null;

            _propFactoryFactory = BuildThePropFactoryFactory(valueConverter, delegateCacheProvider, typeResolver);

            // Build the AppDomain-Wide Property Store and the EventHandler (Delegate) Dispatch cache on which it depends.
            HandlerDispatchDelegateCacheProvider = new SimpleHandlerDispatchDelegateCacheProvider();
            _mct.MeasureAndReport("After new SimpleHandlerDispatchDelegateCacheProvider");

            // This creates the global, shared, Property Store.
            _theStore = new SimplePropStoreProxy(MAX_NUMBER_OF_PROPERTIES, HandlerDispatchDelegateCacheProvider);

            // Get a reference to the PropStoreAccessService Factory that the PropertyStore provides.
            PSAccessServiceCreatorInterface psAccessServiceFactory = _theStore.PropStoreAccessServiceFactory;

            _vmActivator = new SimpleViewModelActivator();
            _mct.MeasureAndReport("After new SimpleViewModelActivator");


            IPropModelBuilder propModelBuilder = GetPropModelProvider(_propFactoryFactory);

            PropModelCache = new SimplePropModelCache(propModelBuilder);

            WrapperTypeCreator = BuildSimpleWrapperTypeCreator();
            _mct.MeasureAndReport("After GetSimpleWrapperTypeCreator");


            ViewModelFactory = new SimpleViewModelFactory(PropModelCache, _vmActivator, psAccessServiceFactory, null, WrapperTypeCreator);
            _mct.MeasureAndReport("After new ViewModelHelper");

            AutoMapperService = GetAutoMapperProvider(ViewModelFactory);
            _mct.MeasureAndReport("After GetAutoMapperProvider");

            ViewModelFactory.AutoMapperService = AutoMapperService;


            //_defaultPropFactory = BuildDefaultPropFactory(valueConverter, delegateCacheProvider, typeResolver);
            //_mct.MeasureAndReport("After new BuildDefaultPropFactory");
        }
Ejemplo n.º 2
0
        public Type TargetRunTimeType => DestinationType;  //=> RunTimeType;

        #endregion

        #region Constructor

        public AbstractPropBagMapper
        (
            PropModelType propModel,
            IMapper mapper,
            ViewModelFactoryInterface viewModelFactory,
            IPropBagMapperService propBagMapperService,
            IConfigureAMapper <TSource, TDestination> mappingConfiguration
        )
        {
            SourceType      = typeof(TSource);
            DestinationType = typeof(TDestination);

            PropModel = propModel;               //(PropModelType) mapRequest.DestinationTypeDef.UniqueRef;

            PropFactory = PropModel.PropFactory; // (IPropFactory)mapRequest.DestinationTypeDef.PropFactory;

            Mapper = mapper;

            _viewModelFactory     = viewModelFactory;
            _propBagMapperService = propBagMapperService;
            _mappingConfiguration = mappingConfiguration;

            SupportsMapFrom = true;

            _requiresWrappperTypeEmitServices = _mappingConfiguration.RequiresWrappperTypeEmitServices;

            CheckRequiresEmitted(_requiresWrappperTypeEmitServices, DestinationType);

            _mct.Measure();

            _destPropBagTemplate = GetDestinationTemplate(DestinationType);

            _mct.MeasureAndReport("GetNewDestination(PropModel, ... [In Constructor]", "AbstractPropBagMapper");

            // Working on see if we can get the SupportsMapFrom from the Mapper itself.
            //TypePair tp = new TypePair(SourceType, DestinationType);
            //IObjectMapper mpr = mapper.ConfigurationProvider.FindMapper(tp);

            return;
        }