Example #1
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);
     }
 }
        /// <summary>
        /// Creates a new ViewModel using the specified PropModel. The PropFactory and FullClassName values recorded in
        /// the PropModel may be overridden by the pfOverrid and fcnOverride arguments. If these values should not be
        /// overridden set the arguments to null.
        /// </summary>
        /// <param name="propModel"></param>
        /// <param name="pfOverride"></param>
        /// <param name="fcnOverride"></param>
        /// <returns></returns>
        public object GetNewViewModel(PropModelType propModel, IPropFactory pfOverride, string fcnOverride)
        {
            object result = _viewModelActivator.GetNewViewModel
                            (
                typeToCreate: propModel.TypeToWrap,
                propModel: propModel,
                viewModelFactory: this,
                ams: AutoMapperService,
                pfOverride: pfOverride,
                fcnOverride: fcnOverride
                            );

            return(result);
        }
Example #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);
            }
        }