Category5.XmlSettingsFile.LoadConfiguration C# (CSharp) Method

LoadConfiguration() public static method

public static LoadConfiguration ( Microsoft.Xna.Framework.Content.ContentManager content ) : void
content Microsoft.Xna.Framework.Content.ContentManager
return void
        public static void LoadConfiguration(ContentManager content)
        {
            XmlTextReader reader;

            //Allocate memory for objects
            megaTileTypes = new List<MegaTileType>();
            levelConfigs = new List<LevelConfig>();
            victimTypes = new List<VictimConfig>();

            //Try to open the configuration file
            reader = new XmlTextReader(CONFIG_FILE);

            //Make sure the file opened successfully
            try
            {
                reader.Read();
            }
            catch (Exception e)
            {
                throw new ApplicationException("XmlSettingsFile.LoadConfiguration: Error loading configuration file '" + CONFIG_FILE + "': " +
                        e.Message);
            }

            //Loop through and look for elements
            do
            {
                reader.MoveToContent();

                string tempString;

                //Check for an element
                if (reader.NodeType == XmlNodeType.Element)
                {
                    tempString = reader.Name.ToUpper();
                    //Check for definition of a mega tile type
                    if (tempString == "MEGATILETYPE")
                    {
                        ReadMegaTileType(reader, content);
                    }
                    //Check for definition of a level
                    else if (tempString == "LEVEL")
                    {
                        ReadLevel(reader, content);
                    }
                    //Check for definition of a victim
                    else if (tempString == "VICTIMTYPE")
                    {
                        ReadVictimType(reader, content);
                    }
                    //Check for definition of main element
                    else if (tempString == "TORNADOGAMECONFIG")
                    {

                    }
                    else
                    {
                        throw new ApplicationException("Invalid Element '" + tempString + "' on line " + reader.LineNumber);
                    }
                }
            } while (reader.Read()) ;
        }