本文整理汇总了C#中IMapperConfiguration类的典型用法代码示例。如果您正苦于以下问题:C# IMapperConfiguration类的具体用法?C# IMapperConfiguration怎么用?C# IMapperConfiguration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IMapperConfiguration类属于命名空间,在下文中一共展示了IMapperConfiguration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Initialize
public static void Initialize(IMapperConfiguration mapperConfig)
{
mapperConfig
.CreateMap<GuessThePicture.DataAccessContracts.Dto.PictureDto, GuessThePicture.Domain.Entities.Picture>()
.ForMember(i => i.Style, x => x.ResolveUsing(t => t.Style.Name))
.ForMember(i => i.Campaigns, x => x.Ignore());
}
示例2: TeamMapping
private static void TeamMapping(IMapperConfiguration cfg)
{
cfg.CreateMap<TeamPlayerEntity, TeamPlayer>()
.ForMember(
dest => dest.Type,
opts => opts.MapFrom(src => src.PlayerType));
cfg.CreateMap<TeamEntity, Team>()
.ForMember(
dest => dest.ClubId,
opts => opts.MapFrom(src => Constants.OwnClubId))
.ForMember(
dest => dest.Competition,
opts => opts.MapFrom(src => Constants.NormalizeCompetition(src.Competition)))
.ForMember(
dest => dest.DivisionName,
opts => opts.MapFrom(src => src.ReeksNummer + src.ReeksCode))
.ForMember(
dest => dest.Frenoy,
opts => opts.MapFrom(src => new FrenoyTeamLinks
{
DivisionId = src.FrenoyDivisionId,
LinkId = src.LinkId,
TeamId = src.FrenoyTeamId
}))
.ForMember(
dest => dest.Players,
opts => opts.MapFrom(src => src.Players))
.ForMember(
dest => dest.Opponents,
opts => opts.MapFrom(src => MapAllTeams(src)))
;
}
示例3: RenderDataObjectsAutoMapper
public RenderDataObjectsAutoMapper(RequestContext context, IMapperConfiguration mapperConfiguration,
IMapperExtensions mapperExtensions)
: base(context.Zeus.Output)
{
this._mapperExtensions = mapperExtensions;
this._mapperConfiguration = mapperConfiguration;
this._context = context;
}
示例4: CreateMappings
public override void CreateMappings(IMapperConfiguration configuration)
{
configuration.CreateMap<Organisation, OrganisationDetailsModel>()
.ForMember(x => x.Owner, opt => opt.MapFrom(x => x.Owner.Email))
.ForMember(
x => x.Tests,
opt => opt.MapFrom(x => x.Tests))
.ForMember(x => x.Users, opt => opt.MapFrom(x => x.Users));
}
示例5: ConfigureUserMapping
private static void ConfigureUserMapping(IMapperConfiguration cfg)
{
cfg.CreateMap<UserToRegisterViewModel, User>();
cfg.CreateMap<UserToLoginViewModel, User>();
cfg.CreateMap<UserToActivateViewModel, User>();
cfg.CreateMap<UserToRemindPasswordViewModel, User>();
cfg.CreateMap<UserToSendActivationCodeViewModel, User>();
cfg.CreateMap<UserToSendRemindPasswordRequestViewModel, User>();
cfg.CreateMap<User, User>().ForAllMembers(opt => opt.Condition(c => !c.IsSourceValueNull));
}
示例6: CreateMappings
public void CreateMappings(IMapperConfiguration configuration)
{
configuration.CreateMap<User, UserInfoViewModel>()
.ForMember(
self => self.QuizzesCreated,
opt => opt.MapFrom(model => model.QuizzesCreated.Count))
.ForMember(
self => self.QuizzesTaken,
opt => opt.MapFrom(model => model.SolutionsSubmited.Count));
}
示例7: LoadCustomMappings
private static void LoadCustomMappings(IEnumerable<Type> types, IMapperConfiguration mapperConfiguration)
{
var maps = types
.Where(t => !t.IsInterface && !t.IsAbstract && t.GetInterfaces()
.Any(i => typeof(IHaveCustomMappings).IsAssignableFrom(i)))
.Select(t => (IHaveCustomMappings)Activator.CreateInstance(t))
.ToList();
maps.ForEach(m => m.CreateMappings(mapperConfiguration));
}
示例8: Configure
//методы
public static void Configure(IMapperConfiguration configuration)
{
configuration.CreateMap<SignalBounce<Guid>, SignalBounceGuid>();
configuration.CreateMap<SignalDispatchBase<Guid>, SignalDispatchBaseGuid>();
configuration.CreateMap<SubjectDispatch<Guid>, SubjectDispatchGuid>();
configuration.CreateMap<UserCategorySettings<Guid>, UserCategorySettingsGuid>();
configuration.CreateMap<UserDeliveryTypeSettings<Guid>, UserDeliveryTypeSettingsGuid>();
configuration.CreateMap<UserReceivePeriod<Guid>, UserReceivePeriodGuid>();
configuration.CreateMap<UserTopicSettings<Guid>, UserTopicSettingsGuid>();
}
示例9: Configure
public void Configure(IMapperConfiguration mapperConfiguration)
{
mapperConfiguration.CreateMap<NewTask, Data.Entities.Task>()
.ForMember(opt => opt.Version, x => x.Ignore())
.ForMember(opt => opt.CreatedBy, x => x.Ignore())
.ForMember(opt => opt.TaskId, x => x.Ignore())
.ForMember(opt => opt.CreatedDate, x => x.Ignore())
.ForMember(opt => opt.CompletedDate, x => x.Ignore())
.ForMember(opt => opt.Status, x => x.Ignore())
.ForMember(opt => opt.Users, x => x.Ignore());
}
示例10: LoadAllMappings
private static void LoadAllMappings(IMapperConfiguration config, params string[] assemblies)
{
var types = new List<Type>();
foreach (var assembly in assemblies.Select(a => Assembly.Load(a)))
{
types.AddRange(assembly.GetExportedTypes());
}
LoadStandardMappings(config, types);
LoadCustomMappings(config, types);
}
示例11: LoadCustomMappings
private static void LoadCustomMappings(IEnumerable<Type> types, IMapperConfiguration mapperConfiguration)
{
var maps = (from t in types
from i in t.GetInterfaces()
where typeof(IHaveCustomMappings).IsAssignableFrom(t) && !t.IsAbstract && !t.IsInterface
select (IHaveCustomMappings)Activator.CreateInstance(t)).ToArray();
foreach (var map in maps)
{
map.CreateMappings(mapperConfiguration);
}
}
示例12: ConfigureMaps
public static void ConfigureMaps(IMapperConfiguration cfg)
{
cfg.CreateMap< AuthLoginInfo, AuthLoginInfoPoco>()
.ForMember(s => s.UserName, m => m.MapFrom(s => s.UserName))
.ForMember(s => s.PasswordSalt, m => m.MapFrom(s => s.PasswordSalt))
.ForMember(s => s.HashedPassword, m => m.MapFrom(s => s.HashedPassword));
cfg.CreateMap<AuthLoginInfoPoco, AuthLoginInfo>()
.ForMember(s => s.UserName, m => m.MapFrom(s => s.UserName))
.ForMember(s => s.PasswordSalt, m => m.MapFrom(s => s.PasswordSalt))
.ForMember(s => s.HashedPassword, m => m.MapFrom(s => s.HashedPassword));
}
示例13: LoadCustomMappings
private static void LoadCustomMappings(IMapperConfiguration mapperConfiguration, IEnumerable<Type> types)
{
IEnumerable<IHaveCustomMappings> maps = types
.SelectMany(t => t.GetInterfaces(), (t, i) => new { t, i })
.Where(type => typeof(IHaveCustomMappings).IsAssignableFrom(type.t) &&
!type.t.IsAbstract &&
!type.t.IsInterface)
.Select(type => (IHaveCustomMappings)Activator.CreateInstance(type.t));
foreach (var map in maps)
{
map.CreateMappings(mapperConfiguration);
}
}
示例14: LoadStandardMappings
private static void LoadStandardMappings(IEnumerable<Type> types, IMapperConfiguration mapperConfiguration)
{
var maps = (from t in types
from i in t.GetInterfaces()
where
i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IMapFrom<>) && !t.IsAbstract
&& !t.IsInterface
select new { Source = i.GetGenericArguments()[0], Destination = t }).ToArray();
foreach (var map in maps)
{
mapperConfiguration.CreateMap(map.Source, map.Destination);
}
}
示例15: LoadCustomMappings
private static void LoadCustomMappings(IMapperConfiguration mapperConfiguration, IList<Type> types)
{
var maps = (from t in types
from i in t.GetInterfaces()
where typeof(IHaveCustomMappings).IsAssignableFrom(t) &&
!t.IsAbstract &&
!t.IsInterface
select InitializeCustomMappingObject(t)).ToArray();
foreach (var map in maps)
{
map.CreateMappings(mapperConfiguration);
}
}