private bool TryGetValueByYamlKeyAndType(YamlScalarNode yamlKey, Type type, out object result) { if (mappingNode.Children.ContainsKey(yamlKey)) { var value = mappingNode.Children[yamlKey]; if (YamlDoc.TryMapValue(value, out result)) { return true; } } return FailToGetValue(out result); }
public void Reload(YamlNode node) { yamlNode = node; mappingNode = yamlNode as YamlMappingNode; sequenceNode = yamlNode as YamlSequenceNode; scalarNode = yamlNode as YamlScalarNode; children = null; }
protected override void Visit(YamlScalarNode scalar) { VisitNode(scalar); }
private bool TryGetValueByKeyAndType(string key, Type type, out object result) { if (mappingNode == null) { return FailToGetValue(out result); } // try and get an exact match to the key first if (TryGetValueByYamlKeyAndType(key, type, out result)) { return true; } // otherwise try and match the key with a different cased first character var yamlKey = new YamlScalarNode(key.InverseFirstCapital()); if (TryGetValueByYamlKeyAndType(yamlKey, type, out result)) { return true; } return IsNullableType(type) ? SuccessfullyGetValue(new DynamicYaml((YamlNode)null), out result) : FailToGetValue(out result); }
/// <summary> /// Called after this object finishes visiting a <see cref="YamlScalarNode"/>. /// </summary> /// <param name="scalar"> /// The <see cref="YamlScalarNode"/> that has been visited. /// </param> protected virtual void Visited(YamlScalarNode scalar) { // Do nothing. }
void IYamlVisitor.Visit(YamlScalarNode scalar) { Visit(scalar); Visited(scalar); }
/// <summary> /// Called after this object finishes visiting a <see cref="YamlScalarNode"/>. /// </summary> /// <param name="scalar"> /// The <see cref="YamlScalarNode"/> that has been visited. /// </param> protected virtual void Visited (YamlScalarNode scalar) { // Do nothing. }
void IYamlVisitor.Visit (YamlScalarNode scalar) { Visit(scalar); Visited(scalar); }