public EnumerateNodesOf ( YamlMappingNode mapping ) : YamlNode>>.IEnumerable |
||
mapping | YamlMappingNode | Mapping node to be enumerated |
리턴 | YamlNode>>.IEnumerable |
/// <summary> /// Applies a parameter definition to the given parameters model. /// /// <para>This only has to be overridden to provide a custom parameter parsing logic. Otherwise /// just override <see cref="YamlProjectParametersLoaderBase{TParamType}.GetActions"/></para> /// </summary> /// <param name="target">Target model object to be filled</param> /// <param name="name">Option name</param> /// <param name="value">Option value to be parsed</param> /// <param name="parser">Parser to be used</param> protected override void TryAddParameter(ReferenceAliases target, string name, YamlNode value, YamlParser parser) { var references = new HashSet <Reference>(); var seq = value as YamlSequenceNode; if (seq != null) { foreach (var referenceNode in parser.EnumerateNodesOf(seq)) { foreach (var reference in referenceLoader.LoadReference(referenceNode)) { references.Add(reference); } } } else { foreach (var reference in referenceLoader.LoadReference(value)) { references.Add(reference); } } target.Add(name, references); }
public virtual IProjectParameters Load(Suite suite, string name, YamlNode value, YamlParser parser) { this.suite = suite; var result = CreateNewParameters(suite); var mapping = value as YamlMappingNode; if (mapping != null) { foreach (var pair in parser.EnumerateNodesOf(mapping)) { var scalarKey = pair.Key as YamlScalarNode; if (scalarKey != null) { TryAddParameter(result, scalarKey.Value, pair.Value, parser); } } } else { var hints = new List <string>(); if (value is YamlSequenceNode) { hints.Add("Remove the `-` characters to make it a mapping instead of sequence"); output.Warning(String.Format("{0} block (line {1}) is not a mapping node", BlockName, value != null ? value.Start.Line.ToString(CultureInfo.InvariantCulture) : "?"), hints.ToArray()); } } return(result); }
private void LoadParameters(Suite suite, IProjectParametersHolder target, YamlNode node) { var mapping = node as YamlMappingNode; if (mapping != null) { foreach (var pair in parser.EnumerateNodesOf(mapping)) { if (new YamlScalarNode("postprocessors").Equals(pair.Key) && pair.Value is YamlMappingNode) { // skipping } else { TryAddParameters(suite, target, pair.Key, pair.Value); } } } }
protected string[] ParseStringArray(YamlParser parser, YamlNode value) { var seq = value as YamlSequenceNode; if (seq != null) { return(parser.EnumerateNodesOf(seq).OfType <YamlScalarNode>().Select(childValue => childValue.Value).ToArray()); } else { return(new string[0]); } }
private IEnumerable <Uri> LoadPlugins(YamlNode rootNode) { var result = new List <Uri>(); var rootMapping = (YamlMappingNode)rootNode; YamlNode node; if (rootMapping.Children.TryGetValue(new YamlScalarNode("plugins"), out node)) { var pluginsNode = node as YamlSequenceNode; if (pluginsNode != null) { foreach (var item in parser.EnumerateNodesOf(pluginsNode)) { var scalar = item as YamlScalarNode; if (scalar != null) { try { result.Add(new Uri(scalar.Value)); } catch (UriFormatException) { output.Warning(String.Format("Invalid plugin reference: {0}", scalar.Value)); } } else { output.Warning("Invalid child item "); } } } } return(result); }
protected bool ParseBool(YamlParser parser, YamlNode value) { var seq = value as YamlSequenceNode; if (seq != null) { var values = parser.EnumerateNodesOf(seq).OfType <YamlScalarNode>().Select(childValue => ParseBool(parser, childValue)).ToList(); if (values.Any()) { return(values.First()); } return(false); } var scalarValue = (YamlScalarNode)value; return("true".Equals(scalarValue.Value, StringComparison.InvariantCultureIgnoreCase) || "yes".Equals(scalarValue.Value, StringComparison.InvariantCultureIgnoreCase)); }
public virtual IProjectParameters Load(Suite suite, string name, YamlNode value, YamlParser parser) { this.suite = suite; var result = CreateNewParameters(suite); var mapping = value as YamlMappingNode; if (mapping != null) { foreach (var pair in parser.EnumerateNodesOf(mapping)) { var scalarKey = pair.Key as YamlScalarNode; if (scalarKey != null) { TryAddParameter(result, scalarKey.Value, pair.Value, parser); } } } return(result); }