public PersonVM(PropModelType pm, ViewModelFactoryInterface viewModelFactory, IPropBagMapperService autoMapperService, IPropFactory propFactory, string fullClassName) : base(pm, viewModelFactory, autoMapperService, propFactory, fullClassName) { //System.Diagnostics.Debug.WriteLine("PersonVM is being created with a PropModel."); //////IList<string> pNamesFromOurProvider = TypeInspectorUtility.GetPropertyNames ////// (_typeDescriptionProvider.GetTypeDescriptor(this)); ////ICustomTypeDescriptor ourCustomTypeDescriptor = _typeDescriptionProvider.GetTypeDescriptor(this); ////IList<string> pNamesFromOurProvider = TypeInspectorUtility.GetPropertyNames //// (ourCustomTypeDescriptor); //IList<string> pNamesFromOurPropModel = TypeInspectorUtility.GetPropertyNames // (pm.CustomTypeDescriptor); ////IList<string> pNamesFromAppDomain_WT = TypeInspectorUtility.GetPropertyNames //// (typeof(PersonVM), this); ////IList<string> pNamesFromAppDomain_WT = TypeInspectorUtility.GetPropertyNames //// (this.GetType(), this); //IList<string> pNamesFromAppDomain = TypeInspectorUtility.GetPropertyNames // (this); }
// BaseType + PropModel (BaseType known at compile time.) public object GetNewViewModel <BT>(PropModelType propModel, ViewModelFactoryInterface viewModelFactory, object propBagAutoMapperService, IPropFactory propFactory = null, string fcnOverride = null) where BT : class, IPropBag { object result = GetNewViewModel(typeof(BT), propModel, viewModelFactory, propBagAutoMapperService, propFactory, fcnOverride); return(result); }
static public PerformanceModel Create(PropBagTypeSafetyMode safetyMode, ViewModelFactoryInterface viewModelFactory) { AutoMapperHelpers ourHelper = new AutoMapperHelpers(); IPropFactory propFactory_V1 = ourHelper.GetNewPropFactory_V1(); PropModelType propModel = new PropModel ( "PerformanceModel", "PropBagLib.Tests", DeriveFromClassModeEnum.Custom, typeof(PerformanceModel), propFactory_V1, propFactoryType: null, propModelCache: null, typeSafetyMode: safetyMode, deferMethodRefResolution: true, requireExplicitInitialValue: true ); long generationId = viewModelFactory.PropModelCache.Add(propModel); PerformanceModel pmViewModel = new PerformanceModel(propModel, viewModelFactory); pmViewModel.AddPropNoStore <int>("PropIntNoStore"); pmViewModel.AddPropNoStore <string>("PropStringNoStore"); pmViewModel.AddProp <int>("PropInt"); pmViewModel.AddProp <string>("PropString"); pmViewModel.FixProps(); return(pmViewModel); }
public void Test1() { AutoMapperHelpers ourHelper = new AutoMapperHelpers(); IPropFactory propFactory_V1 = ourHelper.GetNewPropFactory_V1(); PropModel pm = new PropModel ( className: "CreateAtRunTimeModel", namespaceName: "PropBagLib.Tests", deriveFrom: DeriveFromClassModeEnum.PropBag, targetType: null, propFactory: propFactory_V1, propFactoryType: null, propModelCache: null, typeSafetyMode: PropBagTypeSafetyMode.AllPropsMustBeRegistered, deferMethodRefResolution: true, requireExplicitInitialValue: true); PropItemModel pi = new PropItemModel(typeof(string), "PropString", PropStorageStrategyEnum.Internal, propKind: PropKindEnum.Prop, initialValueField: new PropInitialValueField("Initial Value")); pm.Add(pi.PropertyName, pi); ViewModelFactoryInterface viewModelFactory = ourHelper.ViewModelFactory; viewModelFactory.PropModelCache.Add(pm); mod1 = new CreateAtRunTimeModel(pm, viewModelFactory); Assert.That(mod1, Is.Not.EqualTo(null), "Expected the CreateAtRunTimeModel to have been created."); Assert.That(mod1.PropertyExists("PropString"), Is.True, "Expected the property with name = 'PropString' to have been create."); }
private static IPropBagMapperService GetAutoMapperProvider(ViewModelFactoryInterface viewModelFactory) { IAutoMapperBuilderProvider autoMapperBuilderProvider = new SimpleAutoMapperBuilderProvider(); IAutoMapperCache rawAutoMapperCache = new SimpleAutoMapperCache(); SimpleAutoMapperService autoMapperService = new SimpleAutoMapperService ( autoMapperBuilderProvider: autoMapperBuilderProvider, autoMapperCache: rawAutoMapperCache, mapperConfigurationLookupService: null ); IMapTypeDefinitionProvider mapTypeDefinitionProvider = new SimpleMapTypeDefinitionProvider(); IPropBagMapperBuilderProvider propBagMapperBuilderProvider = new SimplePropBagMapperBuilderProvider(); ICachePropBagMappers mappersCachingService = new SimplePropBagMapperCache(viewModelFactory); IPropBagMapperService propBagMapperService = new SimplePropBagMapperService ( mapTypeDefinitionProvider: mapTypeDefinitionProvider, mapperBuilderProvider: propBagMapperBuilderProvider, mappersCachingService: mappersCachingService, autoMapperService: autoMapperService ); return(propBagMapperService); }
public DestinationModel1(PropModelType pm, ViewModelFactoryInterface viewModelFactory, IPropBagMapperService autoMapperService, IPropFactory propFactory, string fullClassName) : base(pm, viewModelFactory, autoMapperService, propFactory, fullClassName) { TryOpenPropSet(); AddProp <int>("NewAfterFixedProp", null, null, 0); TryFixPropSet(); }
public MainWindowViewModel(PropModelType pm, ViewModelFactoryInterface viewModelFactory, IPropBagMapperService autoMapperService) : base(pm, viewModelFactory, autoMapperService) { //System.Diagnostics.Debug.WriteLine("Beginning to construct MainWindowViewModel -- From PropModel."); //System.Diagnostics.Debug.WriteLine("Completed Constructing MainWindowViewModel -- From PropModel."); }
//private MainViewModel() { } // Shows that if no default constructor is available, the one that takes a single byte is use. // If it not desirable to provide a public, default, parameterless constructor, // a consructor that takes a single byte can be used instead. // NOTE: Neither of these constructors is required if an instance of this class already exists from the proerty // marked with the PropBagInstanceAttribute. // An instance of this class must be available so that we create an instance of a Action<T,T> delegate. //public MainViewModel(byte dummy) : base(dummy) {} /// <summary> /// Constructor used by View to create with properties /// </summary> /// <param name="pm"></param> public MainViewModel(PropModelType pm, ViewModelFactoryInterface viewModelFactory, IPropBagMapperService propBagMapperService, IPropFactory propFactory, string fullClassName) : base(pm, viewModelFactory, propBagMapperService, propFactory, fullClassName) { this.PropFirstDidChange = false; this.PropMyStringDidChange = false; this.PropMyPointDidChange = false; }
//public DestinationModel3(PropBagTypeSafetyMode typeSafetyMode, PSAccessServiceCreatorInterface storeAccessCreator, // string fullClassName, IPropFactory propFactory) // : base(typeSafetyMode, storeAccessCreator, propFactory, fullClassName) //{ // AddProp<Guid>("ProductId", null, null, Guid.NewGuid()); // AddProp<int>("Amount", null, null, initialValue: 0); // AddProp<double>("Size", null, null, 10.1); // AddProp<MyModel4>("Deep", null, null, null); //} public DestinationModel3(PropModelType pm, ViewModelFactoryInterface viewModelFactory, IPropBagMapperService autoMapperService, IPropFactory propFactory, string fullClassName) : base(pm, viewModelFactory, autoMapperService, propFactory, fullClassName) { //AddProp<Guid>("ProductId", null, null, Guid.NewGuid()); //AddProp<int>("Amount", null, null, initialValue: 0); //AddProp<double>("Size", null, null, 10.1); //AddProp<MyModel4>("Deep", null, null, null); }
public IPropBagMapper <TSource, TDestination> GeneratePropBagMapper ( IPropBagMapperRequestKey <TSource, TDestination> mapperRequestKey, ViewModelFactoryInterface viewModelFactory ) { var result = _propBagMapperBuilder.BuildPropBagMapper(mapperRequestKey, viewModelFactory); return(result); }
public IPropBagMapperService GetAutoMapperSetup_V1() { if (_autoMapperProvider_V1 == null) { ViewModelFactoryInterface viewModelFactory = ViewModelFactory; _autoMapperProvider_V1 = new AutoMapperHelpers().InitializeAutoMappers(viewModelFactory); ViewModelFactory.AutoMapperService = _autoMapperProvider_V1; } return(_autoMapperProvider_V1); }
public SimplePropBagMapperCache(ViewModelFactoryInterface viewModelFactory) { _viewModelFactory = viewModelFactory ?? throw new ArgumentNullException(nameof(viewModelFactory)); _requests = new LockingConcurrentDictionary <IPropBagMapperRequestKeyGen, IPropBagMapperRequestKeyGen>(RequestFactory); _propBagMappers = new LockingConcurrentDictionary <IPropBagMapperRequestKeyGen, IPropBagMapperGen>(MapperFactory); }
public void Z_BindParent() { AutoMapperHelpers ourHelper = new AutoMapperHelpers(); IPropBagMapperService autoMapperService = ourHelper.GetAutoMapperSetup_V1(); IPropFactory propFactory_V1 = ourHelper.GetNewPropFactory_V1(); ICreateWrapperTypes wrapperTypeCreator = ourHelper.GetWrapperTypeCreator_V1(); ViewModelFactoryInterface viewModelFactory = ourHelper.ViewModelFactory; //viewModelFactory.PropModelCache.Add(propModel5); _propModelCache = viewModelFactory.PropModelCache; Assert.That(ourHelper.StoreAccessCreator.AccessCounter == 0, "The Provider of PropStoreAccessServices has not had its Access Counter reset."); List <DestinationModel1> destinationList = new List <DestinationModel1>(); PropModelHelpers pmHelpers = new PropModelHelpers(); // Set up Child VM (Using Model 5) PropModelType propModel5 = pmHelpers.GetPropModelForModel5Dest(propFactory_V1, _propModelCache); DestinationModel5 testChildVM = new DestinationModel5(pm: propModel5, viewModelFactory: viewModelFactory, autoMapperService: autoMapperService, propFactory: propFactory_V1, fullClassName: "PropBagLib.Tests.PerformanceDb.DestinationModel5"); Business b = new Business(); testChildVM.SetIt(b, "Business"); testChildVM.RegisterBinding <Business>("Business", "../Business"); //List<Person> personList = b.Get().ToList(); //ObservableCollection<Person> personList2 = new ObservableCollection<Person>(personList); //testChildVM.SetIt(personList2, "PersonCollection"); // Set up MainVM (Using Model 6) PropModelType propModel6 = pmHelpers.GetPropModelForModel6Dest(propFactory_V1, _propModelCache); DestinationModel6 testMainVM = new DestinationModel6(propModel6, viewModelFactory, autoMapperService, propFactory_V1, null); Business b2 = new Business(); testMainVM.SetIt(b2, "Business"); testMainVM.SetIt <DestinationModel5>(testChildVM, "ChildVM"); testMainVM.RegisterBinding <Business>("Business", "./ChildVM/Business"); b2 = new Business(); testMainVM.SetIt(b2, "Business"); }
public void SetupAutoMapperSupport_V1() { AutoMapperHelpers ourHelper = new AutoMapperHelpers(); _propFactory_V1 = ourHelper.PropFactory_V1; _amp = ourHelper.GetAutoMapperSetup_V1(); _wrapperTypeCreator_V1 = ourHelper.GetWrapperTypeCreator_V1(); PropModelCacheInterface _propModelCache = ourHelper.GetPropModelCache_V1(); _viewModelFactory = ourHelper.ViewModelFactory; }
public object GetNewViewModel(Type typeToCreate, PropModelType propModel, ViewModelFactoryInterface viewModelFactory, object propBagAutoMapperService, IPropFactory propFactory, string fcnOverride) { object[] parameters = new object[] { propModel, viewModelFactory, propBagAutoMapperService, propFactory, fcnOverride }; //BindingFlags bFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.CreateInstance; //object result = Activator.CreateInstance(typeToCreate, bFlags, binder: null, args: parameters, culture: null); object result = Activator.CreateInstance(typeToCreate, args: parameters); return(result); }
public PersonVM(PropModelType pm, ViewModelFactoryInterface viewModelFactory, IPropBagMapperService autoMapperService, IPropFactory propFactory, string fullClassName) : base(pm, viewModelFactory, autoMapperService, propFactory, fullClassName) { //PropBagTypeDescriptionProvider<PersonVM> tdp = RegisterTypeDescriptorProvider<PersonVM>(pm); //pm.TypeDescriptionProvider = tdp; //TypeDescriptor.AddProvider(tdp, this); //List<string> pNamesFromOurProvider = tdp.GetPropertyDescriptors(this).Select(x => x.Name).ToList(); //List<string> pNamesFromOurPropModel = pm.PropertyDescriptors.Select(x => x.Name).ToList(); //List<string> pNames = TypeInspectorUtility.GetPropertyNames(this); //System.Diagnostics.Debug.WriteLine("PersonVM is being created with a PropModel."); }
private IPropBagMapperGen BuildPropBagMapperGen ( IPropBagMapperRequestKeyGen mapRequestGen, ViewModelFactoryInterface viewModelFactory ) { IPropBagMapperRequestKey <TSource, TDestination> mapRequestTyped = mapRequestGen as IPropBagMapperRequestKey <TSource, TDestination>; if (mapRequestTyped == null) { throw new InvalidOperationException($"{nameof(mapRequestGen)} does not implement the correct typed {nameof(IPropBagMapperRequestKey<TSource, TDestination>)} interface."); } return(BuildPropBagMapper(mapRequestTyped, viewModelFactory)); }
public void CanRegisterMod3ToDestinationMapper_Proxy() { IPropFactory propFactory = _propFactory_V1; ViewModelFactoryInterface viewModelFactory = _viewModelFactory; PropModel propModel = GetPropModelForModel3Dest(propFactory); Type typeToWrap = typeof(PropBag); string configPackageName = "Emit_Proxy"; //IMapperRequest mr = new MapperRequest(typeof(MyModel3), propModel, configPackageName); IPropBagMapperRequestKeyGen mapperRequest = _amp.SubmitPropBagMapperRequest(propModel, typeof(MyModel3), configPackageName); Assert.That(mapperRequest, Is.Not.Null, "mapperRequest should be non-null."); }
public PersonEditorViewModel(PropModelType pm, ViewModelFactoryInterface viewModelFactory, IPropBagMapperService autoMapperService, IPropFactory propFactory, string fullClassName) : base(pm, viewModelFactory, autoMapperService, propFactory, fullClassName) { //PropBagTypeDescriptionProvider<PersonEditorViewModel> tdp = RegisterTypeDescriptorProvider<PersonEditorViewModel>(pm); //pm.TypeDescriptionProvider = tdp; //TypeDescriptor.AddProvider(tdp, this); //List<string> pNamesFromOurProvider = tdp.GetPropertyDescriptors(this).Select(x => x.Name).ToList(); //List<string> pNamesFromOurPropModel = pm.PropertyDescriptors.Select(x => x.Name).ToList(); //List<string> pNames = TypeInspectorUtility.GetPropertyNames(this); _commands = new List <RelayCommand>(); System.Diagnostics.Debug.WriteLine("Constructing PersonEditorViewModel -- with PropModel."); }
public SimplePropBagMapper ( PropModelType propModel, IMapper mapper, ViewModelFactoryInterface viewModelFactory, IPropBagMapperService propBagMapperService, IConfigureAMapper <TSource, TDestination> mappingConfiguration ) : base ( propModel, mapper, viewModelFactory, propBagMapperService, mappingConfiguration ) { }
public PersonCollectionViewModel(PropModelType pm, ViewModelFactoryInterface viewModelFactory, IPropBagMapperService autoMapperService, IPropFactory propFactory, string fullClassName) : base(pm, viewModelFactory, autoMapperService, propFactory, fullClassName) { System.Diagnostics.Debug.WriteLine("Constructing PersonCollectionViewModel -- with PropModel."); //IList<string> pNamesFromOurProvider = TypeInspectorUtility.GetPropertyNames // (_typeDescriptionProvider.GetTypeDescriptor(this)); //IList<string> pNamesFromOurPropModel = TypeInspectorUtility.GetPropertyNames // (pm.CustomTypeDescriptor); //IList<string> pNamesFromAppDomain_WT = TypeInspectorUtility.GetPropertyNames // (typeof(PersonCollectionViewModel), this); //IList<string> pNamesFromAppDomain = TypeInspectorUtility.GetPropertyNames // (this); }
// 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); } }
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; }
protected override void Because_Of() { //mainWindowPropModel = PropModelCache.GetPropModel("MainWindowVM"); string className = "MainWindowVM"; string fcn = GetFullClassName(DefaultNamespace, className, ConfigPackageNameSuffix); if (!PropModelCache.TryGetPropModel(fcn, out mainWindowPropModel)) { throw new KeyNotFoundException($"Could not find a PropModel with Full Class Name = {fcn}."); } BaseMemTracker.CompactMeasureAndReport("After get mainWindow_PropModel.", "CreateVM_CreateMainWindowVM_Run1"); ViewModelFactoryInterface viewModelFactory = ViewModelFactory; mainWindowViewModel = new MainWindowViewModel(mainWindowPropModel, viewModelFactory, PropBagMapperService); BaseMemTracker.CompactMeasureAndReport("After create the mainWindowViewModel.", "CreateVM_CreateMainWindowVM_Run1"); mainWindowViewModel.Dispose(); BaseMemTracker.CompactMeasureAndReport("After dispose of the mainWindowViewModel.", "CreateVM_CreateMainWindowVM_Run1"); }
public MainWindowViewModel(PropModelType pm, ViewModelFactoryInterface viewModelFactory, IPropBagMapperService autoMapperService, IPropFactory propFactory, string fullClassName) : base(pm, viewModelFactory, autoMapperService, propFactory, fullClassName) { //System.Diagnostics.Debug.WriteLine("Beginning to construct MainWindowViewModel -- From PropModel."); //IHaveADbContext dBActivator = new DBActivator<PersonDB>(System.Environment.SpecialFolder.CommonApplicationData); //PersonDB personDb = (PersonDB)dBActivator.DbContext; //PersonDAL b = new PersonDAL(personDb); //SetIt(b, "Business"); //PropBagTypeDescriptionProvider<MainWindowViewModel> tdp = RegisterTypeDescriptorProvider<MainWindowViewModel>(pm); //pm.TypeDescriptionProvider = tdp; //TypeDescriptor.AddProvider(tdp, this); //List<string> pNamesFromOurProvider = tdp.GetPropertyDescriptors(this).Select(x => x.Name).ToList(); //List<string> pNamesFromOurPropModel = pm.PropertyDescriptors.Select(x => x.Name).ToList(); //List<string> pNames = TypeInspectorUtility.GetPropertyNames(this); System.Diagnostics.Debug.WriteLine("Completed Constructing MainWindowViewModel -- From PropModel."); }
// Create a new PropBagMapper public IPropBagMapper <TSource, TDestination> BuildPropBagMapper ( IPropBagMapperRequestKey <TSource, TDestination> mapperRequestKey, ViewModelFactoryInterface viewModelFactory ) { CheckTypeToCreate("source", typeof(TSource), mapperRequestKey.SourceType); CheckTypeToCreate("destination", typeof(TDestination), mapperRequestKey.DestinationType); PropModelType propModel = mapperRequestKey.PropModel; IMapper theMapper = mapperRequestKey.AutoMapper; IPropBagMapper <TSource, TDestination> result = new SimplePropBagMapper <TSource, TDestination> ( propModel, theMapper, viewModelFactory, _propBagMapperService, mapperRequestKey.MappingConfiguration ); return(result); }
public void CanGetMapperForMod3ToDestination_Proxy() { IPropFactory propFactory = _propFactory_V1; ViewModelFactoryInterface viewModelFactory = _viewModelFactory; PropModel propModel = GetPropModelForModel3Dest(propFactory); viewModelFactory.PropModelCache.Add(propModel); Type typeToWrap = typeof(PropBag); string configPackageName = "Emit_Proxy"; IMapperRequest mapperRequest = new MapperRequest(typeof(MyModel3), propModel, configPackageName); Type et = _wrapperTypeCreator_V1.GetWrapperType(propModel, typeToWrap); propModel.NewEmittedType = et; IPropBagMapperRequestKeyGen mapperKey = _amp.SubmitPropBagMapperRequest(mapperRequest.PropModel, mapperRequest.SourceType, mapperRequest.ConfigPackageName); // Get the AutoMapper mapping function associated with the mapper request already submitted. IPropBagMapperGen genMapper = _amp.GetPropBagMapper(mapperKey); //IMapper genMapper = _amp.GetRawAutoMapper(mapperKey); Assert.That(mapperKey, Is.Not.Null, "mapperRequest should be non-null."); //IPropBagMapper<MyModel3, DestinationModel3> mapper = _amp.GetMapper<MyModel3, DestinationModel3>(mapperRequest); Assert.That(genMapper, Is.Not.Null, "mapper should be non-null"); MyModel4 dp = new MyModel4 { MyString = "This is a good thing." }; MyModel3 testSource = new MyModel3 { Amount = 11, Size = 22.22, ProductId = Guid.Empty, Deep = dp }; var testDest = genMapper.MapToDestination(testSource); //IPropBagMapperKey<MyModel3, DestinationModel3> mapperRequest2 = // _amp.SubmitMapperRequest<MyModel3, DestinationModel3> // ( // propModel: propModel, // typeToWrap: typeToWrap, // configPackageName: configPackageName // ); //IPropBagMapper<MyModel3, DestinationModel3> mapper2 = _amp.GetMapper<MyModel3, DestinationModel3>(mapperRequest2); IPropBagMapperRequestKeyGen mapperKey2 = _amp.SubmitPropBagMapperRequest(mapperRequest.PropModel, mapperRequest.SourceType, mapperRequest.ConfigPackageName); // Get the AutoMapper mapping function associated with the mapper request already submitted. IPropBagMapperGen genMapper2 = _amp.GetPropBagMapper(mapperKey2); var testDest2 = genMapper2.MapToDestination(testSource); }
public void CanGetMapperForMod3ToDestination_Extra() { IPropFactory propFactory = _propFactory_V1; ViewModelFactoryInterface viewModelFactory = _viewModelFactory; PropModel propModel = GetPropModelForModel3Dest(propFactory); viewModelFactory.PropModelCache.Add(propModel); Type typeToWrap = typeof(DestinationModel3); // typeof(PropBag); string configPackageName = "Extra_Members"; // "Emit_Proxy"; IMapperRequest mr = new MapperRequest(typeof(MyModel3), propModel, configPackageName); //IMapper rawAutoMapper = AutoMapperHelpers.GetAutoMapper<MyModel3, DestinationModel3> // ( // mr, // _amp, // out IPropBagMapperKey<MyModel3, DestinationModel3> propBagMapperKey // ); //IPropBagMapper<MyModel3, DestinationModel3> cookedAutoMapper = new SimplePropBagMapper<MyModel3, DestinationModel3> // ( // propBagMapperKey, // rawAutoMapper, // viewModelFactory, // _amp // ); IPropBagMapper <MyModel3, DestinationModel3> propBagMapper = AutoMapperHelpers.GetAutoMapper <MyModel3, DestinationModel3> ( mr, _amp, out IPropBagMapperRequestKey <MyModel3, DestinationModel3> propBagMapperKey ); //IPropBagMapperKey<MyModel3, DestinationModel3> mapperRequest = // _amp.SubmitMapperRequest<MyModel3, DestinationModel3> // ( // propModel: propModel, // viewModelFactory: viewModelFactory, // typeToWrap: typeToWrap, // configPackageName: configPackageName // ); Assert.That(propBagMapperKey, Is.Not.Null, "mapperRequest should be non-null."); //IPropBagMapper<MyModel3, DestinationModel3> mapper = _amp.GetMapper<MyModel3, DestinationModel3>(mapperRequest); Assert.That(propBagMapper, Is.Not.Null, "mapper should be non-null"); MyModel4 dp = new MyModel4 { MyString = "This is a good thing." }; MyModel3 testSource = new MyModel3 { Amount = 11, Size = 22.22, ProductId = Guid.Empty, Deep = dp }; DestinationModel3 testDest = propBagMapper.MapToDestination(testSource); //IPropBagMapperKey<MyModel3, DestinationModel3> mapperRequest2 = // _amp.SubmitMapperRequest<MyModel3, DestinationModel3> // ( // propModel: propModel, // viewModelFactory: viewModelFactory, // typeToWrap: typeToWrap, // configPackageName: configPackageName // ); //IPropBagMapper<MyModel3, DestinationModel3> mapper2 = _amp.GetMapper<MyModel3, DestinationModel3>(mapperRequest2); IPropBagMapper <MyModel3, DestinationModel3> propBagMapper2 = AutoMapperHelpers.GetAutoMapper <MyModel3, DestinationModel3> ( mr, _amp, out IPropBagMapperRequestKey <MyModel3, DestinationModel3> propBagMapperKey2 ); //IPropBagMapper<MyModel3, DestinationModel3> cookedAutoMapper2 = new SimplePropBagMapper<MyModel3, DestinationModel3> // ( // propBagMapperKey, // rawAutoMapper, // viewModelFactory, // _amp // ); DestinationModel3 testDest2 = propBagMapper2.MapToDestination(testSource); }
//public CreateAtRunTimeModel(PropBagTypeSafetyMode typeSafetyMode, PSAccessServiceCreatorInterface storeAccessCreator, // IPropFactory propFactory, string fullClassName) // : base(typeSafetyMode, storeAccessCreator, propFactory, fullClassName) //{ //} public CreateAtRunTimeModel(PropModel pm, ViewModelFactoryInterface viewModelFactory) : base(pm, viewModelFactory, null, propFactory: null, fullClassName: "PropBagLib.Tests.CreateAtRunTimeModel") { }
public PubPropBag(PropModel pm, ViewModelFactoryInterface viewModelFactory, IPropBagMapperService propBagMapperService, IPropFactory propFactory, string fullClassName) : base(pm, viewModelFactory, propBagMapperService, propFactory, fullClassName) { }