public void ParsesCruiseControlServerCorrectly() { var kernel = new StandardKernel(); var parser = kernel.Get<CruiseControlConfigParser>(); kernel.Bind<ITimer>().ToConstant(new Mock<ITimer>().Object); kernel.Bind<IParser>().ToConstant(new Mock<IParser>().Object).Named("CruiseControl"); var config = new YamlMappingNode { {"url", "http://goserver.localdomain:8153/go/cctray.xml"}, {"username", "ci"}, {"password", "secret"} }; var pipeline1 = new YamlMappingNode {{"name", "Cosby-Kid"}}; var pipeline2 = new YamlMappingNode { { "name", "Family-Tieman" } }; var pipelines = new YamlSequenceNode {pipeline1, pipeline2}; config.Add("pipelines",pipelines); var cruiseControlServer = parser.Parse(config) as CruiseControlServer; Assert.IsNotNull(cruiseControlServer); Assert.IsNotNull(cruiseControlServer.Config); var cruiseControlServerconfig = cruiseControlServer.Config; Assert.AreEqual("http://goserver.localdomain:8153/go/cctray.xml", cruiseControlServerconfig.URL); Assert.AreEqual("ci", cruiseControlServerconfig.Username); Assert.AreEqual("secret", cruiseControlServerconfig.Password); Assert.IsNotNull(cruiseControlServerconfig.Pipelines); Assert.AreEqual(2, cruiseControlServerconfig.Pipelines.Count()); }
private static Tuple<string, YamlNode> GetUpdateAttribute(JProperty prop) { var propValueType = prop.Value.Type; var value = string.Empty; if (propValueType == JTokenType.Object || propValueType == JTokenType.Array) { if (propValueType == JTokenType.Array) { var nodes = new YamlSequenceNode(); foreach(var item in prop.Value as JArray) { var asset = new Asset(item as dynamic); var yamlNode = GetNodes(asset); nodes.Add(yamlNode); } return new Tuple<string, YamlNode>(prop.Name, nodes); } return new Tuple<string, YamlNode>(prop.Name, new YamlScalarNode(string.Empty)); } else { value = (prop.Value as JValue).Value.ToString(); return new Tuple<string, YamlNode>(prop.Name, new YamlScalarNode(value)); } }
public void ParsesTeamCityServerCorrectly() { var kernel = new StandardKernel(); var parser = kernel.Get<TeamCityConfigParser>(); kernel.Bind<ITimer>().ToConstant(new Mock<ITimer>().Object); kernel.Bind<IParser>().ToConstant(new Mock<IParser>().Object).Named("TeamCity"); var config = new YamlMappingNode { {"url", "http://localhost"}, {"username", "ci"}, {"password", "secret"} }; var pipeline1 = new YamlMappingNode {{"name", "bt1"}}; var pipeline2 = new YamlMappingNode { { "name", "bt2" } }; var pipelines = new YamlSequenceNode {pipeline1, pipeline2}; config.Add("pipelines",pipelines); var teamCityServer = parser.Parse(config) as TeamCityServer; Assert.IsNotNull(teamCityServer); Assert.IsNotNull(teamCityServer.Config); var teamCityServerConfig = teamCityServer.Config; Assert.AreEqual("http://localhost", teamCityServerConfig.URL); Assert.AreEqual("ci", teamCityServerConfig.Username); Assert.AreEqual("secret", teamCityServerConfig.Password); Assert.IsNotNull(teamCityServerConfig.Pipelines); Assert.AreEqual(2, teamCityServerConfig.Pipelines.Count()); }
public YamlSequenceNodeValueConverter(YamlSequenceNode parent, Type globalType, string label, MemberInfo memberInfo) { this.parentNode = parent; this.globalType = globalType; this.label = label; this.memberInfo = memberInfo; }
private YamlNode FindSequence(YamlSequenceNode node, string key, object value) { if (this.IsError) return null; foreach (var child in node.Children) { var mapping = (YamlMappingNode) child; foreach (var mappingChild in mapping.Children) { if (mappingChild.Key.ToString() == key) { // Found key, check value, otherwise skip this mappingChild if (mappingChild.Value.ToString() == value.ToString()) { // Value matches, return mapping return mapping; } else { // Value does not match, skip this child break; } } } } return null; }
static IEnumerable<KeyShortcut> GetKeyShortcuts(YamlSequenceNode groupShortcuts) { return from entry in groupShortcuts.Children.OfType<YamlMappingNode>() from keys in entry.Children.Where(n => n.Key.ToString() == "keys").Take(1).Select(x=>x.Value).OfType<YamlSequenceNode>() let name = GetValueByKey(entry, "name") from definitions in keys.Children.Select(KeyPressDefinitions).Where(definitions => definitions.Count > 0) select new KeyShortcut(name, definitions.ToArray()); }
private void VisitYamlSequenceNode(YamlSequenceNode yamlNode) { foreach (var entry in yamlNode.Children) { if (entry is YamlMappingNode) VisitYamlMappingNode((YamlMappingNode)entry); } }
private static List <object> RenderYamlSequenceNodeToObject(YamlSequenceNode node) { var result = new List <object>(); foreach (var item in node.Children) { result.Add(RenderYamlNodeToObject(item)); } return(result); }
private string[] HandleSequence(YamlSequenceNode node) { List <string> strings = new List <string>(); for (int i = 0; i < node.Children.Count; i++) { strings.Add((string)node[i]); } return(strings.ToArray()); }
public void Load(YamlSequenceNode CountriesNode) { foreach( YamlNode childSeq in CountriesNode.Children ) { if( childSeq is YamlMappingNode ) { CountryList.Add( new Country( (YamlMappingNode)childSeq ) ); } } }
protected virtual void VisitSequence(YamlSequenceNode sequence) { for (var i = 0; i < sequence.Children.Count; i++) { using (EnterPath(i.ToString())) { VisitNode(sequence.Children[i]); } } }
private static YamlSequenceNode SaveCharacterWidth(CharacterWidthEntry table) { YamlSequenceNode node = new YamlSequenceNode(); node.Style = SharpYaml.YamlStyle.Flow; node.Add(NewMappingNode("CharWidth", table.CharWidth.ToString())); node.Add(NewMappingNode("GlyphWidth", table.GlyphWidth.ToString())); node.Add(NewMappingNode("Left", table.Left.ToString())); return(node); }
private static void HandleBuildProperties(YamlSequenceNode yamlSequenceNode, List <BuildProperty> buildProperties) { foreach (var child in yamlSequenceNode.Children) { YamlParser.ThrowIfNotYamlMapping(child); var buildProperty = new BuildProperty(); HandleServiceBuildPropertyNameMapping((YamlMappingNode)child, buildProperty); buildProperties.Add(buildProperty); } }
private static void HandleServiceBindings(YamlSequenceNode yamlSequenceNode, List <ConfigServiceBinding> bindings) { foreach (var child in yamlSequenceNode.Children) { YamlParser.ThrowIfNotYamlMapping(child); var binding = new ConfigServiceBinding(); HandleServiceBindingNameMapping((YamlMappingNode)child, binding); bindings.Add(binding); } }
private void VisitYamlSequenceNode(YamlSequenceNode yamlNode) { foreach (var entry in yamlNode.Children) { if (entry is YamlMappingNode) { VisitYamlMappingNode((YamlMappingNode)entry); } } }
public static void HandleServiceMapping(YamlSequenceNode yamlSequenceNode, List <ConfigService> services, ConfigApplication application) { foreach (var child in yamlSequenceNode.Children) { YamlParser.ThrowIfNotYamlMapping(child); var service = new ConfigService(); HandleServiceNameMapping((YamlMappingNode)child, service, application); services.Add(service); } }
internal static List <Dictionary <string, string> > ConvertToDictionaryList(this YamlSequenceNode yamlNode) { List <Dictionary <string, string> > list = new List <Dictionary <string, string> >(); foreach (var item in yamlNode.OfType <YamlMappingNode>()) { list.Add(ConvertToDictionary(item)); } return(list); }
public static void HandleIngress(YamlSequenceNode yamlSequenceNode, List <ConfigIngress> ingress) { foreach (var child in yamlSequenceNode.Children) { YamlParser.ThrowIfNotYamlMapping(child); var configIngress = new ConfigIngress(); HandleIngressMapping((YamlMappingNode)child, configIngress); ingress.Add(configIngress); } }
private static void HandleIngressRules(YamlSequenceNode yamlSequenceNode, List <ConfigIngressRule> rules) { foreach (var child in yamlSequenceNode.Children) { YamlParser.ThrowIfNotYamlMapping(child); var rule = new ConfigIngressRule(); HandleIngressRuleMapping((YamlMappingNode)child, rule); rules.Add(rule); } }
private static byte[] ToByteArray(YamlSequenceNode nodes) { List <byte> values = new List <byte>(); foreach (var val in nodes) { values.Add(byte.Parse(val.ToString())); } return(values.ToArray()); }
private IList <string> ToList(YamlSequenceNode node) { var list = new List <string>(); foreach (var item in node.Children) { list.Add(((YamlScalarNode)item).Value); } return(list); }
public Dictionary <string, YamlMappingNode> ConvertTileChunks(YamlSequenceNode chunks) { var map = new Dictionary <string, YamlMappingNode>(); foreach (var chunk in chunks) { map[chunk["ind"].ToString()] = (YamlMappingNode)chunk; } return(map); }
private static int[] ToIntArray(YamlSequenceNode nodes) { List <int> values = new List <int>(); foreach (var val in nodes) { values.Add(int.Parse(val.ToString())); } return(values.ToArray()); }
private static void HandleServiceConfiguration(YamlSequenceNode yamlSequenceNode, List <ConfigConfigurationSource> configuration) { foreach (var child in yamlSequenceNode.Children) { YamlParser.ThrowIfNotYamlMapping(child); var config = new ConfigConfigurationSource(); HandleServiceConfigurationNameMapping((YamlMappingNode)child, config); configuration.Add(config); } }
private static void HandleServiceVolumes(YamlSequenceNode yamlSequenceNode, List <ConfigVolume> volumes) { foreach (var child in yamlSequenceNode.Children) { YamlParser.ThrowIfNotYamlMapping(child); var volume = new ConfigVolume(); HandleServiceVolumeNameMapping((YamlMappingNode)child, volume); volumes.Add(volume); } }
protected override void Visit(YamlSequenceNode sequence) { var nestedVisitor = new ContextAwareSequenceVisitor(context); sequence.Accept(nestedVisitor); foreach (var item in nestedVisitor.Items) { this.items.Add(new KeyValuePair<string, string>(item.Key, item.Value)); } }
static IEnumerable <ChartData> Foo(YamlSequenceNode packageVersions) { foreach (var yamlNode in packageVersions) { var node = ChartData.FromNode((YamlMappingNode)yamlNode); if (node != null) { yield return(node); } } }
private void LoadYamlSequence(YamlSequenceNode sequence) { var index = 0; foreach (var element in sequence) { this.EnterScope(index++.ToString()); this.LoadYamlNode(element); this.ExitScope(); } }
private void VisitYamlSequenceNode(string context, YamlSequenceNode sequenceNode) { EnterContext(context); for (var index = 0; index < sequenceNode.Children.Count; index++) { VisitYamlNode(index.ToString(), sequenceNode.Children[index]); } ExitContext(); }
public static List <ShipBonus> LoadBonusList(YamlNode node) { List <ShipBonus> bonuses = new List <ShipBonus>(); YamlSequenceNode seq = (YamlSequenceNode)node; foreach (var value in seq.Children) { bonuses.Add(new ShipBonus(value)); } return(bonuses); }
protected override void VisitChildren(YamlSequenceNode sequence) { int index = 0; foreach (var child in sequence.Children) { _currentPath.Push(string.Format("seq[{0}]", index.ToString())); child.Accept(this); _currentPath.Pop(); } }
protected override void Visit(YamlSequenceNode sequence) { var nestedVisitor = new ContextAwareSequenceVisitor(context); sequence.Accept(nestedVisitor); foreach (var item in nestedVisitor.Items) { this.items.Add(new KeyValuePair <string, string>(item.Key, item.Value)); } }
private KeyCode[] HandleKeyCodes(YamlSequenceNode node) { string[] codenames = HandleSequence(node); KeyCode[] KeyCodes = new KeyCode[codenames.Length]; for (int i = 0; i < codenames.Length; i++) { KeyCodes[i] = (KeyCode)System.Enum.Parse( typeof(KeyCode), codenames[i]); } return(KeyCodes); }
/// <summary> /// Builds a YAML sequence node holding a list of strings. /// </summary> /// <param name="items">The list of strings</param> /// <returns>The (new) sequence node</returns> internal static YamlSequenceNode BuildSequenceNode(List <string> items) { var seqNode = new YamlSequenceNode(); foreach (var item in items) { seqNode.AddString(item); } return(seqNode); }
protected override void VisitChildren(YamlSequenceNode sequence) { _Contexts.Push(new Context()); base.VisitChildren(sequence); var ctx = _Contexts.Pop(); foreach (var child in ctx.ToRemove) { sequence.Children.Remove(child); } }
static IList <object> GetSequenceValue(YamlSequenceNode sequence) { var results = new List <object>(); foreach (var entry in sequence.Children) { results.Add(GetValue(entry)); } return(results); }
internal static ContextReference ReadAnonymousMatchContextReference(YamlSequenceNode seq, Dictionary <string, string> variables) { var ctx = new SyntaxContext("__Anonymous__", new List <object> (), metaIncludePrototype: false); foreach (var c in seq.Children.OfType <YamlMappingNode> ()) { ctx.ParseMapping(c, variables); } return(new AnonymousMatchContextReference(ctx)); }
private static void WriteHtmlForSequenceNode(StringWriter htmlwriter, YamlSequenceNode sequence) { htmlwriter.Write("<ul>"); foreach (var node in sequence) { htmlwriter.Write("<li>"); WriteHtmlForNode(node, htmlwriter); htmlwriter.Write("</li>"); } htmlwriter.Write("</ul>"); }
private void VisitYamlSequenceNode(string context, YamlSequenceNode sequenceNode) { EnterContext(context); for (var i = 0; i < sequenceNode.Children.Count; ++i) { VisitYamlNode(i.ToString(), sequenceNode.Children[i]); } ExitContext(); }
protected YamlQuery(YamlQuery parent, bool error, YamlSequenceNode root, string key, object value) { _path = parent == null ? "" : parent.QueryPath; _path += string.Format("{0}:{{{1}}}", key, value); // Find sequencing node with matching value this.IsError = error; if (!error) { // Find next mapping node this.Node = FindSequence(root, key, value); } }
protected override void VisitChildren(YamlSequenceNode sequence) { foreach (var node in sequence.Children) { this.EnterContext(index.ToString()); var visitor = new ContextAwareVisitor(context); node.Accept(visitor); this.items.AddRange(visitor.Items); this.ExitContext(); index++; } }
public static FilterCollection parseList(YamlSequenceNode list, Dictionary<string, Filter> filterMap) { FilterCollection collection = new FilterCollection(); if (list != null) { foreach (YamlNode node in list.Children) { parseFilterNode(collection, filterMap, node); } } return collection; }
public static ValidationCollection parseList(YamlSequenceNode list, Dictionary<string, Validator> validatorMap) { ValidationCollection collection = new ValidationCollection(); if (list != null) { foreach (YamlNode node in list.Children) { parseFilterNode(collection, validatorMap, node); } } return collection; }
/// <summary> /// Visits every child of a <see cref="YamlSequenceNode"/>. /// </summary> /// <param name="sequence"> /// The <see cref="YamlSequenceNode"/> that is being visited. /// </param> protected virtual void VisitChildren(YamlSequenceNode sequence) { foreach (var node in sequence.Children) { node.Accept(this); } }
/// <summary> /// Called after this object finishes visiting a <see cref="YamlSequenceNode"/>. /// </summary> /// <param name="sequence"> /// The <see cref="YamlSequenceNode"/> that has been visited. /// </param> protected virtual void Visited(YamlSequenceNode sequence) { // Do nothing. }
private YamlNode Build() { var root = new YamlMappingNode(); root.Add("from", _assetType); if (SelectFields.Count > 0) { var select = new YamlSequenceNode(); var attributes = SelectFields.Where(s => s is string); foreach(var attr in attributes) { var val = attr as string; select.Add(val); } var nestedBuilders = SelectFields.Where(s => s is QueryApiQueryBuilder); foreach (var item in nestedBuilders) { var nestedBuilder = item as QueryApiQueryBuilder; select.Add(nestedBuilder.Build()); } root.Add("select", select); } if (WhereCriteria.Count > 0) { var whereNodes = new YamlMappingNode(); foreach (var criterion in WhereCriteria) { whereNodes.Add(criterion.AttributeName, criterion.MatchValue.ToString()); } root.Add("where", whereNodes); } if (FilterCriteria.Count > 0) { var filterNodes = new YamlSequenceNode(); foreach (var criterion in FilterCriteria) { filterNodes.Add($"{criterion.AttributeName}{criterion.Operator.Token}\"{criterion.MatchValue.ToString()}\""); } root.Add("filter", filterNodes); } return root; }
public void Reload(YamlNode node) { yamlNode = node; mappingNode = yamlNode as YamlMappingNode; sequenceNode = yamlNode as YamlSequenceNode; scalarNode = yamlNode as YamlScalarNode; children = null; }
protected override void UpgradeAsset(AssetMigrationContext context, int currentVersion, int targetVersion, dynamic asset, PackageLoadingAssetFile assetFile) { var entities = asset.Hierarchy.Entities; var designEntities = new YamlSequenceNode(); asset.Hierarchy.Entities = designEntities; foreach (var entity in entities) { var designEntity = new YamlMappingNode(); dynamic dynamicDesignEntity = new DynamicYamlMapping(designEntity); dynamicDesignEntity.Entity = entity; designEntities.Add(designEntity); } }
protected override void Visit(YamlSequenceNode sequence) { WriteIndent(); Console.WriteLine("Visit(YamlSequenceNode, {0}, {1})", sequence.Anchor, sequence.Tag); indent++; }
/// <summary> /// Called when this object is visiting a <see cref="YamlSequenceNode"/>. /// </summary> /// <param name="sequence"> /// The <see cref="YamlSequenceNode"/> that is being visited. /// </param> public virtual void Visit(YamlSequenceNode sequence) { VisitChildren(sequence); }
protected override void Visited(YamlSequenceNode sequence) { indent--; WriteIndent(); Console.WriteLine("Visited(YamlSequenceNode)"); }
public override void Visit(YamlSequenceNode sequence) { if (!VisitNodeAndFindDuplicates(sequence)) base.Visit(sequence); }
public override void Visit(YamlSequenceNode sequence) { events.Add(new YamlNodeEvent(YamlNodeEventType.SequenceStart, sequence.Anchor, sequence.Tag, null)); base.Visit(sequence); events.Add(new YamlNodeEvent(YamlNodeEventType.SequenceEnd, sequence.Anchor, sequence.Tag, null)); }
private void VisitYamlSequenceNode(YamlScalarNode yamlNodeKey, YamlSequenceNode yamlNodeValue) { EnterContext(yamlNodeKey.Value); VisitYamlSequenceNode(yamlNodeValue); ExitContext(); }
void IYamlVisitor.Visit(YamlSequenceNode sequence) { Visit(sequence); Visited(sequence); }
public DynamicYamlArray(YamlSequenceNode node) { this.node = node; }
/// <summary> /// Called when this object is visiting a <see cref="YamlSequenceNode"/>. /// </summary> /// <param name="sequence"> /// The <see cref="YamlSequenceNode"/> that is being visited. /// </param> protected virtual void Visit(YamlSequenceNode sequence) { VisitChildren(sequence); }
protected override void Visit(YamlSequenceNode sequence) { VisitNode(sequence); }
protected override void Visited(YamlSequenceNode sequence) { events.Add(new YamlNodeEvent(YamlNodeEventType.SequenceEnd, sequence.Anchor, sequence.Tag, null)); }
public DynamicYamlArray(YamlSequenceNode node) { if (node == null) throw new ArgumentNullException(nameof(node)); this.node = node; }