Mapper.CreateMap<WorkItemSummary, WorkItemSummaryDto> () .ForMember(dto => dto.ProductDisplayName, opt => opt.MapFrom(src => src.Product.DisplayName)) .ForMember(dto => dto.TeamId, opt => opt.MapFrom(src => src.Product.Team.TeamId)) .ForMember(dto => dto.TeamName, opt => opt.MapFrom(src => src.Product.Team.TeamName)) .ForMember(dto => dto.RRConsolidated, opt => opt.ResolveUsing<WIConsolidateResolveReasonResolver>()) .ForMember(dto => dto.NewBugsQuery, opt => opt.ResolveUsing<WIQueryNewBugsResolver>()) .ForMember(dto => dto.ResolvedBugsQuery, opt => opt.ResolveUsing<WIQueryResolvedResolver>()) .ForMember(dto => dto.ClosedBugsQuery, opt => opt.ResolveUsing<WIQueryClosedResolver>()) .ForMember(dto => dto.BacklogQuery, opt => opt.ResolveUsing<WIQueryBacklogResolver>()) .ForMember(dto => dto.ResolvedReasonFixQuery, opt => opt.ResolveUsing<WIQueryResolvedReasonFixResolver>()); --- Adding One Resolver Code and mostly all resolvers are doing same Job but pulling different content from Xml Nodes public class WIQueryNewBugsResolver: ValueResolver<WorkItemSummary, string> { protected override string ResolveCore(WorkItemSummary source) { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(System.IO.Path.Combine(AppDomain.CurrentDomain.RelativeSearchPath, "WIsQuery.xml")); .... } }
我有多个解析器在读取一些xml和获取数据时几乎完成相同的工作。考虑在一个解析器下整合所有这些调用。 例如:WIConsolidateResolveReasonResolver,WIQueryResolvedReasonFixResolver,WIQueryBacklogResolver
在这方面,我可以拨打一个解析器一次,并在一次通话中填写所有其他属性。
是否有其他方法调用代替ForMember
由于
答案 0 :(得分:0)
使用&#34; forallmembers&#34;如果你正在做同样的工作,自动化器的方法。可能对你有所帮助。