Skip to content

Commit

Permalink
Add overload of YamlStream.Load to be able to specify the EventReader.
Browse files Browse the repository at this point in the history
  • Loading branch information
aaubry committed Aug 21, 2015
1 parent 3c4112c commit 4d9fe28
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions YamlDotNet/RepresentationModel/YamlStream.cs
Expand Up @@ -88,20 +88,24 @@ public void Add(YamlDocument document)
/// <param name="input">The input.</param>
public void Load(TextReader input)
{
documents.Clear();

var parser = new Parser(input);

EventReader events = new EventReader(parser);
events.Expect<StreamStart>();
while (!events.Accept<StreamEnd>())
{
YamlDocument document = new YamlDocument(events);
documents.Add(document);
}
events.Expect<StreamEnd>();
Load(new EventReader(new Parser(input)));
}

/// <summary>
/// Loads the stream from the specified <see cref="EventReader"/>.
/// </summary>
public void Load(EventReader reader)
{
documents.Clear();
reader.Expect<StreamStart>();
while (!reader.Accept<StreamEnd>())
{
YamlDocument document = new YamlDocument(reader);
documents.Add(document);
}
reader.Expect<StreamEnd>();
}

/// <summary>
/// Saves the stream to the specified output.
/// </summary>
Expand Down

0 comments on commit 4d9fe28

Please sign in to comment.