Here is the code for the translator:
public IEnumerable<GetQuestionsContract> Map(IEnumerable<XmlNode> nodes, XmlNamespaceManager namespaceManager)
{
Mapper.CreateMap<XmlNode, GetQuestionsContract>()
.ForMember(
dest => dest.Id,
options =>
options.ResolveUsing<XmlNodeResolver<string>>().FromMember(
source => source.SelectSingleNode("//wfauth60xsd:questionID", namespaceManager)))
.ForMember(
dest => dest.Question,
options =>
options.ResolveUsing<XmlNodeResolver<string>>().FromMember(
source => source.SelectSingleNode("//wfauth60xsd:question", namespaceManager)));
return Mapper.Map<IEnumerable<XmlNode>, List<GetQuestionsContract>>(nodes);
}
While this works, only one returned element appears in the IEnumerable list several times (as many times as there are elements in the XmlNodeList).
Update . I simplified the code and updated the title. The script works fine if I map one to XmlNode, but enumeration seems to be the problem. For example, the following code works very well:
public SomeIdContract Map(XmlDocument document, XmlNamespaceManager namespaceManager)
{
Mapper.CreateMap<XmlDocument, SomeIdContract>()
.ForMember(
dest => dest.Id,
options =>
options.ResolveUsing<XmlNodeResolver<string>>().FromMember(
source => source.SelectSingleNode("//wfauth60msgs:someID", namespaceManager)));
return Mapper.Map<XmlDocument, SomeIdContract>(document);
}
Any thoughts? Thank!
source
share