public GetNode ( string anchor, bool throwException, YamlDotNet.Core.Mark start, YamlDotNet.Core.Mark end ) : |
||
anchor | string | The anchor. |
throwException | bool | if set to |
start | YamlDotNet.Core.Mark | The start position. |
end | YamlDotNet.Core.Mark | The end position. |
Результат |
/// <summary> /// Parses the node represented by the next event in <paramref name="parser" />. /// </summary> /// <returns>Returns the node that has been parsed.</returns> static internal YamlNode ParseNode(IParser parser, DocumentLoadingState state) { if (parser.Accept <Scalar>()) { return(new YamlScalarNode(parser, state)); } if (parser.Accept <SequenceStart>()) { return(new YamlSequenceNode(parser, state)); } if (parser.Accept <MappingStart>()) { return(new YamlMappingNode(parser, state)); } if (parser.Accept <AnchorAlias>()) { var alias = parser.Expect <AnchorAlias>(); return(state.GetNode(alias.Value, false, alias.Start, alias.End) ?? new YamlAliasNode(alias.Value)); } throw new ArgumentException("The current event is of an unsupported type.", "events"); }
/// <summary> /// Parses the node represented by the next event in <paramref name="events" />. /// </summary> /// <param name="events">The events.</param> /// <param name="state">The state.</param> /// <returns>Returns the node that has been parsed.</returns> static internal YamlNode ParseNode(EventReader events, DocumentLoadingState state, bool allowOverrideKeys) { if (events.Accept <Scalar>()) { return(new YamlScalarNode(events, state)); } if (events.Accept <SequenceStart>()) { return(new YamlSequenceNode(events, state, allowOverrideKeys)); } if (events.Accept <MappingStart>()) { return(new YamlMappingNode(events, state, allowOverrideKeys)); } if (events.Accept <AnchorAlias>()) { AnchorAlias alias = events.Expect <AnchorAlias>(); return(state.GetNode(alias.Value, false, alias.Start, alias.End) ?? new YamlAliasNode(alias.Value)); } throw new ArgumentException("The current event is of an unsupported type.", "events"); }
internal override void ResolveAliases(DocumentLoadingState state) { Dictionary <YamlNode, YamlNode> dictionary = null; Dictionary <YamlNode, YamlNode> dictionary2 = null; foreach (KeyValuePair <YamlNode, YamlNode> pair in this.children) { if (pair.Key is YamlAliasNode) { dictionary = new Dictionary <YamlNode, YamlNode> { { pair.Key, state.GetNode(pair.Key.Anchor, true, pair.Key.Start, pair.Key.End) } }; } if (pair.Value is YamlAliasNode) { dictionary2 = new Dictionary <YamlNode, YamlNode> { { pair.Key, state.GetNode(pair.Value.Anchor, true, pair.Value.Start, pair.Value.End) } }; } } if (dictionary2 != null) { foreach (KeyValuePair <YamlNode, YamlNode> pair2 in dictionary2) { this.children[pair2.Key] = pair2.Value; } } if (dictionary != null) { foreach (KeyValuePair <YamlNode, YamlNode> pair3 in dictionary) { YamlNode node = this.children[pair3.Key]; this.children.Remove(pair3.Key); this.children.Add(pair3.Value, node); } } }
/// <summary> /// Resolves the aliases that could not be resolved when the node was created. /// </summary> /// <param name="state">The state of the document.</param> internal override void ResolveAliases(DocumentLoadingState state) { for (int i = 0; i < children.Count; ++i) { if (children[i] is YamlAliasNode) { children[i] = state.GetNode(children[i].Anchor, true, children[i].Start, children[i].End); } } }
internal override void ResolveAliases(DocumentLoadingState state) { for (int i = 0; i < this.children.Count; i++) { if (this.children[i] is YamlAliasNode) { this.children[i] = state.GetNode(this.children[i].Anchor, true, this.children[i].Start, this.children[i].End); } } }
/// <summary> /// Resolves the aliases that could not be resolved when the node was created. /// </summary> /// <param name="state">The state of the document.</param> internal override void ResolveAliases(DocumentLoadingState state) { Dictionary <YamlNode, YamlNode> keysToUpdate = null; Dictionary <YamlNode, YamlNode> valuesToUpdate = null; foreach (var entry in children) { if (entry.Key is YamlAliasNode) { if (keysToUpdate == null) { keysToUpdate = new Dictionary <YamlNode, YamlNode>(); } keysToUpdate.Add(entry.Key, state.GetNode(entry.Key.Anchor, true, entry.Key.Start, entry.Key.End)); } if (entry.Value is YamlAliasNode) { if (valuesToUpdate == null) { valuesToUpdate = new Dictionary <YamlNode, YamlNode>(); } valuesToUpdate.Add(entry.Key, state.GetNode(entry.Value.Anchor, true, entry.Value.Start, entry.Value.End)); } } if (valuesToUpdate != null) { foreach (var entry in valuesToUpdate) { children[entry.Key] = entry.Value; } } if (keysToUpdate != null) { foreach (var entry in keysToUpdate) { YamlNode value = children[entry.Key]; children.Remove(entry.Key); children.Add(entry.Value, value); } } }
internal override void ResolveAliases(DocumentLoadingState state) { Dictionary <YamlNode, YamlNode> dictionary = null; Dictionary <YamlNode, YamlNode> dictionary2 = null; foreach (KeyValuePair <YamlNode, YamlNode> child in children) { if (child.Key is YamlAliasNode) { if (dictionary == null) { dictionary = new Dictionary <YamlNode, YamlNode>(); } dictionary.Add(child.Key, state.GetNode(child.Key.Anchor, true, child.Key.Start, child.Key.End)); } if (child.Value is YamlAliasNode) { if (dictionary2 == null) { dictionary2 = new Dictionary <YamlNode, YamlNode>(); } dictionary2.Add(child.Key, state.GetNode(child.Value.Anchor, true, child.Value.Start, child.Value.End)); } } if (dictionary2 != null) { foreach (KeyValuePair <YamlNode, YamlNode> item in dictionary2) { children[item.Key] = item.Value; } } if (dictionary != null) { foreach (KeyValuePair <YamlNode, YamlNode> item2 in dictionary) { YamlNode value = children[item2.Key]; children.Remove(item2.Key); children.Add(item2.Value, value); } } }
/// <summary> /// Parses the node represented by the next event in <paramref name="parser" />. /// </summary> /// <returns>Returns the node that has been parsed.</returns> internal static YamlNode ParseNode(IParser parser, DocumentLoadingState state) { if (parser.Accept<Scalar>()) { return new YamlScalarNode(parser, state); } if (parser.Accept<SequenceStart>()) { return new YamlSequenceNode(parser, state); } if (parser.Accept<MappingStart>()) { return new YamlMappingNode(parser, state); } if (parser.Accept<AnchorAlias>()) { var alias = parser.Expect<AnchorAlias>(); return state.GetNode(alias.Value, false, alias.Start, alias.End) ?? new YamlAliasNode(alias.Value); } throw new ArgumentException("The current event is of an unsupported type.", "events"); }