コード例 #1
0
        public void Load()
        {
            document        = new XmlDocument();
            dataDirectories = new ArrayList();
            libraryConfig   = new Hashtable();

            if (File.Exists(filename))
            {
                XmlTextReader reader = new XmlTextReader(filename);
                try {
                    document.Load(reader);
                } finally {
                    reader.Close();
                }
            }
            else
            {
                document.AppendChild(document.CreateElement("sunuo-config"));
            }

            XmlElement locations = GetConfiguration("locations");

            foreach (XmlElement dp in locations.GetElementsByTagName("data-path"))
            {
                string path = dp.InnerText;
                if (Directory.Exists(path))
                {
                    dataDirectories.Add(path);
                }
            }

            XmlElement librariesEl = GetConfiguration("libraries");

            foreach (XmlElement el in librariesEl.GetElementsByTagName("library"))
            {
                LibraryConfig lc = new LibraryConfig(el);
                if (lc.Name != null)
                {
                    libraryConfig[lc.Name] = lc;
                }
            }

            XmlElement loginEl = GetConfiguration("login");

            loginConfig = loginEl == null
                                ? new LoginConfig()
                                : new LoginConfig(loginEl);
        }
コード例 #2
0
        private void Load()
        {
            document        = new XmlDocument();
            dataDirectories = new ArrayList();

            if (Exists)
            {
                XmlTextReader reader = new XmlTextReader(filename);
                try {
                    document.Load(reader);
                } finally {
                    reader.Close();
                }
            }
            else
            {
                document.AppendChild(document.CreateElement("sunuo-config"));
            }

            // section "global"
            XmlElement global = GetConfiguration("global");

            if (global != null)
            {
                multiThreading = GetElementBool(global, "multi-threading", false);
            }

            // section "locations"
            XmlElement locations = GetConfiguration("locations");

            foreach (XmlElement dp in locations.GetElementsByTagName("data-path"))
            {
                string path = dp.InnerText;
                if (Directory.Exists(path))
                {
                    dataDirectories.Add(path);
                }
            }

            // section "libraries"
            XmlElement librariesEl = GetConfiguration("libraries");

            foreach (XmlElement el in librariesEl.GetElementsByTagName("library"))
            {
                string name = el.GetAttribute("name");
                if (name == null || name == "")
                {
                    Console.WriteLine("Warning: library element without name attribute");
                    continue;
                }

                name = name.ToLower();

                LibraryConfig libConfig = (LibraryConfig)libraryConfig[name];
                if (libConfig == null)
                {
                    libraryConfig[name] = libConfig = new LibraryConfig(name);
                }

                libConfig.Load(el);
            }

            if (!libraryConfig.ContainsKey("legacy"))
            {
                libraryConfig["legacy"] = new LibraryConfig("legacy");
            }

            // section "login"
            XmlElement loginEl = GetConfiguration("login");

            loginConfig = loginEl == null
                                ? new LoginConfig()
                                : new LoginConfig(loginEl);
        }
コード例 #3
0
ファイル: Config.cs プロジェクト: BackupTheBerlios/sunuo-svn
        private void Load()
        {
            document = new XmlDocument();
            dataDirectories = new ArrayList();

            if (Exists) {
                XmlTextReader reader = new XmlTextReader(filename);
                try {
                    document.Load(reader);
                } finally {
                    reader.Close();
                }
            } else {
                document.AppendChild(document.CreateElement("sunuo-config"));
            }

            // section "global"
            XmlElement global = GetConfiguration("global");
            if (global != null) {
                multiThreading = GetElementBool(global, "multi-threading", false);
            }

            // section "locations"
            XmlElement locations = GetConfiguration("locations");
            foreach (XmlElement dp in locations.GetElementsByTagName("data-path")) {
                string path = dp.InnerText;
                if (Directory.Exists(path))
                    dataDirectories.Add(path);
            }

            // section "libraries"
            XmlElement librariesEl = GetConfiguration("libraries");
            foreach (XmlElement el in librariesEl.GetElementsByTagName("library")) {
                string name = el.GetAttribute("name");
                if (name == null || name == "") {
                    Console.WriteLine("Warning: library element without name attribute");
                    continue;
                }

                name = name.ToLower();

                LibraryConfig libConfig = (LibraryConfig)libraryConfig[name];
                if (libConfig == null)
                    libraryConfig[name] = libConfig = new LibraryConfig(name);

                libConfig.Load(el);
            }

            if (!libraryConfig.ContainsKey("legacy"))
                libraryConfig["legacy"] = new LibraryConfig("legacy");

            // section "login"
            XmlElement loginEl = GetConfiguration("login");
            loginConfig = loginEl == null
                ? new LoginConfig()
                : new LoginConfig(loginEl);
        }
コード例 #4
0
ファイル: Config.cs プロジェクト: BackupTheBerlios/sunuo-svn
        public void Load()
        {
            document = new XmlDocument();
            dataDirectories = new ArrayList();
            libraryConfig = new Hashtable();

            if (File.Exists(filename)) {
                XmlTextReader reader = new XmlTextReader(filename);
                try {
                    document.Load(reader);
                } finally {
                    reader.Close();
                }
            } else {
                document.AppendChild(document.CreateElement("sunuo-config"));
            }

            XmlElement locations = GetConfiguration("locations");
            foreach (XmlElement dp in locations.GetElementsByTagName("data-path")) {
                string path = dp.InnerText;
                if (Directory.Exists(path))
                    dataDirectories.Add(path);
            }

            XmlElement librariesEl = GetConfiguration("libraries");
            foreach (XmlElement el in librariesEl.GetElementsByTagName("library")) {
                LibraryConfig lc = new LibraryConfig(el);
                if (lc.Name != null)
                    libraryConfig[lc.Name] = lc;
            }

            XmlElement loginEl = GetConfiguration("login");
            loginConfig = loginEl == null
                ? new LoginConfig()
                : new LoginConfig(loginEl);
        }