Exemple #1
0
        public XMLHotkeyFile(string filePath)
        {
            FilePath = filePath;

            // Ignores comments and reads file
            XmlReaderSettings readerSettings = new XmlReaderSettings
            {
                IgnoreComments = true
            };
            XmlReader reader = XmlReader.Create(filePath, readerSettings);

            Load(reader);

            // Finds HotkeyType by parsing file name
            HotkeyType = System.IO.Path.GetFileNameWithoutExtension(filePath);
            if (HotkeyType.Contains("_"))
            {
                // Finds index of first "_" character
                int index = HotkeyType.IndexOf("_");
                // Substring(4, index - 4) returns string after CIV5 and excluding text after "_"; ex. CIV5Builds_Inherited_Expansion2 returns Builds
                HotkeyType = HotkeyType.Substring(4, index - 4);
            }
            else
            {
                // Substring(4) returns string after CIV5; ex. CIV5Builds returns Builds
                HotkeyType = HotkeyType.Substring(4);
            }
        }