Skip to content

Mapping an object that implements IEnumerable T #1

@chriswalpen

Description

@chriswalpen
public class EnumerableNode : IEnumerable<SimpleNode>
{
    private List<SimpleNode> _nodes = new List<SimpleNode>();
    public void Add(SimpleNode node)
    {
        _nodes.Add(node);
    }
    public IEnumerator<SimpleNode> GetEnumerator()
    {
        return _nodes.GetEnumerator();
    }
    IEnumerator IEnumerable.GetEnumerator()
    {
        return GetEnumerator();
    }
}

public class SimpleNode
{
    public string Name { get; set; }

    public int Value { get; set; }
}
var reader = new YamlReader();
var data = reader.Read<EnumerableNode>(lines);

This can't be mapped because the EnumerableNode is not a list. The Errormessage is not very clear on why this can't be made

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions