コード例 #1
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);
        }
コード例 #2
0
        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);
        }
コード例 #3
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);
        }
コード例 #4
0
        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);
        }