コード例 #1
0
        /// <summary>
        /// Loads the specified path.
        /// </summary>
        /// <param name="path">The path.</param>
        public void Load(string path)
        {
            try
            {
                CommandsMap.Clear();
                document.RemoveAll();
                document.Load(path);

                var root         = document.SelectSingleNode("/Commands");
                var commandNodes = root.ChildNodes;

                foreach (XmlNode commandNode in commandNodes)
                {
                    var name    = commandNode.Attributes["name"].Value;
                    var content = commandNode.Attributes["content"].Value;
                    var regex   = new Regex(commandNode.Attributes[2].Value);
                    var type    = EnumExtensions
                                  .GetValueFromDescription <Command.TypeE>(commandNode.Attributes["type"].Value);
                    var description = commandNode.FirstChild.InnerText;

                    CommandsMap.Add(Command.CreateCommand(name, content, description, regex, type));
                }
                FilePath = path;
            }
            catch
            {
                Console.Error.WriteLine("Could not load command list into memory");
                MissingFileManager.CreateCommandsFile();
                Load(MissingFileManager.DEFAULT_COMMANDS_PATH);
            }
        }
コード例 #2
0
 /// <summary>
 /// Adds the command.
 /// </summary>
 /// <param name="command">The command.</param>
 public void AddCommand(Command command)
 {
     CommandsMap.Add(command);
 }