本文整理汇总了C#中IMapper.CreateMap方法的典型用法代码示例。如果您正苦于以下问题:C# IMapper.CreateMap方法的具体用法?C# IMapper.CreateMap怎么用?C# IMapper.CreateMap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMapper
的用法示例。
在下文中一共展示了IMapper.CreateMap方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateMaps
public void CreateMaps(IMapper mapper)
{
mapper.CreateMap<Snapshot, SnapshotModel>();
mapper.CreateMap<DroneSnapshotDto, Snapshot>()
.ForMember(dest => dest.Average, opt => opt.MapFrom(src => src.CurrentWorkload.Average))
.ForMember(dest => dest.AverageResponseTime, opt => opt.MapFrom(src => src.CurrentWorkload.AverageResponseTime))
.ForMember(dest => dest.Completed, opt => opt.MapFrom(src => src.CurrentWorkload.Completed))
.ForMember(dest => dest.Successful, opt => opt.MapFrom(src => src.CurrentWorkload.Successful))
.ForMember(dest => dest.Failed, opt => opt.MapFrom(src => src.CurrentWorkload.Failed))
.ForMember(dest => dest.TimedOut, opt => opt.MapFrom(src => src.CurrentWorkload.TimedOut))
.ForMember(dest => dest.IdleUsers, opt => opt.MapFrom(src => GetCountByStatus(src, VirtualUserStatus.Idle)))
.ForMember(dest => dest.SleepingUsers, opt => opt.MapFrom(src => GetCountByStatus(src, VirtualUserStatus.Sleeping)))
.ForMember(dest => dest.BusyUsers, opt => opt.MapFrom(src => GetCountByStatus(src, VirtualUserStatus.Busy)));
mapper.CreateMap<DroneSnapshotDto, SnapshotModel>()
.ForMember(dest => dest.Average, opt => opt.MapFrom(src => src.CurrentWorkload.Average))
.ForMember(dest => dest.AverageResponseTime, opt => opt.MapFrom(src => src.CurrentWorkload.AverageResponseTime))
.ForMember(dest => dest.Completed, opt => opt.MapFrom(src => src.CurrentWorkload.Completed))
.ForMember(dest => dest.Successful, opt => opt.MapFrom(src => src.CurrentWorkload.Successful))
.ForMember(dest => dest.Failed, opt => opt.MapFrom(src => src.CurrentWorkload.Failed))
.ForMember(dest => dest.TimedOut, opt => opt.MapFrom(src => src.CurrentWorkload.TimedOut))
.ForMember(dest => dest.IdleUsers, opt => opt.MapFrom(src => GetCountByStatus(src, VirtualUserStatus.Idle)))
.ForMember(dest => dest.SleepingUsers, opt => opt.MapFrom(src => GetCountByStatus(src, VirtualUserStatus.Sleeping)))
.ForMember(dest => dest.BusyUsers, opt => opt.MapFrom(src => GetCountByStatus(src, VirtualUserStatus.Busy)));
}
示例2: CreateMaps
public void CreateMaps(IMapper mapper)
{
mapper.CreateMap<Comment, CommentModel>()
.ForMember(
dest => dest.Message,
opt => opt.MapFrom(src => postService.BeautifyUserMessage(src.Message, null)));
}
示例3: CreateMaps
public void CreateMaps(IMapper mapper)
{
mapper.CreateMap<Domain.Entity.Entities.Post, CommentListModel>()
.ForMember(dest => dest.PostId, opt => opt.MapFrom(src => src.Id))
.ForMember(dest => dest.Form, opt => opt.MapFrom(src => new CommentReplyModel(src.Id, null)))
.ForMember(dest => dest.Threads, opt => opt.MapFrom(src => GetCommentThreads(src, mapper)));
}
示例4: CreateMaps
public void CreateMaps(IMapper mapper)
{
mapper.CreateMap<ScheduledJobDto, ScheduledJobModel>().ForMember(
m => m.StartTime,
x => x.MapFrom(j => userService.ToCurrentUserTimeZone(HttpContext.Current.Wrap(), j.StartTime))
);
}
示例5: CreateMaps
public void CreateMaps(IMapper mapper)
{
mapper.CreateMap<FacebookPost, Post>().ForMember(
m => m.FacebookPostId,
x => x.MapFrom(p => p.Id)
).ForMember(
m => m.FacebookFeedId,
x => x.MapFrom(p => p.To.Data[0].Id)
).ForMember(
m => m.FacebookUserId,
x => x.MapFrom(p => p.From.Id)
).ForMember(
m => m.UserMessage,
x => x.MapFrom(p => p.Message)
).ForMember(
m => m.Created,
x => x.MapFrom(p => p.CreatedTime)
).Ignoring(
m => m.Id,
m => m.UserId,
m => m.User,
m => m.LinkId,
m => m.Link,
m => m.Updated,
m => m.TwitterPostId,
m => m.TwitterUserId,
m => m.Comments
);
}
示例6: CreateMaps
public void CreateMaps(IMapper mapper)
{
mapper.CreateMap<FacebookPost, Link>().ForMember(
m => m.ReferenceUri,
x => x.MapFrom(p => p.Link)
).ForMember(
m => m.Title,
x => x.MapFrom(p => p.Name)
).ForMember(
m => m.Description,
x => x.MapFrom(p => p.Description)
).ForMember(
m => m.Picture,
x => x.MapFrom(p => p.Picture)
).ForMember(
m => m.Type,
x => x.MapFrom(p => LinkType.Html)
).ForMember(
m => m.Created,
x => x.MapFrom(p => p.CreatedTime)
).Ignoring(
m => m.Id,
m => m.PostId
);
}
示例7: CreateMaps
public void CreateMaps(IMapper mapper)
{
mapper.CreateMap<Domain.Entity.Entities.Post, LinkPostModel>().Ignoring(
m => m.Comments,
m => m.PostSlug,
m => m.UserMessage
);
}
示例8: CreateMaps
public void CreateMaps(IMapper mapper)
{
int pageSize = Config.Defaults.PostListPageSize;
mapper.CreateMap<IEnumerable<Domain.Entity.Entities.Post>, PostListModel>()
.ForMember(dest => dest.Posts, opt => opt.MapFrom(src => src))
.ForMember(dest => dest.OpenGraph, opt => opt.MapFrom(src => src.FirstOrDefault()))
.ForMember(dest => dest.HasMorePosts, opt => opt.MapFrom(src => pageSize >= src.Count()));
}
示例9: CreateMaps
public void CreateMaps(IMapper mapper)
{
mapper.CreateMap<Type, JobDto>().ForMember(
m => m.Name,
x => x.MapFrom(t => t.Name.Replace("Job", string.Empty).SplitOnCamelCase())
).ForMember(
m => m.Guid,
x => x.MapFrom(t => t.GUID.Stringify())
);
}
示例10: CreateMaps
public void CreateMaps(IMapper mapper)
{
mapper.CreateMap<IJobExecutionContext, ScheduledJobDto>().ForMember(
m => m.Name,
x => x.MapFrom(c => c.JobDetail.JobType.Name.Replace("Job", string.Empty).SplitOnCamelCase())
).ForMember(
m => m.Guid,
x => x.MapFrom(c => c.JobDetail.JobType.GUID.Stringify())
).ForMember(
m => m.StartTime,
x => x.MapFrom(c => c.Trigger.StartTimeUtc.UtcDateTime)
);
}
示例11: CreateMaps
public void CreateMaps(IMapper mapper)
{
mapper.CreateMap<Scenario, LoadTestScenario>().ForMember(
dest => dest.StartDate,
opt => opt.MapFrom(src => DateTime.UtcNow.AddSeconds(5))
).ForMember(
dest => dest.Users,
opt => opt.MapFrom(src => new VirtualUserSettings
{
Amount = src.VirtualUsers,
RampTime = src.RampUpTime,
SleepTime = src.SleepTime
})
).Ignoring(dest => dest.ExecutionId);
}
示例12: CreateMaps
public void CreateMaps(IMapper mapper)
{
mapper.CreateMap<Domain.Entity.Entities.Post, PostModel>()
.ConstructUsing(ModelByLinkType)
.BeforeMap((src, dest) => mapper.Map(src, dest, typeof(Domain.Entity.Entities.Post), dest.GetType()))
.ForMember(dest => dest.Comments, opt => opt.MapFrom(src => src))
.ForMember(
dest => dest.PostSlug,
opt => opt.MapFrom(src => postService.GetTitleSlug(src))
)
.ForMember(
dest => dest.UserMessage,
opt => opt.MapFrom(src => postService.BeautifyUserMessage(src.UserMessage, src))
);
}
示例13: CreateMaps
public void CreateMaps(IMapper mapper)
{
mapper.CreateMap<PropertiesDictionary, IDictionary<string, object>>()
.ConvertUsing(props =>
{
string[] keys = props.GetKeys();
IDictionary<string, object> dictionary = new Dictionary<string, object>();
foreach (string key in keys)
{
dictionary[key] = props[key];
}
return dictionary;
});
mapper.CreateMap<IDictionary<string, object>, PropertiesDictionary>()
.ConvertUsing(dictionary =>
{
PropertiesDictionary props = new PropertiesDictionary();
foreach (var prop in dictionary)
{
props[prop.Key] = prop.Value;
}
return props;
});
mapper.CreateMap<string, Level>()
.ConvertUsing(src =>
{
LevelMap map = LoggerManager.GetAllRepositories().First().LevelMap;
IEnumerable<Level> levels = map.AllLevels.Cast<Level>();
Level level = levels.FirstOrDefault(l => l.Name.InsensitiveEquals(src));
return level;
});
mapper.CreateMap<DroneLogDto, LoggingEventData>();
}
示例14: CreateMaps
public void CreateMaps(IMapper mapper)
{
mapper.CreateMap<Domain.Entity.Entities.Post, OpenGraphModel>().ForMember(
m => m.Title,
x => x.MapFrom(p => p.Link.Title)
).ForMember(
m => m.Description,
x => x.MapFrom(p => p.Link.Description)
).ForMember(
m => m.Image,
x => x.MapFrom(p => p.Link.Picture)
).ForMember(
m => m.Url,
x => x.MapFrom(p => urlHelper.PublicRouteUrl("PostShortcut", new { id = p.Id }))
);
}
示例15: CreateMaps
public void CreateMaps(IMapper mapper)
{
mapper.CreateMap<Log, LogModel>();
}