Esempio n. 1
0
            public void AddCommand(CommandInfo info)
            {
                //If our path is "", we can't replace, otherwise we just get ""
                string innerPath = info.command;

                if (ourPath != "")
                {
                    innerPath = info.command.Replace(ourPath, "");
                }
                if (innerPath.StartsWith(" "))
                {
                    innerPath = innerPath.Remove(0, 1);
                }
                string[] commandPath = innerPath.Split(new string[1] {
                    " "
                }, StringSplitOptions.RemoveEmptyEntries);
                if (commandPath.Length == 1 || !m_allowSubSets)
                {
                    //Only one command after our path, its ours
                    commands[info.command] = info;
                }
                else
                {
                    //Its down the tree somewhere
                    CommandSet downTheTree;
                    if (!commandsets.TryGetValue(commandPath[0], out downTheTree))
                    {
                        //Need to add it to the tree then
                        downTheTree = new CommandSet();
                        downTheTree.Initialize((ourPath == "" ? "" : ourPath + " ") + commandPath[0], false);
                        commandsets.Add(commandPath[0], downTheTree);
                    }
                    downTheTree.AddCommand(info);
                }
            }
            public ICommandSet Create(IServiceProvider serviceProvider, CommandOptions commandOptions)
            {
                var commandSet = new CommandSet <TAppSession>();

                commandSet.Initialize(serviceProvider, CommandType, commandOptions);
                return(commandSet);
            }
Esempio n. 3
0
            public void AddCommand(CommandInfo info)
            {
                if (!_ConsoleIsCaseSensitive) //Force to all lowercase
                {
                    info.command = info.command.ToLower();
                }

                //If our path is "", we can't replace, otherwise we just get ""
                string innerPath = info.command;

                if (ourPath != "")
                {
                    innerPath = info.command.Replace(ourPath, "");
                }
                if (innerPath.StartsWith(" "))
                {
                    innerPath = innerPath.Remove(0, 1);
                }
                string[] commandPath = innerPath.Split(new string[1] {
                    " "
                }, StringSplitOptions.RemoveEmptyEntries);
                if (commandPath.Length == 1 || !m_allowSubSets)
                {
                    //Only one command after our path, its ours

                    //Add commands together if there is more than one event hooked to one command
                    if (commands.ContainsKey(info.command))
                    {
                        commands[info.command].fn.AddRange(info.fn);
                    }
                    else
                    {
                        commands[info.command] = info;
                    }
                }
                else
                {
                    //Its down the tree somewhere
                    CommandSet downTheTree;
                    if (!commandsets.TryGetValue(commandPath[0], out downTheTree))
                    {
                        //Need to add it to the tree then
                        downTheTree = new CommandSet();
                        downTheTree.Initialize((ourPath == "" ? "" : ourPath + " ") + commandPath[0], false);
                        commandsets.Add(commandPath[0], downTheTree);
                    }
                    downTheTree.AddCommand(info);
                }
            }
            public void AddCommand(CommandInfo info)
            {
                if (!_ConsoleIsCaseSensitive) //Force to all lowercase
                {
                    info.command = info.command.ToLower();
                }

                //If our path is "", we can't replace, otherwise we just get ""
                string innerPath = info.command;
                if (ourPath != "")
                {
                    innerPath = info.command.Replace(ourPath, "");
                }
                if (innerPath.StartsWith(" "))
                {
                    innerPath = innerPath.Remove(0, 1);
                }
                string[] commandPath = innerPath.Split(new string[1] {" "}, StringSplitOptions.RemoveEmptyEntries);
                if (commandPath.Length == 1 || !m_allowSubSets)
                {
                    //Only one command after our path, its ours

                    //Add commands together if there is more than one event hooked to one command
                    if (!commands.ContainsKey(info.command))
                    {
                        commands[info.command] = info;
                    }
                }
                else
                {
                    //Its down the tree somewhere
                    CommandSet downTheTree;
                    if (!commandsets.TryGetValue(commandPath[0], out downTheTree))
                    {
                        //Need to add it to the tree then
                        downTheTree = new CommandSet();
                        downTheTree.Initialize((ourPath == "" ? "" : ourPath + " ") + commandPath[0], false);
                        commandsets.Add(commandPath[0], downTheTree);
                    }
                    downTheTree.AddCommand(info);
                }
            }
Esempio n. 5
0
 public void AddCommand (CommandInfo info)
 {
     //If our path is "", we can't replace, otherwise we just get ""
     string innerPath = info.command;
     if (ourPath != "")
         innerPath = info.command.Replace (ourPath, "");
     if (innerPath.StartsWith (" "))
         innerPath = innerPath.Remove (0, 1);
     string[] commandPath = innerPath.Split (new string[1]{" "}, StringSplitOptions.RemoveEmptyEntries);
     if (commandPath.Length == 1 || !m_allowSubSets)
     {
         //Only one command after our path, its ours
         commands[info.command] = info;
     }
     else
     {
         //Its down the tree somewhere
         CommandSet downTheTree;
         if (!commandsets.TryGetValue (commandPath[0], out downTheTree))
         {
             //Need to add it to the tree then
             downTheTree = new CommandSet ();
             downTheTree.Initialize ((ourPath == "" ? "" : ourPath + " ") + commandPath[0], false);
             commandsets.Add (commandPath[0], downTheTree);
         }
         downTheTree.AddCommand (info);
     }
 }