예제 #1
0
        /// <summary>
        /// Loads the project from the specified file.
        /// </summary>
        public void Load(string fileName)
        {
            SetToDefault();
            FileName = fileName;

            XmlDocument xmlDoc = new();

            xmlDoc.Load(fileName);

            XmlElement rootElem = xmlDoc.DocumentElement;

            Version     = ProjectVersion.Parse(rootElem.GetChildAsString("ProjectVersion"));
            Description = rootElem.GetChildAsString("Description");

            // load instances
            XmlNode instancesNode = rootElem.SelectSingleNode("Instances");

            if (instancesNode != null)
            {
                XmlNodeList instanceNodes = instancesNode.SelectNodes("Instance");
                string      projectDir    = ProjectDir;

                foreach (XmlNode instanceNode in instanceNodes)
                {
                    ProjectInstance instance = new();
                    instance.LoadFromXml(instanceNode);
                    instance.InstanceDir = Path.Combine(projectDir, "Instances", instance.Name);
                    Instances.Add(instance);

                    // fix instance ID
                    if (instance.ID <= 0)
                    {
                        instance.ID = Instances.Count;
                    }
                }
            }
        }