Skip to content

Commit 5a01713

Browse files
committed
improve comments
1 parent 18a309a commit 5a01713

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

YamlDotNet/Core/ParserExtensions.cs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,17 @@ public static bool Accept<T>(this IParser parser) where T : ParsingEvent
149149
}
150150

151151
/// <summary>
152-
/// Checks whether the current event contains a mapping entry that returns true for the specified selector.
153-
/// If one is found, it's key is returned as a Scalar and it's value as a ParsingEvent, the mapping entry
154-
/// is consumed and the parser is moved to the next event, and the whole function returns true.
152+
/// Attempts to find a key on a YAML mapping that matches our predicate.
153+
/// This is useful for scanning a mapping for type discriminator information.
154+
/// For example: looking for a `kind` key on an object.
155+
///
156+
/// This function only checks mappings, and only looks at the current depth.
157+
///
158+
/// If the event is a mapping and has a key that satisfies the predicate the scan
159+
/// will stop, return true, and set <paramref name="key" /> and
160+
/// <paramref name="value" />. All events up until the predicate is matched will
161+
/// be consumed.
162+
///
155163
/// If the event is not a mapping event or a matching key is not found, returns false.
156164
/// </summary>
157165
/// <param name="selector">The selector to filter the mapping by.</param>
@@ -169,8 +177,7 @@ public static bool TryFindMappingEntry(this IParser parser, Func<Scalar, bool> s
169177
switch (parser.Current)
170178
{
171179
case Scalar scalar:
172-
// we've found a scalar, check if it's value matches one
173-
// of our predicate
180+
// we've found a scalar, check if it's value matches our predicate
174181
var keyMatched = selector(scalar);
175182

176183
// move head so we can read or skip value

0 commit comments

Comments
 (0)