Beispiel #1
0
        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);
        }
Beispiel #2
0
        //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;
        }
Beispiel #3
0
 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();
 }
Beispiel #4
0
        //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);
        }
Beispiel #5
0
 public IPropBagMapperService GetAutoMapperSetup_V1()
 {
     if (_autoMapperProvider_V1 == null)
     {
         ViewModelFactoryInterface viewModelFactory = ViewModelFactory;
         _autoMapperProvider_V1             = new AutoMapperHelpers().InitializeAutoMappers(viewModelFactory);
         ViewModelFactory.AutoMapperService = _autoMapperProvider_V1;
     }
     return(_autoMapperProvider_V1);
 }
Beispiel #6
0
        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;
        }
Beispiel #7
0
        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 IPropBagMapperBuilder <TSource, TDestination> GetPropBagMapperBuilder <TSource, TDestination>
        (
            IPropBagMapperService propBagMapperService
        )
            where TDestination : class, IPropBag
        {
            IPropBagMapperBuilder <TSource, TDestination> result
                = new SimplePropBagMapperBuilder <TSource, TDestination>
                  (
                      propBagMapperService: propBagMapperService
                  );

            return(result);
        }
Beispiel #9
0
        //public static IMapper GetAutoMapper<TSource, TDestination>
        //    (
        //    IMapperRequest mapperRequest,
        //    //ViewModelFactoryInterface viewModelFactory,
        //    IPropBagMapperService propBagMapperService,
        //    out IAutoMapperRequestKey<TSource, TDestination> rawAutoMapperRequest
        //    )
        //    where TDestination : class, IPropBag
        //{
        //    // This is where the PropModel is used to define the Mapper

        //    // TODO: See if we can submit the request earlier; perhaps when the mapper request is created.

        //    Type typeToWrap = mapperRequest.PropModel.TypeToWrap;

        //    // Submit the Mapper Request.
        //    rawAutoMapperRequest = propBagMapperService.SubmitRawAutoMapperRequest<TSource, TDestination>
        //        (mapperRequest.PropModel/*, viewModelFactory*/, typeToWrap, mapperRequest.ConfigPackageName);

        //    // Get the AutoMapper mapping function associated with the mapper request just submitted.
        //    //IPropBagMapperGen genMapper = _propBagMapperService.GetMapper(mapperKey);

        //    IMapper rawAutoMapper = propBagMapperService.GetRawAutoMapper(rawAutoMapperRequest);
        //    return rawAutoMapper;
        //}

        public static IPropBagMapperGen GetAutoMapper
        (
            IMapperRequest mapperRequest,
            IPropBagMapperService propBagMapperService,
            out IPropBagMapperRequestKeyGen propBagMapperRequestKeyGen
        )
        {
            // Submit the Mapper Request. TODO: See if we can submit the request earlier; perhaps when the mapper request is created.
            propBagMapperRequestKeyGen = propBagMapperService.SubmitPropBagMapperRequest(mapperRequest.PropModel, mapperRequest.SourceType, mapperRequest.ConfigPackageName);

            // Get the AutoMapper mapping function associated with the mapper request just submitted.
            IPropBagMapperGen mapperGen = propBagMapperService.GetPropBagMapper(propBagMapperRequestKeyGen);

            return(mapperGen);
        }
Beispiel #10
0
        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.");
        }
Beispiel #11
0
        public void CanMapObservableCollection_AProxy()
        {
            _ourHelper      = new AutoMapperHelpers();
            _propFactory_V1 = _ourHelper.GetNewPropFactory_V1();
            _amp            = _ourHelper.GetAutoMapperSetup_V1();
            _propModelCache = _ourHelper.GetPropModelCache_V1();

            _pmHelpers = new PropModelHelpers();

            string configPackageName = "Emit_Proxy";

            ObservableCollTestObject oTester = new ObservableCollTestObject();

            oTester.CanMapObservableCollection(configPackageName, _ourHelper, _propFactory_V1, _propModelCache, _amp, _pmHelpers, NUMBER_OF_PEOPLE);
            //oTester.DoCleanup();
        }
Beispiel #12
0
 public SimplePropBagMapper
 (
     PropModelType propModel,
     IMapper mapper,
     ViewModelFactoryInterface viewModelFactory,
     IPropBagMapperService propBagMapperService,
     IConfigureAMapper <TSource, TDestination> mappingConfiguration
 )
     : base
     (
         propModel,
         mapper,
         viewModelFactory,
         propBagMapperService,
         mappingConfiguration
     )
 {
 }
        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.");
        }
Beispiel #14
0
        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);
        }
            // The Typed Method for PropBagMappers
            static IPropBagMapperRequestKey <TSource, TDestination> SubmitPropBagMapperRequest <TSource, TDestination>
            (
                PropModelType propModel,
                string configPackageName,
                IPropBagMapperService propBagMapperService
            )
                where TDestination : class, IPropBag
            {
                IPropBagMapperRequestKey <TSource, TDestination> result
                    = propBagMapperService.SubmitPropBagMapperRequest <TSource, TDestination>
                      (
                          propModel: propModel,
                          configPackageName: configPackageName,
                          configStarterForThisRequest: null,
                          propFactory: null
                      );

                return(result);
            }
        public static IPropBagMapper <TSource, TDestination> GetAutoMapper <TSource, TDestination>
        (
            IMapperRequest mapperRequest,
            IPropBagMapperService propBagMapperService,
            out IPropBagMapperRequestKey <TSource, TDestination> propBagMapperRequestKey
        )
            where TDestination : class, IPropBag
        {
            // TODO: See if we can submit the request earlier; perhaps when the mapper request is created.
            //Type typeToWrap = mapperRequest.PropModel.TypeToWrap;

            // Submit the Mapper Request.
            propBagMapperRequestKey = propBagMapperService.SubmitPropBagMapperRequest <TSource, TDestination>
                                          (mapperRequest.PropModel, mapperRequest.ConfigPackageName);

            // Get the AutoMapper mapping function associated with the mapper request just submitted.
            IPropBagMapper <TSource, TDestination> propBagMapper = propBagMapperService.GetPropBagMapper <TSource, TDestination>(propBagMapperRequestKey);

            return(propBagMapper);
        }
Beispiel #17
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;
        }
Beispiel #18
0
        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.");
        }
Beispiel #19
0
        public static IPropBagMapper <TSource, TDestination> GetAutoMapper <TSource, TDestination>
        (
            IMapperRequest mapperRequest,
            IPropBagMapperService propBagMapperService,
            out IPropBagMapperRequestKey <TSource, TDestination> propBagMapperRequestKey
        )
            where TDestination : class, IPropBag
        {
            // This is where the PropModel is used to define the Mapper

            // TODO: See if we can submit the request earlier; perhaps when the mapper request is created.

            //Type typeToWrap = null; // This should only be used if we are overridding the TypeToWrap value stored in the PropModel.

            // Submit the Mapper Request.
            propBagMapperRequestKey = propBagMapperService.SubmitPropBagMapperRequest <TSource, TDestination>
                                          (mapperRequest.PropModel /*, typeToWrap*/, mapperRequest.ConfigPackageName);

            // Get the AutoMapper mapping function associated with the mapper request just submitted.
            IPropBagMapper <TSource, TDestination> result = propBagMapperService.GetPropBagMapper <TSource, TDestination>(propBagMapperRequestKey);

            return(result);
        }
Beispiel #20
0
        public void MapOcAndCleanUp()
        {
            GC.WaitForPendingFinalizers();
            GC.WaitForFullGCComplete();

            _ourHelper = new AutoMapperHelpers();
            ICreateWrapperTypes wrapperTypeCreator = _ourHelper.GetWrapperTypeCreator_V1();

            _propFactory_V1 = _ourHelper.GetNewPropFactory_V1();
            _propModelCache = _ourHelper.GetPropModelCache_V1();

            _amp = _ourHelper.GetAutoMapperSetup_V1();

            _pmHelpers = new PropModelHelpers();

            string configPackageName = "Extra_Members";

            ObservableCollTestObject oTester = new ObservableCollTestObject();

            oTester.CanMapObservableCollection(configPackageName, _ourHelper, _propFactory_V1, _propModelCache, _amp, _pmHelpers, NUMBER_OF_PEOPLE);

            oTester.DoCleanup();
            oTester = null;

            //Thread.Sleep(new TimeSpan(0, 0, 1));

            //for (int tp = 0; tp < 5; tp++)
            //{
            //    // Yield for 1 seconds.
            //    Thread.Sleep(new TimeSpan(0, 0, 1));
            //    GC.WaitForPendingFinalizers();
            //    GC.WaitForFullGCComplete();
            //}

            GC.WaitForPendingFinalizers();
            GC.WaitForFullGCComplete();
        }
        public void CanMapObservableCollection(
            string configPackageName,
            AutoMapperHelpers ourHelper,
            IPropFactory propFactory_V1,
            PropModelCacheInterface propModelCache,
            IPropBagMapperService amp,
            PropModelHelpers pmHelpers,
            int numberOfItemsToLoad
            )
        {
            ourHelper.StoreAccessCreator.ResetAccessCounter();

            Assert.That(ourHelper.StoreAccessCreator.AccessCounter == 0, "The Provider of PropStoreAccessServices did not have its Access Counter reset.");

            // Setup Mapping between Model1 and Person
            PropModelType propModel1 = pmHelpers.GetPropModelForModel1Dest(propFactory_V1, propModelCache);

            ViewModelActivatorInterface viewModelActivator = new SimpleViewModelActivator();
            IPropBagMapperService       autoMapperService  = ourHelper.GetAutoMapperSetup_V1();
            ICreateWrapperTypes         wrapperTypeCreator = ourHelper.GetWrapperTypeCreator_V1();

            ViewModelFactoryInterface viewModelFactory = new SimpleViewModelFactory(propModelCache, viewModelActivator, ourHelper.StoreAccessCreator, amp, wrapperTypeCreator);

            // TODO: Move this to a separate test.
            #region Clone Tests

            // Make sure we can activate (or clone as appropriate) the destination type.
            DestinationModel1 test = new DestinationModel1(PropBagTypeSafetyMode.AllPropsMustBeRegistered, ourHelper.StoreAccessCreator, ourHelper.PropFactory_V1, "Test");
            if (configPackageName == "Emit_Proxy")
            {
                DestinationModel1 testCopy = new DestinationModel1(test);
            }
            else
            {
                DestinationModel1 testCopy = (DestinationModel1)test.Clone();
            }

            DestinationModel1 test2 = new DestinationModel1(propModel1, viewModelFactory, amp, ourHelper.PropFactory_V1, null);

            if (configPackageName == "Emit_Proxy")
            {
                DestinationModel1 test2Copy = new DestinationModel1(test2);
            }
            else
            {
                DestinationModel1 test2Copy = (DestinationModel1)test2.Clone();
            }

            #endregion

            Type typeToWrap = typeof(PropBag);

            IMapperRequest localMr = new MapperRequest(typeof(Person), propModel1, configPackageName);

            IPropBagMapper <Person, DestinationModel1>           propBagMapper           = null;
            IPropBagMapperRequestKey <Person, DestinationModel1> propBagMapperRequestKey = null;

            IPropBagMapperGen           propBagMapperGen           = null;
            IPropBagMapperRequestKeyGen propBagMapperRequestKeyGen = null;

            if (configPackageName == "Emit_Proxy")
            {
                wrapperTypeCreator = ourHelper.GetWrapperTypeCreator_V1();
                Type et = wrapperTypeCreator.GetWrapperType(propModel1, typeToWrap);
                propModel1.NewEmittedType = et;

                propBagMapperGen = AutoMapperHelpers.GetAutoMapper
                                   (
                    localMr,
                    amp,
                    out propBagMapperRequestKeyGen
                                   );
                Assert.That(propBagMapperRequestKeyGen, Is.Not.Null, "mapperRequest should be non-null.");
                Assert.That(propBagMapperGen, Is.Not.Null, "mapper should be non-null");
            }
            else
            {
                propBagMapper = AutoMapperHelpers.GetAutoMapper <Person, DestinationModel1>
                                (
                    localMr,
                    autoMapperService,
                    out propBagMapperRequestKey
                                );
                Assert.That(propBagMapperRequestKey, Is.Not.Null, "mapperRequest should be non-null.");
                Assert.That(propBagMapper, Is.Not.Null, "mapper should be non-null");
            }

            PropModelType propModel5 = pmHelpers.GetPropModelForModel5Dest(propFactory_V1, propModelCache);

            string fullClassName = null; // Don't override the value from the PropModel.
            _testMainVM = new DestinationModel5(propModel5, viewModelFactory, amp, ourHelper.PropFactory_V1, fullClassName);

            Business b = new Business();
            _testMainVM.SetIt(b, "Business"); // THIS IS A SET ACESSS OPERATION.

            b = _testMainVM.GetIt <Business>("Business");

            // TODO: try using IEnumerable<Person> instead.
            List <Person> unMappedPeople = b.Get(1000);

            //IEnumerable<DestinationModel1> mappedPeople;
            IEnumerable <object> mappedPeople;

            if (configPackageName == "Emit_Proxy")
            {
                mappedPeople = propBagMapperGen.MapToDestination(unMappedPeople);
            }
            else
            {
                mappedPeople = propBagMapper.MapToDestination(unMappedPeople);
            }

            _readyForTheView = new ObservableCollection <object>(mappedPeople);

            // Each time a item is mapped, it is first created. (5 sets during consruction, and another 5 for the actual mapping.)
            int totalNumberOfGets = ourHelper.StoreAccessCreator.AccessCounter;

            if (configPackageName == "Extra_Members")
            {
                Assert.That(totalNumberOfGets == 1, $"Total # of SetIt access operations is wrong: it should be {1}, but instead it is {totalNumberOfGets}.");
            }
            else
            {
                Assert.That(totalNumberOfGets == 1 + (numberOfItemsToLoad * 5), $"Total # of SetIt access operations is wrong: it should be {1 + numberOfItemsToLoad * 5}, but instead it is {totalNumberOfGets}.");
            }

            int currentNumRootPropBags   = ourHelper.StoreAccessCreator.NumberOfRootPropBagsInPlay;
            int totalRootPropBagsCreated = ourHelper.StoreAccessCreator.TotalNumberOfAccessServicesCreated;

            PropBag sampleItem = (PropBag)_readyForTheView[0];

            int howManyDoSetDelegatesGotCreated = sampleItem.NumOfDoSetDelegatesInCache;
            int howManyCreateFromString         = sampleItem.CreatePropFromStringCacheCount;
            //int howManyCreateWithNoVal = sampleItem.CreatePropWithNoValCacheCount;

            //Thread.Sleep(new TimeSpan(0, 0, 1));
        }
Beispiel #22
0
        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.");
        }
Beispiel #23
0
 public PersonEditorViewModel(PropModelType pm, ViewModelFactoryInterface viewModelFactory,
                              IPropBagMapperService autoMapperService, IPropFactory propFactory, string fullClassName)
     : base(pm, viewModelFactory, autoMapperService, propFactory, fullClassName)
 {
     System.Diagnostics.Debug.WriteLine("Constructing PersonEditorViewModel -- with PropModel.");
 }
Beispiel #24
0
 public PubPropBag(PropModel pm, ViewModelFactoryInterface viewModelFactory, IPropBagMapperService propBagMapperService, IPropFactory propFactory, string fullClassName)
     : base(pm, viewModelFactory, propBagMapperService, propFactory, fullClassName)
 {
 }
Beispiel #25
0
 public PubPropBag(PropModel pm, ViewModelFactoryInterface viewModelFactory, IPropBagMapperService propBagMapperService, string fullClassName)
     : this(pm, viewModelFactory, propBagMapperService, propFactory : null, fullClassName : fullClassName)
 {
 }
Beispiel #26
0
 public PubPropBag(PropModel pm, ViewModelFactoryInterface viewModelFactory, IPropBagMapperService propBagMapperService, IPropFactory propFactory)
     : this(pm, viewModelFactory, propBagMapperService, propFactory, fullClassName : null)
 {
 }
Beispiel #27
0
        //public DestinationModel6(PropBagTypeSafetyMode typeSafetyMode, IPropFactory propFactory, string fullClassName)
        //    : base(typeSafetyMode, propFactory, fullClassName)
        //{
        //    AddProp<Guid>("ProductId", null, false, null, null, Guid.NewGuid());
        //}

        public DestinationModel6(PropModelType pm, ViewModelFactoryInterface viewModelFactory,
                                 IPropBagMapperService autoMapperService, IPropFactory propFactory, string fullClassName)
            : base(pm, viewModelFactory, autoMapperService, propFactory, fullClassName)
        {
        }
Beispiel #28
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);
            }
        }
 public SimplePropBagMapperBuilder(IPropBagMapperService propBagMapperService)
 {
     _propBagMapperService = propBagMapperService;
 }