EventReader Class
Reads events from a sequence of ParsingEvent.
public class EventReaderConstructors
| Name | Description |
|---|---|
| EventReader(IParser) | Initializes a new instance of the EventReader class. |
EventReader(IParser)
EventReader.csInitializes a new instance of the EventReader class.
public EventReader(IParser parser)Parameters
parserIParser- The parser that provides the events.
Properties
| Name | Description |
|---|---|
| CurrentDepth | Gets or sets current Depth. |
| Parser | Gets the underlying parser. |
CurrentDepth
EventReader.csParser
EventReader.csMethods
| Name | Description |
|---|---|
| Accept<T>() | Checks whether the current event is of the specified type. |
| Allow<T>() | Checks whether the current event is of the specified type. If the event is of the specified type, returns it and moves to the next event. Otherwise retruns null. |
| Expect<T>() | Ensures that the current event is of the specified type, returns it and moves to the next event. |
| Peek<T>() | Gets the next event without consuming it. |
| Skip() | Skips the current event and any "child" event. |
| Skip(int) | Skips until we reach the appropriate depth again |
Accept<T>()
EventReader.csChecks whether the current event is of the specified type.
public bool Accept<T>() where T : ParsingEventType parameters
T- Type of the event.
Returns
bool Returns true if the current event is of type T. Otherwise returns false.
Allow<T>()
EventReader.csChecks whether the current event is of the specified type. If the event is of the specified type, returns it and moves to the next event. Otherwise retruns null.
public T? Allow<T>() where T : ParsingEventType parameters
T- Type of the
ParsingEvent.
Returns
T? Returns the current event if it is of type T; otherwise returns null.
Expect<T>()
EventReader.csEnsures that the current event is of the specified type, returns it and moves to the next event.
public T Expect<T>() where T : ParsingEventType parameters
T- Type of the
ParsingEvent.
Returns
T Returns the current event.
Exceptions
YamlException- If the current event is not of the specified type.
Peek<T>()
EventReader.csGets the next event without consuming it.
public T? Peek<T>() where T : ParsingEventType parameters
T- Type of the
ParsingEvent.
Returns
T? Returns the current event if it is of type T; otherwise returns null.
Skip overloads
Skip()
EventReader.csSkips the current event and any "child" event.
public void Skip()