Пример #1
0
        /// <summary>
        /// Initializes the mission and vilidates the mission file with mission XMLSchema file.
        /// </summary>
        /// <param name="missionFilePath">The path to the file with mission.</param>
        /// <param name="teams">The dictionary which will be filled by Teams (should be empty).</param>
        /// <param name="solarSystems">The dictionary which will be filled by SolarSystem. (should be empty).</param>
        public XmlLoader(string missionFilePath, Dictionary<string, Team> teams,
			List<SolarSystem> solarSystems)
        {
            loadedMovements = new Dictionary<string, string>();
            loadedOccupations = new List<Tuple<List<string>, string, int>>();
            loadedFights = new List<Tuple<List<string>, List<string>>>();
            teamRealationDict = new Dictionary<Team, List<Team>>();

            this.teamDict = teams;
            this.solarSystemList = solarSystems;
            xml = new XmlDocument();

            // Checks the mission XmlSchema
            XmlSchemaSet schemas = new XmlSchemaSet();
            schemas.Add("", schemaPath);

            xml.Load(missionFilePath);
            xml.Schemas.Add(schemas);
            string msg = "";
            xml.Validate((o, err) => {
                msg = err.Message;
            });

            if (msg == "") {
                Console.WriteLine("Document is valid");
            } else {
                throw new XmlLoadException("Document invalid: " + msg);
            }
            root = xml.DocumentElement;

            runtimeCtor = new RunTimeCreator();
        }
Пример #2
0
        /// <summary>
        /// Initializes the mission and vilidates the mission file with mission XML Schema file.
        /// </summary>
        /// <param name="missionFilePath">The path to the file with mission.</param>
        /// <param name="teams">The dictionary which will be filled - loaded Teams (should be empty).</param>
        /// <param name="solarSystems">The dictionary which will be filled - loaded SolarSystem. (should be empty).</param>
        /// <exception cref="XmlLoadException">Thrown when document is invalid.</exception>
        public XmlLoader(string missionFilePath, Dictionary <string, Team> teams,
                         List <SolarSystem> solarSystems)
        {
            loadedMovements   = new Dictionary <string, string>();
            loadedOccupations = new List <Tuple <List <string>, string, int> >();
            loadedFights      = new List <Tuple <List <string>, List <string> > >();
            teamRealationDict = new Dictionary <Team, List <Team> >();

            this.teamDict        = teams;
            this.solarSystemList = solarSystems;
            xml = new XmlDocument();

            // Checks the mission XmlSchema
            XmlSchemaSet schemas = new XmlSchemaSet();

            schemas.Add("", schemaPath);

            xml.Load(missionFilePath);
            xml.Schemas.Add(schemas);
            string msg = "";

            xml.Validate((o, err) => {
                msg = err.Message;
            });

            if (msg == "")
            {
                Console.WriteLine("Document is valid");
            }
            else
            {
                throw new XmlLoadException("Document invalid: " + msg);
            }
            root = xml.DocumentElement;

            runtimeCtor = new RunTimeCreator();
        }