Пример #1
0
        private void ReadModuleList()
        {
            string fileName = ModulesFile;

            XmlDocument xmlDoc = new XmlDocument();
            XmlReader xmlReader = XmlReader.Create(fileName, xmlReaderSettings);
            xmlDoc.Load(xmlReader);
            XmlElement root = xmlDoc.FirstChild as XmlElement;

            if (!root.Name.Equals("Modules"))
                throw new Exception(fileName + " doesn't start with Modules");

            foreach (XmlElement xmlModule in root.ChildNodes)
            {
                if (!xmlModule.Name.Equals("Module"))
                    throw new Exception("child is not a Module in " + fileName);

                string name = xmlModule.GetAttribute("FriendlyName");
                string appName = xmlModule.GetAttribute("AppName");
                string binaryName = xmlModule.GetAttribute("BinaryName");
                string workingDir = xmlModule.GetAttribute("WorkingDir");
                string autoStartStr = xmlModule.GetAttribute("AutoStart");
                string backgroundStr = xmlModule.GetAttribute("Background");

                string version = xmlModule.GetAttribute("Version");

                string argStr = xmlModule.GetAttribute("ModuleArgStr");

                if (!argStr.Equals(""))
                    throw new Exception("module arguments are being supplied in old-fashioned way");

                //string[] words = argStr.Split(" ");

                if (workingDir.Equals(""))
                    workingDir = null;

                bool autoStart = (autoStartStr.Equals("1")) ? true : false;

                bool background = (backgroundStr.Equals("1")) ? true : false;

                string[] words = ReadModuleArguments(xmlModule);

                ModuleInfo moduleInfo = new ModuleInfo(name, appName, binaryName, workingDir, autoStart, words);
                moduleInfo.Background = background;

                // now lets set the version. if the version is  missing in the xml file set it as UnknownHomeOSUpdateVersionValue(0.0.0.0)
                if(string.IsNullOrWhiteSpace(version))
                    moduleInfo.SetDesiredVersion(Constants.UnknownHomeOSUpdateVersionValue);
                else
                    moduleInfo.SetDesiredVersion(version);
                   
                //now let's attach the manifest
                Manifest manifest = ReadManifest(xmlModule);
                moduleInfo.SetManifest(manifest);

                AddModule(moduleInfo, false);

            }

            xmlReader.Close();
        }