예제 #1
0
        private static void OpenWeatherMapMapping(MapperConfigurationExpression config)
        {
            config.CreateMap <Infrastructure.Integrations.DTOs.Response.OpenWeatherMap.HourlyDetailResponse, HourlyDetailWeatherBE>()
            .ForMember(d => d.PrecipType,
                       opt => opt.MapFrom(
                           s =>
                           s.Weather.Any(x =>
                                         Enumerable.Range(500, 31).Contains(x.Id)) //500 to 531 - rain codes from api
                                ? PrecipType.Rain
                                : PrecipType.NoPrecipitation)
                       )
            .ForMember(d => d.Temperature,
                       o => o.MapFrom(s => s.MainInfoResponse.Temp))
            .ForMember(d => d.Pressure,
                       o => o.MapFrom(s => s.MainInfoResponse.Pressure));

            config.CreateMap <OpenWeatherResponseModel, List <DailyWeatherBE> >()
            .ConstructUsing(OpenWeatherResponseModelToListWeatherDTO);

            config.CreateMap <WeatherParamsData, OpenWeatherRequestModel>()
            .ForMember(d => d.Units,
                       opt => opt.ResolveUsing(OpenWeatherMapUnitsTypeConverter))
            .ForMember(d => d.Lang,
                       opt => opt.ResolveUsing(OpenWeatherMapLangTypeConverter));
        }
예제 #2
0
        private static void InitDarkSkyMapping(MapperConfigurationExpression config)
        {
            config.CreateMap <DailyDetailResponse, DailyWeatherBE>()
            .ForMember(d => d.ProviderType,
                       o => o.MapFrom(s => WeatherProviderType.DarkSky))
            .ForMember(d => d.PrecipType,
                       opt => opt.MapFrom(s => s.PrecipType == null
                        ? PrecipType.NoPrecipitation
                        : Enum.Parse(typeof(PrecipType), s.PrecipType, true)));

            config.CreateMap <Infrastructure.Integrations.DTOs.Response.DarkSky.HourlyDetailResponse, HourlyDetailWeatherBE>()
            .ForMember(d => d.PrecipType,
                       opt => opt.MapFrom(s => s.PrecipType == null
                        ? PrecipType.NoPrecipitation
                        : Enum.Parse(typeof(PrecipType), s.PrecipType, true)));

            config.CreateMap <DarkSkyResponseModel, List <DailyWeatherBE> >()
            .ConstructUsing(DarkSkyResponseModelToListWeatherDTO);

            config.CreateMap <WeatherParamsData, DarkSkyRequestModel>()
            .ForMember(d => d.Units,
                       opt => opt.ResolveUsing(DarkSkyUnitsTypeConverter))
            .ForMember(d => d.Lang,
                       opt => opt.ResolveUsing(DarkSkyLangTypeConverter));
        }
        public static void ConfigureMap(MapperConfigurationExpression cfg)
        {
            cfg.CreateMap <TaxExemption, TaxExemptionViewModel>();

            cfg.CreateMap <TaxExemptionViewModel, TaxExemption>()
            .ForMember(t => t.Rationalities, t => t.Ignore());
        }
예제 #4
0
        public static void ConfigureMap(MapperConfigurationExpression cfg)
        {
            cfg.CreateMap <Models.Registers.Register10Data, Register10DataViewModel>()
            .ForMember(d => d.Id, o => o.MapFrom(s => s.Id))
            .ForMember(d => d.Register10Id, o => o.MapFrom(s => s.Register10Id))
            .ForMember(d => d.AssetType, o => o.MapFrom(s => s.AssetType))
            .ForMember(d => d.CauseDisposal, o => o.MapFrom(s => s.CauseDisposal))
            .ForMember(d => d.Num1, o => o.MapFrom(s => s.Num1))
            .ForMember(d => d.Num2, o => o.MapFrom(s => s.Num2))
            .ForMember(d => d.Num3, o => o.MapFrom(s => s.Num3))
            .ForMember(d => d.Num4, o => o.MapFrom(s => s.Num4))
            .ForMember(d => d.SectionId, o => o.MapFrom(s => s.SectionId))
            .ForAllOtherMembers(x => x.Ignore());

            cfg.CreateMap <Register10DataViewModel, Models.Registers.Register10Data>()
            .ForMember(d => d.Id, o => o.MapFrom(s => s.Id))
            .ForMember(d => d.Register10Id, o => o.MapFrom(s => s.Register10Id))
            .ForMember(d => d.AssetType, o => o.MapFrom(s => s.AssetType))
            .ForMember(d => d.CauseDisposal, o => o.MapFrom(s => s.CauseDisposal))
            .ForMember(d => d.Num1, o => o.MapFrom(s => s.Num1))
            .ForMember(d => d.Num2, o => o.MapFrom(s => s.Num2))
            .ForMember(d => d.Num3, o => o.MapFrom(s => s.Num3))
            .ForMember(d => d.Num4, o => o.MapFrom(s => s.Num4))
            .ForMember(d => d.SectionId, o => o.MapFrom(s => s.SectionId))
            .ForAllOtherMembers(x => x.Ignore());
        }
예제 #5
0
        /// <summary>
        /// 根据Map方向,完成类型间的Map
        /// </summary>
        /// <typeparam name="TAttribute"></typeparam>
        /// <param name="type"></param>
        /// <param name="cfg"></param>
        public static void CreateMap <TAttribute>(Type type, MapperConfigurationExpression cfg) where TAttribute : AutoMapAttribute
        {
            if (!type.IsDefined(typeof(TAttribute)))
            {
                return;
            }
            foreach (var autoMapToAttribute in type.GetCustomAttributes <TAttribute>())
            {
                if (autoMapToAttribute.TargetTypes == null || autoMapToAttribute.TargetTypes.Count() <= 0)
                {
                    continue;
                }
                foreach (var targetType in autoMapToAttribute.TargetTypes)
                {
                    if (autoMapToAttribute.Direction.HasFlag(AutoMapDirection.To))
                    {
                        cfg.CreateMap(type, targetType);
                    }

                    if (autoMapToAttribute.Direction.HasFlag(AutoMapDirection.From))
                    {
                        cfg.CreateMap(targetType, type);
                    }
                }
            }
        }
예제 #6
0
        private IMapper RegisterTypesInAutomapper()
        {
            _mapperConfigurationExpression = new MapperConfigurationExpression();
            _mapperConfigurationExpression.ConstructServicesUsing(_serviceProvider.GetService);

            foreach (var profile in AssemblyHelper.GetAllTypes <Profile>())
            {
                _mapperConfigurationExpression.AddProfile(profile);
            }

            _mapperConfigurationExpression.ShouldMapProperty = propInfo => (propInfo.CanWrite && propInfo.GetGetMethod(true).IsPublic) || propInfo.IsDefined(typeof(MapAttribute), false);

            foreach (var actorType in _dynamicTypes.Values)
            {
                if (typeof(Adapter).IsAssignableFrom(actorType))
                {
                    _mapperConfigurationExpression.CreateMap(typeof(AdapterDTO), actorType).ConstructUsingServiceLocator();
                }
                else if (typeof(Service).IsAssignableFrom(actorType))
                {
                    _mapperConfigurationExpression.CreateMap(typeof(ServiceDTO), actorType).ConstructUsingServiceLocator();
                }
            }

            var mapper = new Mapper(new MapperConfiguration(_mapperConfigurationExpression), t => _serviceProvider.GetService(t));

            return(mapper);
        }
 public static void ConfigureMap(MapperConfigurationExpression cfg)
 {
     cfg.CreateMap <Models.User, UserViewModel>();
     cfg.CreateMap <UserViewModel, Models.User>()
     .ForMember(x => x.Projects, y => y.Ignore())
     .ForMember(x => x.Role, y => y.Ignore());
 }
예제 #8
0
        public static void LoadConfig(ref MapperConfigurationExpression config)
        {
            BLL.Mapping.MapperConfig.LoadConfig(ref config);

            config.CreateMap <AuthUser, RegisterViewModel>();
            config.CreateMap <RegisterViewModel, AuthUser>();
        }
예제 #9
0
 public BaseDALMapper()
 {
     MapperConfigurationExpression = new MapperConfigurationExpression();
     MapperConfigurationExpression.CreateMap <TLeftObject, TRightObject>();
     MapperConfigurationExpression.CreateMap <TRightObject, TLeftObject>();
     Mapper = new Mapper(new MapperConfiguration(MapperConfigurationExpression));
 }
예제 #10
0
        public static void ConfigureMap(MapperConfigurationExpression cfg)
        {
            cfg.CreateMap <Models.Registers.Register9Data, Register9DataViewModel>()
            .ForMember(d => d.Id, o => o.MapFrom(s => s.Id))
            .ForMember(d => d.Register9Id, o => o.MapFrom(s => s.Register9Id))
            .ForMember(d => d.StockholderName, o => o.MapFrom(s => s.StockholderName))
            .ForMember(d => d.LastYearDividendPaymentYear, o => o.MapFrom(s => s.LastYearDividendPaymentYear))
            .ForMember(d => d.LastYearDividendPaymentData, o => o.MapFrom(s => s.LastYearDividendPaymentData))
            .ForMember(d => d.LastYearDividendSum, o => o.MapFrom(s => s.LastYearDividendSum))
            .ForMember(d => d.CurrentYearTransitionalDividendPaymentData, o => o.MapFrom(s => s.CurrentYearTransitionalDividendPaymentData))
            .ForMember(d => d.CurrentYearTransitionalDividendSum, o => o.MapFrom(s => s.CurrentYearTransitionalDividendSum))
            .ForMember(d => d.CurrentYearDividendPaymentData, o => o.MapFrom(s => s.CurrentYearDividendPaymentData))
            .ForMember(d => d.CurrentYearDividendSum, o => o.MapFrom(s => s.CurrentYearDividendSum))
            .ForMember(d => d.CountryCodeId, o => o.MapFrom(s => s.CountryCodeId))
            .ForAllOtherMembers(x => x.Ignore());

            cfg.CreateMap <Register9DataViewModel, Models.Registers.Register9Data>()
            .ForMember(d => d.Id, o => o.MapFrom(s => s.Id))
            .ForMember(d => d.Register9Id, o => o.MapFrom(s => s.Register9Id))
            .ForMember(d => d.StockholderName, o => o.MapFrom(s => s.StockholderName))
            .ForMember(d => d.LastYearDividendPaymentYear, o => o.MapFrom(s => s.LastYearDividendPaymentYear))
            .ForMember(d => d.LastYearDividendPaymentData, o => o.MapFrom(s => s.LastYearDividendPaymentData))
            .ForMember(d => d.LastYearDividendSum, o => o.MapFrom(s => s.LastYearDividendSum))
            .ForMember(d => d.CurrentYearTransitionalDividendPaymentData, o => o.MapFrom(s => s.CurrentYearTransitionalDividendPaymentData))
            .ForMember(d => d.CurrentYearTransitionalDividendSum, o => o.MapFrom(s => s.CurrentYearTransitionalDividendSum))
            .ForMember(d => d.CurrentYearDividendPaymentData, o => o.MapFrom(s => s.CurrentYearDividendPaymentData))
            .ForMember(d => d.CurrentYearDividendSum, o => o.MapFrom(s => s.CurrentYearDividendSum))
            .ForMember(d => d.CountryCodeId, o => o.MapFrom(s => s.CountryCodeId))
            .ForAllOtherMembers(x => x.Ignore());
        }
 public static void ConfigureMap(MapperConfigurationExpression cfg)
 {
     cfg.CreateMap <DomesticCompany, DomesticCompanyViewModel>()
     .ForMember(x => x.ProjectCompany, y => y.Ignore());
     cfg.CreateMap <DomesticCompanyViewModel, DomesticCompany>()
     .ForMember(x => x.ProjectCompany, y => y.Ignore());
 }
예제 #12
0
        public static void RegisterAllMaps()
        {
            //Mapper.CreateMap<Member, WelcomeViewModel>();

            //在目标类型我们有个属性ProfilePictureUrl,它有其他的含义(非字面意思或预留字段), 我们不想进行转换
            //Mapper.CreateMap<Member, ProfileViewModel>().ForMember(dest => dest.ProfilePictureUrl, src => src.Ignore());

            //Name属性在Source中不存在,如果现在创建映射规则,在映射的时候必然会抛出异常。这个时候我们就需要使用自定义解析器来完成映射。
            //Mapper.CreateMap<Member, MembersViewModel>().ForMember(dest => dest.Name, src => src.ResolveUsing(m => string.Format("{0} {1}", m.FirstName, m.LastName)));


            // 但由于AutoMaper Mapper.CreateMap<Source,Dest>()方法已启用,所以在最新版本的AutoMaper中就不可以使用该方法,解决方法如下:
            // 将以前使用的Mapper.CreateMap<Source,Dest>()方法改为Mapper.Initialize(x=>x.CreateMap<Source,Dest>());即可。


            //Mapper.Initialize(x => x.CreateMap<User, UserDto>());
            //Mapper.Initialize(x => x.CreateMap<Naire, NaireDto>().ForMember(dest => dest.AnswerCount, src => src.ResolveUsing(m => 0)));
            // Mapper.Initialize()只能用1次,第2次会覆盖第1次的配置,改为下面的写法就能解决问题:

            var cfg = new MapperConfigurationExpression();

            cfg.CreateMap <UserInfo, UserDto>();
            cfg.CreateMap <Interview, InterviewOutputDto>();
            //cfg.CreateMap<User, UserSession>();
            //cfg.CreateMap<Naire, NaireDto>().ForMember(dest => dest.AnswerCount, src => src.ResolveUsing(m => 0)).ForMember(dest => dest.AnswerScore, src => src.ResolveUsing(m => 0));
            Mapper.Initialize(cfg);

            //在程序启动时对所有的配置进行严格的验证
            Mapper.AssertConfigurationIsValid();
        }
예제 #13
0
        private void RegisterAutoMapper(IServiceCollection services)
        {
            var configurationExp = new MapperConfigurationExpression();

            configurationExp.CreateMap <Adress, AdressViewModel>()
            .ForMember(nameof(AdressViewModel.CitizenCount),
                       opt => opt.MapFrom(adress => adress.Citizens.Count()));
            configurationExp.CreateMap <AdressViewModel, Adress>();

            configurationExp.AddProfile <PoliceProfiles>();
            configurationExp.AddProfile <AirportProfiles>();
            configurationExp.CreateMap <Fireman, FiremanShowViewModel>()
            .ForMember(nameof(FiremanShowViewModel.Name),
                       opt => opt.MapFrom(fireman => fireman.Citizen.Name))
            .ForMember(nameof(FiremanShowViewModel.Age),
                       opt => opt.MapFrom(fireman => fireman.Citizen.Age));

            MapBothSide <Fireman, FiremanViewModel>(configurationExp);
            MapBothSide <Citizen, FullProfileViewModel>(configurationExp);
            MapBothSide <Bus, BusParkViewModel>(configurationExp);
            MapBothSide <TripRoute, TripViewModel>(configurationExp);

            MapBothSide <Student, StudentViewModel>(configurationExp);
            MapBothSide <Pupil, PupilViewModel>(configurationExp);
            MapBothSide <Student, Pupil>(configurationExp);
            MapBothSide <University, UniversityViewModel>(configurationExp);
            MapBothSide <School, SchoolViewModel>(configurationExp);
            MapBothSide <Certificate, CertificateViewModel>(configurationExp);

            var config = new MapperConfiguration(configurationExp);
            var mapper = new Mapper(config);

            services.AddScoped <IMapper>(x => mapper);
        }
예제 #14
0
        public void Config(MapperConfigurationExpression configuration, ILifetimeScope scope)
        {
            configuration.CreateMap <ErrorRecord, ErrorRecordPreview>()
            .ForMember(dest => dest.Id, m => m.MapFrom(src => src.Id))
            .ForMember(dest => dest.Description, m => m.MapFrom(src => src.ShortDescription))
            .ForMember(dest => dest.ImportanceType, m => m.MapFrom(src => src.ImportanceType))
            .ForMember(dest => dest.InputDate, m => m.MapFrom(src => src.InputDate))
            .ForMember(dest => dest.Status, m => m.MapFrom(src => src.Status))
            .ForMember(dest => dest.Urgency, m => m.MapFrom(src => src.Urgency))
            .ReverseMap();

            configuration.CreateMap <ErrorRecord, EditableErrorRecord>()
            .ForMember(dest => dest.Id, m => m.MapFrom(src => src.Id))
            .ForMember(dest => dest.ShortDescription, m => m.MapFrom(src => src.ShortDescription))
            .ForMember(dest => dest.FullDescription, m => m.MapFrom(src => src.FullDescription))
            .ForMember(dest => dest.CriticalType, m => m.MapFrom(src => src.ImportanceType))
            .ForMember(dest => dest.Status, m => m.MapFrom(src => src.Status))
            .ForMember(dest => dest.Urgency, m => m.MapFrom(src => src.Urgency))
            .ReverseMap();

            configuration.CreateMap <ErrorChangeRecord, ErrorRecordHistory>()
            .ForMember(dest => dest.Id, m => m.MapFrom(src => src.Id))
            .ForMember(dest => dest.Action, m => m.MapFrom(src => src.Action))
            .ForMember(dest => dest.Comment, m => m.MapFrom(src => src.Comment))
            .ForMember(dest => dest.Date, m => m.MapFrom(src => src.Date))
            .ForMember(dest => dest.ChangedBy, m => m.MapFrom(src => $"{src.ChangedBy.FirstName} {src.ChangedBy.LastName}"))
            .ReverseMap();

            configuration.CreateMap <ErrorChangeRecord, ErrorRecordChangeStateRequest>()
            .ForMember(dest => dest.ParentId, m => m.MapFrom(src => src.ErrorRecordId))
            .ForMember(dest => dest.NextState, m => m.MapFrom(src => src.Action))
            .ForMember(dest => dest.Comment, m => m.MapFrom(src => src.Comment))
            .ReverseMap();
        }
예제 #15
0
        public static void ConfigureMap(MapperConfigurationExpression cfg)
        {
            cfg.CreateMap <ProjectCompany, ProjectCompanyViewModel>()
            .ForMember(x => x.StateName, o => o.MapFrom(s => s.State.GetDescription()))
            .ForMember(m => m.SupportingDocuments, o => o.MapFrom(s => s.SupportingDocuments));
            ;

            cfg.CreateMap <ProjectCompanyViewModel, ProjectCompany>()
            .ForMember(x => x.ProjectCompanyControl, y => y.Ignore())
            .ForMember(x => x.OwnerProjectCompanyShares, y => y.Ignore())
            .ForMember(x => x.DependentProjectCompanyShares, y => y.Ignore())
            .ForMember(x => x.Signatories, y => y.Ignore())
            .ForMember(x => x.Notifications, y => y.Ignore())
            .ForMember(x => x.Registers1, o => o.Ignore())
            .ForMember(x => x.Registers2, o => o.Ignore())
            .ForMember(x => x.Registers3, o => o.Ignore())
            .ForMember(x => x.Registers4, o => o.Ignore())
            .ForMember(x => x.Registers5, o => o.Ignore())
            .ForMember(x => x.Registers6, o => o.Ignore())
            .ForMember(x => x.Registers7, o => o.Ignore())
            .ForMember(x => x.Registers8, o => o.Ignore())
            .ForMember(x => x.Registers10, o => o.Ignore())
            .ForMember(x => x.Registers9, o => o.Ignore())
            .ForMember(x => x.Registers11, o => o.Ignore())
            .ForMember(x => x.TaxExemptions, o => o.Ignore())
            .ForMember(x => x.TaxReturns, o => o.Ignore())
            .ForMember(x => x.NotificationOfKIKs, o => o.Ignore())
            .ForMember(m => m.SupportingDocuments, o => o.MapFrom(s => s.SupportingDocuments));
            ;
        }
        private void ConfigureAnonymousTypeMaps(Type oldType, Type newAnonymousType)
        {
            anonymousTypesBaseMappings.CreateMap(newAnonymousType, oldType);
            Dictionary <Type, Type> memberTypeMaps = new Dictionary <Type, Type>();

            newAnonymousType.GetMembers()
            .OfType <PropertyInfo>()
            .ToList()
            .ForEach(member =>
            {
                Type sourceType = member.PropertyType;
                Type destMember = oldType.GetProperty(member.Name).PropertyType;
                if (sourceType == destMember)
                {
                    return;
                }

                if (!memberTypeMaps.ContainsKey(sourceType))
                {
                    memberTypeMaps.Add(sourceType, destMember);
                    anonymousTypesBaseMappings.CreateMap(sourceType, destMember);
                }
            });

            anonymousTypesConfigurationProvider = new MapperConfiguration(anonymousTypesBaseMappings);
        }
예제 #17
0
        public static void Configure(MapperConfigurationExpression cfg)
        {
            if (alreadyConfigured)
            {
                return;
            }

            lock (lockObj)
            {
                if (alreadyConfigured)
                {
                    return;
                }

                alreadyConfigured = true;

                cfg.CreateMap <Guid, string>().ConvertUsing <GuidToStringConverter>();
                cfg.CreateMap <DateTimeOffset, DateTime>().ConvertUsing <DateTimeTypeConverter>();
                cfg.AddProfile(new EntityRelationProfile());
                cfg.AddProfile(new EntityProfile());
                cfg.AddProfile(new RecordPermissionsProfile());
                cfg.AddProfile(new FieldPermissionsProfile());
                cfg.AddProfile(new FieldProfile());
                cfg.AddProfile(new EntityRelationOptionsProfile());
                cfg.AddProfile(new JobProfile());
                cfg.AddProfile(new UserFileProfile());
                cfg.AddProfile(new CurrencyProfile());
                cfg.AddProfile(new DataSourceProfile());
                cfg.CreateMap <EntityRecord, ErpUser>().ConvertUsing(new ErpUserConverter());
                cfg.CreateMap <ErpUser, EntityRecord>().ConvertUsing(new ErpUserConverterOposite());
                cfg.CreateMap <EntityRecord, ErpRole>().ConvertUsing(new ErpRoleConverter());
                cfg.AddProfile(new ErrorModelProfile());
            }
        }
예제 #18
0
        public void AddressMap_Map테스트()
        {
            var mapping = new MapperConfigurationExpression();

            mapping.CreateMap <AddressMap, AddressMap>();
            mapping.CreateMap <AddressMap, AddressData>();
            mapping.CreateMap <AddressData, AddressDataWrapper>();

            var config = new MapperConfiguration(mapping);
            var Mapper = new Mapper(config);

            string deviceName  = "Device";
            var    addressMaps = new List <AddressMap>
            {
                new AddressMap(deviceName, "1", "D1"),
                new AddressMap(deviceName, "2", "D2"),
                new AddressMap(deviceName, "3", "D3"),
                new AddressMap(deviceName, "4", "D4"),
                new AddressMap(deviceName, "5", "D5"),
                new AddressMap(deviceName, "6", "D7.1"),
                new AddressMap(deviceName, "7", "D7.2"),
                new AddressMap(deviceName, "8", "D7.3"),
            };

            var a = Mapper.Map <List <AddressData> >(addressMaps);
            var b = Mapper.Map <List <AddressDataWrapper> >(a);
            var c = Mapper.Map <List <AddressDataWrapper> >(addressMaps);
        }
예제 #19
0
 public static void ConfigureMap(MapperConfigurationExpression cfg)
 {
     cfg.CreateMap <Register10, Register10ViewModel>();
     cfg.CreateMap <Register10ViewModel, Register10>()
     .ForMember(r => r.OwnerProjectCompany, c => c.Ignore())
     .ForMember(r => r.Register10Data, c => c.Ignore());
 }
예제 #20
0
 public static void ConfigureMap(MapperConfigurationExpression cfg)
 {
     cfg.CreateMap <Models.Project, ProjectViewModel>();
     cfg.CreateMap <ProjectViewModel, Models.Project>()
     .ForMember(dest => dest.Users, opt => opt.Ignore())
     .ForMember(x => x.ProjectCompanies, y => y.Ignore());
 }
        public static void ConfigureMap(MapperConfigurationExpression cfg)
        {
            cfg.CreateMap <SupportingDocument, SupportingDocumentsViewModel>()
            .ForMember(m => m.Id, o => o.MapFrom(s => s.Id))
            .ForMember(m => m.ProjectCompanyId, o => o.MapFrom(s => s.ProjectCompanyId))
            .ForMember(m => m.IsUU, o => o.MapFrom(s => s.IsUU))
            .ForMember(m => m.IsUKIK, o => o.MapFrom(s => s.IsUKIK))
            .ForMember(m => m.IsND, o => o.MapFrom(s => s.IsND))
            .ForMember(m => m.UKIKDocType, o => o.MapFrom(s => s.UKIKDocType))
            //.ForMember(m => m.ProjectCompany, o => o.MapFrom(s => s.ProjectCompany))
            .ForMember(m => m.FileName, o => o.MapFrom(s => s.FileName))
            .ForAllOtherMembers(m => m.Ignore());


            cfg.CreateMap <SupportingDocumentsViewModel, SupportingDocument>()
            .ForMember(m => m.Id, o => o.MapFrom(s => s.Id))
            .ForMember(m => m.ProjectCompanyId, o => o.MapFrom(s => s.ProjectCompanyId))
            .ForMember(m => m.IsUU, o => o.MapFrom(s => s.IsUU))
            .ForMember(m => m.IsUKIK, o => o.MapFrom(s => s.IsUKIK))
            .ForMember(m => m.IsND, o => o.MapFrom(s => s.IsND))
            .ForMember(m => m.UKIKDocType, o => o.MapFrom(s => s.UKIKDocType))
            //.ForMember(m => m.ProjectCompany, o => o.MapFrom(s => s.ProjectCompany))
            .ForMember(m => m.FileName, o => o.MapFrom(s => s.FileName))
            .ForAllOtherMembers(m => m.Ignore());
        }
예제 #22
0
 public static void Configure(MapperConfigurationExpression cfg)
 {
     cfg.CreateMap <PersonEntity, PersonDto>()
     ;
     cfg.CreateMap <PersonDto, PersonEntity>()
     ;
 }
예제 #23
0
        public void Initialize()
        {
            var cfg = new MapperConfigurationExpression();

            cfg.CreateMap <Post, PostViewModel>().ReverseMap();
            cfg.CreateMap <Category, CategoryViewModel>().ReverseMap();
            Mapper.Initialize(cfg);
        }
 public static void ConfigureMap(MapperConfigurationExpression cfg)
 {
     cfg.CreateMap <DocumentInformation, DocumentInformationViewModel>();
     cfg.CreateMap <DocumentInformationViewModel, DocumentInformation>()
     .ForMember(x => x.DocumentCode, y => y.Ignore())
     .ForMember(x => x.ConfirmedPersonalityDocInfo, y => y.Ignore())
     .ForMember(x => x.VerifedPersonalityDocInfo, y => y.Ignore());
 }
예제 #25
0
 /// <summary>
 /// Initialize mapper
 /// </summary>
 public static void Mapping(this MapperConfigurationExpression Configuration)
 {
     Configuration.CreateMap <User, UserModel>().ReverseMap();
     Configuration.CreateMap <Category, CategoryModel>().ReverseMap();
     Configuration.CreateMap <Supplier, SupplierModel>().ReverseMap();
     Configuration.CreateMap <Product, ProductModel>().ReverseMap();
     Configuration.CreateMap <ImportLog, ImportLogModel>().ReverseMap();
 }
 public static void ConfigureMap(MapperConfigurationExpression cfg)
 {
     cfg.CreateMap <ForeignLightCompany, ForeignLightCompanyViewModel>()
     .ForMember(x => x.ProjectCompany, y => y.Ignore());
     cfg.CreateMap <ForeignLightCompanyViewModel, ForeignLightCompany>()
     .ForMember(x => x.ForeignOrganizationalFormCode, y => y.Ignore())
     .ForMember(x => x.ProjectCompany, y => y.Ignore());
 }
예제 #27
0
        protected AutoMapperConfigFactory()
        {
            _cfg = new MapperConfigurationExpression();

            //default
            _cfg.CreateMap <string, int>().ConvertUsing(s => Convert.ToInt32(s));
            _cfg.CreateMap <DateTime, string>().ConvertUsing(s => s.ToString("yyyy-MM-dd"));
        }
 /// <summary>
 /// 创建对象映射
 /// </summary>
 /// <param name="mapper">映射配置表达</param>
 public void CreateMaps(MapperConfigurationExpression mapper)
 {
     //mapper.CreateMap<SaleOrderInputDto, SaleOrderItem>().ForMember(po => po.SaleOrderId, opt => opt.Ignore());
     mapper.CreateMap <SaleOrder, SaleOrderOutputDto>().ForMember(po => po.Items, opt => opt.Ignore());
     mapper.CreateMap <SaleOrderOutputDto, SaleOrderPrintDataDto>()
     .ForMember(po => po.Items, opt => opt.MapFrom(po => po.Items))
     .ForMember(po => po.Status, opt => opt.MapFrom(po => po.Status.GetDisplayName()));
 }
예제 #29
0
        static AutoMapper()
        {
            BaseMapping.CreateMap <AddressMap, AddressMap>();
            BaseMapping.CreateMap <AddressMap, AddressData>();

            config = new MapperConfiguration(BaseMapping);
            Mapper = new Mapper(config);
        }
예제 #30
0
        public static void ConfigureMap(MapperConfigurationExpression cfg)
        {
            cfg.CreateMap <Register8Dto, Register8>()
            .ForMember(m => m.Register8Data, o => o.MapFrom(s => s.Register8Data));

            cfg.CreateMap <Register8, Register8Dto>()
            .ForMember(m => m.Register8Data, o => o.MapFrom(s => s.Register8Data));
        }
예제 #31
0
        public SeparateConfiguration()
        {
            var expr = new MapperConfigurationExpression();

            expr.CreateMap<Source, Dest>();

            var configuration = new MapperConfiguration(expr);

            Configuration = configuration;
        }