CubeIsland.LyricsReloaded.Filters.FilterCollection.parseFilterNode C# (CSharp) Method

parseFilterNode() private static method

private static parseFilterNode ( FilterCollection filterCollection, Filter>.Dictionary filterMap, YamlNode node ) : void
filterCollection FilterCollection
filterMap Filter>.Dictionary
node YamlDotNet.RepresentationModel.YamlNode
return void
        private static void parseFilterNode(FilterCollection filterCollection, Dictionary<string, Filter> filterMap, YamlNode node)
        {
            string name;
            string[] args;
            if (node is YamlScalarNode)
            {
                name = ((YamlScalarNode)node).Value.Trim().ToLower();
                args = new string[0];
            }
            else if (node is YamlSequenceNode)
            {
                IEnumerator<YamlNode> it = ((YamlSequenceNode)node).Children.GetEnumerator();
                if (!it.MoveNext())
                {
                    throw new InvalidConfigurationException("An empty list as a filter is not valid!");
                }
                node = it.Current;
                if (!(node is YamlScalarNode))
                {
                    throw new InvalidConfigurationException("Filter definitions as a list my only contain strings!");
                }
                name = ((YamlScalarNode)node).Value.Trim().ToLower();
                args = readFilterArgs(it);
            }
            else if (node is YamlMappingNode)
            {
                YamlMappingNode filterConfig = (YamlMappingNode)node;
                IDictionary<YamlNode, YamlNode> childNodes = filterConfig.Children;
                node = (childNodes.ContainsKey(Node.NAME) ? childNodes[Node.NAME] : null);
                if (!(node is YamlScalarNode))
                {
                    throw new InvalidConfigurationException("The filter name is missing or invalid!");
                }
                name = ((YamlScalarNode)node).Value.Trim().ToLower();

                node = (childNodes.ContainsKey(Node.ARGS) ? childNodes[Node.ARGS] : null);
                if (node is YamlSequenceNode)
                {
                    args = readFilterArgs(((YamlSequenceNode)node).Children.GetEnumerator());
                }
                else
                {
                    args = new string[0];
                }
            }
            else
            {
                throw new InvalidConfigurationException("Invalid filter configuration");
            }

            if (!filterMap.ContainsKey(name))
            {
                throw new InvalidConfigurationException("Unknown filter " + name);
            }

            filterCollection.Add(filterMap[name], args);
        }