Пример #1
0
 /// <summary>
 /// Full service, all arguments must have a non-null value.
 /// </summary>
 /// <param name="propModelCache"></param>
 /// <param name="viewModelActivator"></param>
 /// <param name="storeAccessCreator"></param>
 /// <param name="autoMapperService"></param>
 /// <param name="wrapperTypeCreator"></param>
 public SimpleViewModelFactory
 (
     PropModelCacheInterface propModelCache,
     ViewModelActivatorInterface viewModelActivator,
     PSAccessServiceCreatorInterface storeAccessCreator,
     object autoMapperService,
     ICreateWrapperTypes wrapperTypeCreator
 )
     : this(propModelCache, viewModelActivator, storeAccessCreator)
 {
     AutoMapperService   = autoMapperService; // ?? throw new ArgumentNullException(nameof(autoMapperService));
     _wrapperTypeCreator = wrapperTypeCreator ?? throw new ArgumentNullException(nameof(wrapperTypeCreator));
 }
Пример #2
0
        /// <summary>
        /// This is provided for use by clients that require no loading of PropModels by FullClassName,
        /// or will otherwise retrieve PropModels using some other mechanisim.
        /// </summary>
        /// <param name="viewModelActivator"></param>
        /// <param name="storeAccessCreator"></param>
        public SimpleViewModelFactory
        (
            ViewModelActivatorInterface viewModelActivator,
            PSAccessServiceCreatorInterface storeAccessCreator
        )
        {
            _propModelCache     = null;
            _viewModelActivator = viewModelActivator ?? throw new ArgumentNullException(nameof(viewModelActivator));
            _storeAccessCreator = storeAccessCreator ?? throw new ArgumentNullException(nameof(storeAccessCreator));

            AutoMapperService   = null;
            _wrapperTypeCreator = null;
        }
Пример #3
0
        // Regular Instantiation using the PropModel.
        //private TDestination GetNewDestination(Type destinationOrProxyType, PropModelType propModel, PSAccessServiceCreatorInterface storeAccessCreator, IProvideAutoMappers autoMapperService, ICreateWrapperTypes wrapperTypeCreator, IPropFactory propFactory, string fullClassName)

        private TDestination GetNewDestination(Type destinationOrProxyType, PropModelType propModel,
                                               ViewModelFactoryInterface viewModelFactory, IPropBagMapperService propBagMapperService,
                                               IPropFactory propFactory, string fullClassName)
        {
            ViewModelActivatorInterface vmActivator = viewModelFactory.ViewModelActivator;

            try
            {
                //var newViewModel =  _vmActivator.GetNewViewModel(destinationOrProxyType, propModel, viewModelFactory, propFactory, fullClassName);

                var newViewModel = vmActivator.GetNewViewModel(destinationOrProxyType, propModel, viewModelFactory, propBagMapperService, propFactory, fullClassName);

                return(newViewModel as TDestination);
            }
            catch (Exception e2)
            {
                //Type targetType = destinationOrProxyType ?? typeof(TDestination);
                throw new InvalidOperationException($"Cannot create an instance of {destinationOrProxyType} that takes a PropModel argument.", e2);
            }
        }
Пример #4
0
 // Emitted Types do not implement clone for the Emitted Type (Clone calls the base type.)
 // So this uses the emitted type's constructor that takes a source IPropBag.
 private TDestination GetNewDestination(Type destinationOrProxyType, IPropBag copySource, ViewModelActivatorInterface vmActivator)
 {
     try
     {
         var newViewModel = vmActivator.GetNewViewModel(destinationOrProxyType, copySource);
         return(newViewModel as TDestination);
     }
     catch (Exception e2)
     {
         throw new InvalidOperationException($"Cannot create an instance of {destinationOrProxyType} that takes a single IPropag argument.", e2);
     }
 }