本文整理汇总了C#中IConfiguration.CreateMap方法的典型用法代码示例。如果您正苦于以下问题:C# IConfiguration.CreateMap方法的具体用法?C# IConfiguration.CreateMap怎么用?C# IConfiguration.CreateMap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IConfiguration
的用法示例。
在下文中一共展示了IConfiguration.CreateMap方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Configure
public void Configure(IConfiguration config)
{
config.CreateMap<HomeTrack.Transaction, Transaction>()
.ForMember(x => x.Id, map => map.ResolveUsing(x => x.Id ?? TransactionId.From(x)));
config.CreateMap<Transaction, HomeTrack.Transaction>();
}
示例2: ConfigureMappings
public override void ConfigureMappings(IConfiguration config, ApplicationContext applicationContext)
{
//FROM IMacro TO EntityBasic
config.CreateMap<IMacro, EntityBasic>()
.ForMember(entityBasic => entityBasic.Icon, expression => expression.UseValue("icon-settings-alt"))
.ForMember(dto => dto.ParentId, expression => expression.UseValue(-1))
.ForMember(dto => dto.Path, expression => expression.ResolveUsing(macro => "-1," + macro.Id));
config.CreateMap<IMacro, IEnumerable<MacroParameter>>()
.ConvertUsing(macro => macro.Properties.Select(Mapper.Map<MacroParameter>).ToList());
config.CreateMap<IMacroProperty, MacroParameter>()
.AfterMap((property, parameter) =>
{
//map the view and the config
var paramEditor = ParameterEditorResolver.Current.GetByAlias(property.EditorAlias);
if (paramEditor == null)
{
//we'll just map this to a text box
paramEditor = ParameterEditorResolver.Current.GetByAlias(Constants.PropertyEditors.TextboxAlias);
LogHelper.Warn<MacroModelMapper>("Could not resolve a parameter editor with alias " + property.EditorAlias + ", a textbox will be rendered in it's place");
}
parameter.View = paramEditor.ValueEditor.View;
//set the config
parameter.Configuration = paramEditor.Configuration;
});
}
示例3: ConfigureMaps
public static void ConfigureMaps(IConfiguration configStore)
{
configStore.CreateMap<SummaryRequest, SummaryViewModel>();
configStore.CreateMap<LoginRequest, LoginViewModel>();
configStore.CreateMap<RegisterRequest, RegisterViewModel>();
configStore.CreateMap<NewThreadRequest, NewThreadViewModel>();
configStore.CreateMap<NewThreadCommand, NewThreadRequest>();
configStore.CreateMap<DiscussionThread, ViewThreadRequest>()
.ForMember(x => x.IPAddress, opt => opt.Ignore())
.ForMember(x => x.UserAccount, opt => opt.Ignore());
configStore.CreateMap<DiscussionThread, ThreadSummaryViewModel>()
.ForMember(x => x.TimeZoneOffset, opt => opt.Ignore());
configStore.CreateMap<DiscussionThread, ViewThreadViewModel>()
.ForMember(x => x.ReplyBody, opt => opt.Ignore())
.ForMember(x => x.Replies, opt => opt.Ignore());
configStore.CreateMap<LoginCommand, LoginRequest>()
.ForMember(x => x.Password, opt => opt.Ignore());
configStore.CreateMap<RegisterCommand, RegisterRequest>()
.ForMember(x => x.Password, opt => opt.Ignore())
.ForMember(x => x.ConfirmPassword, opt => opt.Ignore());
}
示例4: Map
public void Map(IConfiguration cfg)
{
cfg.CreateMap<PersonModel, Person>();
cfg.CreateMap<Person, PersonModel>();
cfg.CreateMap<BaptismModel, Baptism>();
cfg.CreateMap<Baptism, BaptismModel>();
}
示例5: CreateMap
public void CreateMap(IConfiguration configuration)
{
configuration.CreateMap<Point, SimplePoint>();
configuration.CreateMap<SimplePoint, Point>()
.ConstructUsing(src => CreatePoint(src.X, src.Y))
.ForAllMembers(d => d.Ignore());
}
示例6: Map
public void Map(IConfiguration cfg)
{
cfg.CreateMap<PersonModel, Person>();
cfg.CreateMap<Person, PersonModel>();
cfg.CreateMap<ParishModel, Parish>();
cfg.CreateMap<Parish, ParishModel>();
}
示例7: Configure
public void Configure(IConfiguration config)
{
config.CreateMap<HomeTrack.Account, Models.Account>()
.ForMember(x => x.AccountTypeName, map => map.MapFrom(x => x.Type));
config.CreateMap<Models.Account, HomeTrack.Account>()
.ForMember(x => x.Type, map => map.MapFrom(x => x.AccountTypeName));
}
示例8: Configure
public void Configure(IConfiguration config)
{
config.CreateMap<HomeTrack.ImportResult, ImportResult>();
config.CreateMap<ImportResult, HomeTrack.ImportResult>();
config.CreateMap<ImportedTransaction, HomeTrack.ImportedTransaction>();
config.CreateMap<Transaction, ImportedTransaction>();
}
示例9: Create
public void Create(IConfiguration configuration)
{
configuration.CreateMap<UserOrder, UserOrderListViewModel>()
.ForMember(d => d.FirstName, o => o.MapFrom(s => s.User.FirstName))
.ForMember(d => d.LastName, o => o.MapFrom(s => s.User.LastName));
configuration.CreateMap<UserOrder, CreateEditUserOrderViewModel>()
.ForMember(d => d.UserId, o => o.MapFrom(s => s.User.Id))
.ForMember(d => d.Users, o => o.Ignore());
}
示例10: CreateMappings
public void CreateMappings(IConfiguration configuration)
{
configuration
.CreateMap<Administrator, AdministratorDetailViewModel>()
.ForMember(viewModel => viewModel.IsCurrentAuthenticatedUser,
o => o.MapFrom(administrator => IsCurrentUser(administrator)))
.IgnoreAllNonExisting();
configuration
.CreateMap<Charity, IEnumerable<AdministratorDetailViewModel>>()
.ConvertUsing(ConvertToAdministratorDetailViewModels);
}
示例11: ConfigureMappings
public void ConfigureMappings(IConfiguration config, ApplicationContext applicationContext)
{
config.CreateMap<Section, Application>()
.ForMember(x => x.alias, expression => expression.MapFrom(x => x.Alias))
.ForMember(x => x.icon, expression => expression.MapFrom(x => x.Icon))
.ForMember(x => x.name, expression => expression.MapFrom(x => x.Name))
.ForMember(x => x.sortOrder, expression => expression.MapFrom(x => x.SortOrder)).ReverseMap();
config.CreateMap<Application, Section>()
.ForMember(x => x.Alias, expression => expression.MapFrom(x => x.alias))
.ForMember(x => x.Icon, expression => expression.MapFrom(x => x.icon))
.ForMember(x => x.Name, expression => expression.MapFrom(x => x.name))
.ForMember(x => x.SortOrder, expression => expression.MapFrom(x => x.sortOrder));
}
示例12: ConfigureMappings
public override void ConfigureMappings(IConfiguration config, ApplicationContext applicationContext)
{
config.CreateMap<IUser, UserDetail>()
.ForMember(detail => detail.UserId, opt => opt.MapFrom(user => GetIntId(user.Id)))
.ForMember(detail => detail.UserType, opt => opt.MapFrom(user => user.UserType.Alias))
.ForMember(detail => detail.Culture, opt => opt.MapFrom(user => ui.Culture(user)))
.ForMember(
detail => detail.EmailHash,
opt => opt.MapFrom(user => user.Email.ToLowerInvariant().Trim().ToMd5()));
config.CreateMap<IProfile, UserBasic>()
.ForMember(detail => detail.UserId, opt => opt.MapFrom(profile => GetIntId(profile.Id)));
}
示例13: ConfigureMappings
public override void ConfigureMappings(IConfiguration config, ApplicationContext applicationContext)
{
config.CreateMap<IRelation, RelationRepresentation>()
.ForMember(representation => representation.RelationTypeAlias, expression => expression.MapFrom(member => member.RelationType.Alias));
config.CreateMap<RelationRepresentation, IRelation>()
.ConstructUsing((RelationRepresentation source) => new Relation(source.ParentId, source.ChildId, ApplicationContext.Current.Services.RelationService.GetRelationTypeByAlias(source.RelationTypeAlias)))
.ForMember(dto => dto.ParentId, expression => expression.Ignore())
.ForMember(dto => dto.ChildId, expression => expression.Ignore())
.ForMember(dest => dest.Id, expression => expression.Condition(representation => (representation.Id > 0)));
}
示例14: Create
public void Create(IConfiguration configuration)
{
configuration.CreateMap<Company, CompanyFormViewModel>();
configuration.CreateMap<Company, CompanyListDatatableViewModel>();
configuration.CreateMap<User, UserFormViewModel>()
.ForMember(d => d.CompanyId, o => o.MapFrom(s => s.Company.Id))
.IgnoreAllNonExisting();
configuration.CreateMap<User, UserListDatatableViewModel>()
.ForMember(d => d.CompanyName, o => o.MapFrom(s => s.Company.Name))
.ForMember(d => d.CreateDate, o => o.ResolveUsing<DateToFormattedStringResolver>().FromMember(s => s.CreateDate))
.ForMember(d => d.Role, o => o.ResolveUsing<UserRoleListToStringResolver>().FromMember(s => s));
}
示例15: CreateMappings
public void CreateMappings(IConfiguration configuration)
{
configuration.CreateMap<Model.Question, QuestionModel>()
.ForMember(m => m.Category, opt => opt.MapFrom(u => u.Category.Name))
.ForMember(m => m.Choices, opt => opt.MapFrom(u => u.Choices))
.ForMember(m => m.Files, opt => opt.MapFrom(u => u.Files));
}