Here is the code for the mapper:
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, it only appears to return the first element in the IEnumerable list multiple times (as many times as their are items in the XmlNodeList).
Update: I've simplified the code and update the title. The scenario works just fine if I'm mapping to one XmlNode, but the Enumeration seems to be an issue. For example, the following code works just fine:
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? Thanks!