Beispiel #1
0
        public ObjectMapper(
            Expression <MapperFunc <TSource, TTarget> > mappingLambda,
            IObjectMappingData mappingData)
        {
            _mapperKey    = mappingData.MapperKey;
            MappingLambda = mappingLambda;
            MapperData    = mappingData.MapperData;

            if (MapperData.Context.Compile)
            {
                _mapperFunc = mappingLambda.Compile();
            }
            else if (MapperData.Context.NeedsSubMapping)
            {
                MapperData.Mapper = this;
            }

            if (MapperData.Context.NeedsSubMapping)
            {
                _subMappersByKey = MapperData.MapperContext.Cache.CreateNew <ObjectMapperKeyBase, IObjectMapper>();
            }

            if (MapperData.HasRepeatedMapperFuncs)
            {
                _repeatedMappingFuncsByKey = MapperData.MapperContext.Cache.CreateNew <ObjectMapperKeyBase, IRepeatedMapperFunc>();
                MapperData.Mapper          = this;

                CacheRepeatedMappingFuncs();
            }
        }
        public ObjectMapper(Expression mapping, IObjectMappingData mappingData)
        {
            _mapperKey = mappingData.MapperKey;
            Mapping    = mapping;
            MapperData = mappingData.MapperData;

            var mapperDataContext = MapperData.Context;

            if (mapperDataContext.Compile)
            {
                _mapperFunc = GetMappingLambda().Compile();
            }
            else if (mapperDataContext.NeedsRuntimeTypedMapping)
            {
                MapperData.Mapper = this;
            }

            if (mapperDataContext.NeedsRuntimeTypedMapping)
            {
                _subMappersByKey = Cache.CreateNew <ObjectMapperKeyBase, IObjectMapper>();
            }

            if (MapperData.HasRepeatedMapperFuncs)
            {
                _repeatedMappingFuncsByKey = Cache.CreateNew <ObjectMapperKeyBase, IRepeatedMapperFunc>();
                MapperData.Mapper          = this;

                CacheRepeatedMappingFuncs();
            }
        }
Beispiel #3
0
        public ObjectMapper(
            Expression <MapperFunc <TSource, TTarget> > mappingLambda,
            ObjectMapperData mapperData)
        {
            MappingLambda = mappingLambda;
            MapperData    = mapperData;

            if (mapperData.Context.Compile)
            {
                _mapperFunc = mappingLambda.Compile();
            }

            if (mapperData.Context.NeedsChildMapping)
            {
                _childMappersByKey = mapperData.MapperContext.Cache.CreateNew <ObjectMapperKeyBase, IObjectMapper>();
            }
            else if (mapperData.Context.NeedsElementMapping)
            {
                _elementMappersByKey = mapperData.MapperContext.Cache.CreateNew <ObjectMapperKeyBase, IObjectMapper>();
            }

            if (mapperData.HasMapperFuncs)
            {
                _recursionMappingFuncsByKey = CreateRecursionMapperFuncs();
            }
        }
        public void SetUp()
        {
            _returnedEmployee = new Employee();
            _returnedEmployeeViewModel = new EmployeeViewModel();
            _mapEmployee = emp => emp == _returnedEmployee ? _returnedEmployeeViewModel : null;

            _employeeServiceMock = new Mock<IEmployeeService>();
            _employeeServiceMock.Setup(x => x.GetEmployee(It.Is<int>(i => i == 1))).Returns(_returnedEmployee);
            _employeeServiceMock.Setup(x => x.GetEmployee(It.Is<int>(i => i != 1))).Throws<InvalidOperationException>();
        }
        private void CreateMapperFunc(IObjectMappingData mappingData, bool isLazyLoading = false)
        {
            mappingData.MapperKey.MappingData = mappingData;
            mappingData.MapperKey.MapperData  = mappingData.MapperData;

            MappingLambda = mappingData.GetOrCreateMapper().MappingLambda;

            var typedMappingLambda = (Expression <MapperFunc <TChildSource, TChildTarget> >)MappingLambda;

            _repeatedMappingFunc = typedMappingLambda.Compile();

            if (isLazyLoading)
            {
                _mapperData.GetRootMapperData().Mapper.CacheRepeatedMappingFuncs();
            }

            mappingData.MapperKey.MapperData  = null;
            mappingData.MapperKey.MappingData = null;
        }
        public RecursionMapperFunc(LambdaExpression mappingLambda)
        {
            var typedMappingLambda = (Expression <MapperFunc <TChildSource, TChildTarget> >)mappingLambda;

            _recursionMapperFunc = typedMappingLambda.Compile();
        }
 public EmployeeController(IEmployeeService employeeService, MapperFunc<Employee, EmployeeViewModel> mapEmployee)
 {
     _employeeService = employeeService;
     _mapEmployee = mapEmployee;
 }
Beispiel #8
0
 public Graph(MapperFunc func)
 {
     _func   = func;
     _points = new List <PointF>();
     Draw();
 }