本文整理汇总了C#中IMapper.Map方法的典型用法代码示例。如果您正苦于以下问题:C# IMapper.Map方法的具体用法?C# IMapper.Map怎么用?C# IMapper.Map使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMapper
的用法示例。
在下文中一共展示了IMapper.Map方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Photo
public Photo(dynamic obj, IMapper<Photo> photoMapper)
{
photoMapper.Map(obj, this);
}
示例2: Observation
public Observation(dynamic obj, IMapper<Observation> observationMapper)
{
Photos = new List<Photo>();
Feedback = new List<FeedBack>();
observationMapper.Map(obj, this);
}
示例3: UpkManagerController
public UpkManagerController(UpkManagerViewModel ViewModel, MainMenuViewModel MenuViewModel, IMessenger Messenger, ISettingsRepository SettingsRepository, IExceptionRepository ExceptionRepository, IMapper Mapper) {
if (Application.Current != null) Application.Current.DispatcherUnhandledException += onCurrentDispatcherUnhandledException;
AppDomain.CurrentDomain.UnhandledException += onDomainUnhandledException;
Dispatcher.CurrentDispatcher.UnhandledException += onCurrentDispatcherUnhandledException;
TaskScheduler.UnobservedTaskException += onUnobservedTaskException;
System.Windows.Forms.Application.ThreadException += onThreadException;
viewModel = ViewModel;
menuViewModel = MenuViewModel;
messenger = Messenger;
settingsRepository = SettingsRepository;
exceptionRepository = ExceptionRepository;
mapper = Mapper;
settings = Task.Run(() => settingsRepository.LoadSettingsAsync()).Result;
viewModel.Settings = mapper.Map<SettingsWindowViewEntity>(settings);
registerMessages();
registerCommands();
}
示例4: GetCommentThreads
private IList<CommentThreadModel> GetCommentThreads(Domain.Entity.Entities.Post post, IMapper mapper)
{
if (post.Comments == null) // sanity
{
return new List<CommentThreadModel>();
}
IEnumerable<Comment> roots = post.Comments.Where(comment => !comment.ParentId.HasValue);
IList<CommentThreadModel> threads = roots.Select(comment => new CommentThreadModel
{
Original = mapper.Map<Comment, CommentModel>(comment),
Replies = mapper.Map<IEnumerable<Comment>, IList<CommentModel>>(post.Comments.Where(c => c.ParentId == comment.Id)),
Form = new CommentReplyModel(post.Id, comment.Id)
}).ToList();
return threads;
}
示例5: Fill
public async Task<EditViewModel> Fill(IMapper mapper, Db db, Guest guest)
{
await base.Fill(db);
mapper.Map(guest, this);
return this;
}
示例6: PageModule
public PageModule(IPageService pageService,IMapper mapper): base("/pages")
{
if (pageService == null)
{
throw new ArgumentNullException(nameof(pageService));
}
this.pageService = pageService;
this.mapper = mapper;
Get["/"] = _ =>
{
var pages = pageService.GetAll().ToList();
var pagesViewModel = mapper.Map<IEnumerable<Page>, IEnumerable<PageViewModel>>(pages);
return pagesViewModel;
};
Get["/{id}"] = parameter => pageService.GetById(parameter.id) ?? HttpStatusCode.NotFound;
Post["/"] = _ =>
{
var page = this.Bind<Page>();
page = pageService.Add(page);
return page;
};
Put["/{id}"] = parameter =>
{
var page = this.Bind<Page>();
page.PageId = parameter.id;
bool isUpdated = pageService.Update(page);
return isUpdated ? HttpStatusCode.OK : HttpStatusCode.NotFound;
};
Delete["/{id}"] = parameter =>
{
var page = new Page() { PageId = parameter.id };
bool isDeleted = pageService.Remove(page);
return isDeleted ? HttpStatusCode.OK : HttpStatusCode.NotFound;
};
Post["/insert"] = _ =>
{
var pages = this.Bind<IEnumerable<Page>>();
pageService.Insert(pages);
return HttpStatusCode.OK;
};
}
示例7: ViewModelLocator
public ViewModelLocator(IMapper mapper)
{
if (mapper == null) throw new ArgumentNullException(nameof(mapper));
_mapper = mapper;
_mapper.Map<ToolbarViewModel, ToolbarView>()
.Map<MainContentViewModel, MainContentView>()
.Map<ComponentTitleViewModel, ComponentTitleView>();
Application.Current.Startup += ApplicationStartup;
}
示例8: Setup
public void Setup()
{
fieldMapper = new Mock<IMapper<IReadOnlyDictionary<string, string>, IEnumerable<XElement>>>();
expectedFields = fixture.CreateMany<XElement>();
fieldMapper.Setup(x => x.Map(It.IsAny<IReadOnlyDictionary<string, string>>()))
.Returns(expectedFields);
mapper = new CoinHeaderToXmlMapper(fieldMapper.Object);
result = mapper.Map(input);
}
示例9: 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))
);
}
示例10: User
public User(dynamic obj, IMapper<User> userMapper)
{
userMapper.Map(obj, this);
}
示例11: Identification
public Identification(dynamic obj, IMapper<Identification> identificationMapper)
{
identificationMapper.Map(obj, this);
}
示例12: Setup
public void Setup()
{
mapper = new CoinMetadataFieldToXmlMapper();
result = mapper.Map(new ReadOnlyDictionary<string, string>(metadata));
}
示例13: Comment
public Comment(dynamic obj, IMapper<Comment> commentMapper)
{
commentMapper.Map(obj, this);
}
示例14: Taxon
public Taxon(dynamic obj, IMapper<Taxon> taxonMapper)
{
Photos = new List<Photo>();
taxonMapper.Map(obj, this);
}