YamlStream Class
A YAML stream: a list of YamlStreamDocument.
public class YamlStream : ICollection<YamlStreamDocument>, IEnumerable<YamlStreamDocument>, IList<YamlStreamDocument>, IEnumerable- Implements
Constructors
| Name | Description |
|---|---|
| YamlStream() | Initializes a new instance of this type. |
YamlStream()
YamlStream.csInitializes a new instance of this type.
public YamlStream()Properties
| Name | Description |
|---|---|
| Count | Gets count. |
| IsReadOnly | Gets a value indicating whether is Read Only. |
Count
YamlStream.csIsReadOnly
YamlStream.csIndexers
| Name | Description |
|---|---|
| this[int] | Gets or sets an element at the specified index. |
this[int]
YamlStream.csGets or sets an element at the specified index.
public YamlStreamDocument this[int index] { get; set; }Methods
| Name | Description |
|---|---|
| Add(YamlStreamDocument) | Adds an item. |
| Clear() | Removes all elements from the collection. |
| Contains(YamlStreamDocument) | Determines whether a value exists. |
| CopyTo(YamlStreamDocument[], int) | Copies the elements to an array starting at the specified index. |
| DeepClone() | Creates a deep clone of the current value. |
| EnumerateEvents() | Enumerates the parsing events of the stream. |
| GetEnumerator() | Gets enumerator. |
| IndexOf(YamlStreamDocument) | Gets the zero-based index of the specified item. |
| Insert(int, YamlStreamDocument) | Inserts an item at the specified index. |
| Load(EventReader) | Loads data. |
| Load(EventReader, YamlSerializerOptions?) | Loads data, honoring the anchor, alias and alias-expansion limits of options. |
| Load(TextReader) | Loads data. |
| Load(TextReader, YamlSerializerOptions?) | Loads data, honoring the hardening options in options. |
| Remove(YamlStreamDocument) | Removes an item. |
| RemoveAt(int) | Removes at. |
| System.Collections.IEnumerable.GetEnumerator() | |
| ToObject(Type, YamlSerializerOptions?) | Converts the stream to an object. |
| ToObject<T>(YamlSerializerOptions?) | Converts the stream to an instance of T. |
| ToString() | Returns a string representation of the current instance. |
| ToStringPreservingFormatting() | Returns the stream as the text it was loaded from, in which only the nodes that changed since are rewritten. See YamlStream.WritePreservingFormatting. |
| WritePreservingFormatting(TextWriter) | Writes the stream as the text it was loaded from, in which only the nodes that changed since are rewritten. The rest of the text, comments, blank lines and formatting included, is copied byte for byte. |
| WriteTo(IEmitter, bool) | Writes the stream as YAML. |
| WriteTo(TextWriter, bool) | Writes the stream as YAML. |
Add(YamlStreamDocument)
YamlStream.csClear()
YamlStream.csRemoves all elements from the collection.
public void Clear()Contains(YamlStreamDocument)
YamlStream.csDetermines whether a value exists.
public bool Contains(YamlStreamDocument item)CopyTo(YamlStreamDocument[], int)
YamlStream.csCopies the elements to an array starting at the specified index.
public void CopyTo(YamlStreamDocument[] array, int arrayIndex)Parameters
arrayYamlStreamDocument[]arrayIndexint
DeepClone()
YamlStream.csEnumerateEvents()
YamlStream.csEnumerates the parsing events of the stream.
public IEnumerable<ParsingEvent> EnumerateEvents()Returns
GetEnumerator()
YamlStream.csGets enumerator.
public IEnumerator<YamlStreamDocument> GetEnumerator()IndexOf(YamlStreamDocument)
YamlStream.csGets the zero-based index of the specified item.
public int IndexOf(YamlStreamDocument item)Insert(int, YamlStreamDocument)
YamlStream.csInserts an item at the specified index.
public void Insert(int index, YamlStreamDocument item)Parameters
indexintitemYamlStreamDocument
Load overloads
Load(EventReader)
YamlStream.csLoads data.
public static YamlStream Load(EventReader eventReader)Load(EventReader, YamlSerializerOptions?)
YamlStream.csLoads data, honoring the anchor, alias and alias-expansion limits of options.
public static YamlStream Load(EventReader eventReader, YamlSerializerOptions? options)Parameters
eventReaderEventReader- The event reader.
optionsYamlSerializerOptions?- The options used to bound alias expansion. If
null,YamlSerializerOptions.Defaultis used.
Returns
Load(TextReader)
YamlStream.csLoads data.
public static YamlStream Load(TextReader stream)Load(TextReader, YamlSerializerOptions?)
YamlStream.csLoads data, honoring the hardening options in options.
public static YamlStream Load(TextReader stream, YamlSerializerOptions? options)Parameters
streamTextReader- The reader over the YAML payload.
optionsYamlSerializerOptions?- The options used to bound nesting depth and alias expansion. If
null,YamlSerializerOptions.Defaultis used.
Returns
Remarks
Use this overload for untrusted input: it applies YamlSerializerOptions.MaxDepth, YamlSerializerOptions.AllowAnchors, YamlSerializerOptions.AllowAliases and YamlSerializerOptions.MaxAliasExpansionNodeCount.
Remove(YamlStreamDocument)
YamlStream.csRemoves an item.
public bool Remove(YamlStreamDocument item)RemoveAt(int)
YamlStream.csSystem.Collections.IEnumerable.GetEnumerator()
YamlStream.csToObject overloads
ToObject(Type, YamlSerializerOptions?)
YamlStream.csConverts the stream to an object.
public object? ToObject(Type type, YamlSerializerOptions? options = null)ToObject<T>(YamlSerializerOptions?)
YamlStream.csConverts the stream to an instance of T.
public T? ToObject<T>(YamlSerializerOptions? options = null)ToString()
YamlStream.csToStringPreservingFormatting()
YamlStream.csReturns the stream as the text it was loaded from, in which only the nodes that changed since are rewritten. See YamlStream.WritePreservingFormatting.
public string ToStringPreservingFormatting()Returns
WritePreservingFormatting(TextWriter)
YamlStream.csWrites the stream as the text it was loaded from, in which only the nodes that changed since are rewritten. The rest of the text, comments, blank lines and formatting included, is copied byte for byte.
public void WritePreservingFormatting(TextWriter writer)Parameters
writerTextWriter
Exceptions
ArgumentNullExceptionwriterisnull.
Remarks
A changed scalar replaces the text of the scalar. An entry added to or removed from a block mapping or sequence adds or removes its lines. Other changes, such as reordered entries or a changed flow collection, rewrite the smallest node that contains them. A stream that was not loaded from a text is written like YamlStream.WriteTo, without its comments and layout. So is a stream whose changes rewrite ranges of the text that overlap.
WriteTo overloads
WriteTo(IEmitter, bool)
YamlStream.csWriteTo(TextWriter, bool)
YamlStream.csWrites the stream as YAML.
public void WriteTo(TextWriter writer, bool suppressDocumentTags = false)Parameters
writerTextWritersuppressDocumentTagsbool