当前位置: 首页>>代码示例>>C#>>正文


C# IMapper.CreateMap方法代码示例

本文整理汇总了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)));
        }
开发者ID:bevacqua,项目名称:Swarm,代码行数:26,代码来源:SnapshotModelMapper.cs

示例2: CreateMaps

 public void CreateMaps(IMapper mapper)
 {
     mapper.CreateMap<Comment, CommentModel>()
         .ForMember(
             dest => dest.Message,
             opt => opt.MapFrom(src => postService.BeautifyUserMessage(src.Message, null)));
 }
开发者ID:bevacqua,项目名称:bruttissimo,代码行数:7,代码来源:CommentModelMapper.cs

示例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)));
 }
开发者ID:bevacqua,项目名称:bruttissimo,代码行数:7,代码来源:CommentListModelMapper.cs

示例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))
     );
 }
开发者ID:bevacqua,项目名称:bruttissimo,代码行数:7,代码来源:ScheduledJobModelMapper.cs

示例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
     );
 }
开发者ID:bevacqua,项目名称:bruttissimo,代码行数:29,代码来源:PostMapper.cs

示例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
     );
 }
开发者ID:bevacqua,项目名称:bruttissimo,代码行数:25,代码来源:LinkMapper.cs

示例7: CreateMaps

 public void CreateMaps(IMapper mapper)
 {
     mapper.CreateMap<Domain.Entity.Entities.Post, LinkPostModel>().Ignoring(
         m => m.Comments,
         m => m.PostSlug,
         m => m.UserMessage
     );
 }
开发者ID:bevacqua,项目名称:bruttissimo,代码行数:8,代码来源:LinkPostModelMapper.cs

示例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()));
        }
开发者ID:bevacqua,项目名称:bruttissimo,代码行数:9,代码来源:PostListModelMapper.cs

示例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())
     );
 }
开发者ID:bevacqua,项目名称:Swarm,代码行数:10,代码来源:JobDtoMapper.cs

示例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)
     );
 }
开发者ID:bevacqua,项目名称:bruttissimo,代码行数:13,代码来源:ScheduledJobDtoMapper.cs

示例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);
 }
开发者ID:bevacqua,项目名称:Swarm,代码行数:15,代码来源:LoadTestScenarioMapper.cs

示例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))
         );
 }
开发者ID:bevacqua,项目名称:bruttissimo,代码行数:15,代码来源:PostModelMapper.cs

示例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>();
        }
开发者ID:bevacqua,项目名称:Swarm,代码行数:36,代码来源:LoggingEventDataMapper.cs

示例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 }))
     );
 }
开发者ID:bevacqua,项目名称:bruttissimo,代码行数:16,代码来源:OpenGraphModelMapper.cs

示例15: CreateMaps

 public void CreateMaps(IMapper mapper)
 {
     mapper.CreateMap<Log, LogModel>();
 }
开发者ID:bevacqua,项目名称:Swarm,代码行数:4,代码来源:LogModelMapper.cs


注:本文中的IMapper.CreateMap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。