protected override IAbstractConfigurationNode Visit(ListConfigurationNode node) { var flattened = new List <IAbstractConfigurationNode>(); var nodesToAdd = new Stack <IAbstractConfigurationNode>(); foreach (var childNode in node.Value) { nodesToAdd.Push(childNode); } while (nodesToAdd.Any()) { var childNode = nodesToAdd.Pop(); if (childNode is ListConfigurationNode listNode) { foreach (var nextChildNode in listNode.Value) { nodesToAdd.Push(nextChildNode); } continue; } var visitedNode = this.Visit(childNode); if (visitedNode is NilConfigurationNode) { continue; } flattened.Add(this.Visit(childNode)); } return(node with { Value = ImmutableArray.CreateRange(flattened) }); }
public IAbstractConfigurationNode Visit(IAbstractConfigurationNode node) { return(node switch { BooleanConfigurationNode childNode => this.Visit(childNode), DecimalConfigurationNode childNode => this.Visit(childNode), DeviceCapabilityElementConfigurationNode childNode => this.Visit(childNode), EnumConfigurationNode childNode => this.Visit(childNode), IntegralConfigurationNode childNode => this.Visit(childNode), StringConfigurationNode childNode => this.Visit(childNode), ListConfigurationNode childNode => this.Visit(childNode), UnknownConfigurationNode childNode => this.Visit(childNode), _ => node });