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

Add() public method

public Add ( Filter filter, string args ) : void
filter Filter
args string
return void
        public void Add(Filter filter, string[] args)
        {
            Add(new KeyValuePair<Filter, string[]>(filter, args));
        }

Same methods

FilterCollection::Add ( string[]>.KeyValuePair filter ) : void

Usage Example

Example #1
0
        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);
        }
All Usage Examples Of CubeIsland.LyricsReloaded.Filters.FilterCollection::Add