예제 #1
0
        public static DatabaseConfiguration Read(string file)
        {
            DatabaseConfiguration config = new DatabaseConfiguration ();
            XmlDocument doc = new XmlDocument ();
            doc.Load (file);

            XmlElement disabledElem = (XmlElement) doc.DocumentElement.SelectSingleNode ("DisabledAddins");
            if (disabledElem != null) {
                // For back compatibility
                foreach (XmlElement elem in disabledElem.SelectNodes ("Addin"))
                    config.SetEnabled (elem.InnerText, false, true);
                return config;
            }

            XmlElement statusElem = (XmlElement) doc.DocumentElement.SelectSingleNode ("AddinStatus");
            if (statusElem != null) {
                foreach (XmlElement elem in statusElem.SelectNodes ("Addin")) {
                    AddinStatus status = new AddinStatus (elem.GetAttribute ("id"));
                    string senabled = elem.GetAttribute ("enabled");
                    status.Enabled = senabled.Length == 0 || senabled == "True";
                    status.Uninstalled = elem.GetAttribute ("uninstalled") == "True";
                    config.addinStatus [status.AddinId] = status;
                    foreach (XmlElement fileElem in elem.SelectNodes ("File")) {
                        if (status.Files == null)
                            status.Files = new List<string> ();
                        status.Files.Add (fileElem.InnerText);
                    }
                }
            }
            return config;
        }
		public static DatabaseConfiguration Read (string file)
		{
			DatabaseConfiguration config = new DatabaseConfiguration ();
			
			StreamReader s = new StreamReader (file);
			using (s) {
				XmlTextReader tr = new XmlTextReader (s);
				tr.MoveToContent ();
				tr.ReadStartElement ("Configuration");
				tr.MoveToContent ();
				tr.ReadStartElement ("DisabledAddins");
				tr.MoveToContent ();
				if (!tr.IsEmptyElement) {
					while (tr.NodeType != XmlNodeType.EndElement) {
						if (tr.NodeType == XmlNodeType.Element) {
							if (tr.LocalName == "Addin")
								config.DisabledAddins.Add (tr.ReadElementString ());
						}
						else
							tr.Skip ();
						tr.MoveToContent ();
					}
				}
			}
			return config;
		}
예제 #3
0
        public static DatabaseConfiguration Read(string file)
        {
            DatabaseConfiguration config = new DatabaseConfiguration ();

            StreamReader s = new StreamReader (file);
            using (s) {
                XmlTextReader tr = new XmlTextReader (s);
                tr.MoveToContent ();
                if (tr.IsEmptyElement)
                    return config;

                tr.ReadStartElement ("Configuration");
                tr.MoveToContent ();

                while (tr.NodeType != XmlNodeType.EndElement) {

                    if (tr.NodeType != XmlNodeType.Element || tr.IsEmptyElement) {
                        tr.Skip ();
                    }
                    else if (tr.LocalName == "DisabledAddins") {
                        // For back compatibility
                        tr.ReadStartElement ();
                        tr.MoveToContent ();
                        while (tr.NodeType != XmlNodeType.EndElement) {
                            if (tr.NodeType == XmlNodeType.Element && tr.LocalName == "Addin")
                                config.addinStatus [tr.ReadElementString ()] = null;
                            else
                                tr.Skip ();
                            tr.MoveToContent ();
                        }
                        tr.ReadEndElement ();
                    }
                    else if (tr.LocalName == "AddinStatus") {
                        tr.ReadStartElement ();
                        tr.MoveToContent ();
                        while (tr.NodeType != XmlNodeType.EndElement) {
                            if (tr.NodeType == XmlNodeType.Element && tr.LocalName == "Addin") {
                                string aid = tr.GetAttribute ("id");
                                string senabled = tr.GetAttribute ("enabled");
                                if (senabled.Length == 0 || senabled == "True")
                                    config.addinStatus [aid] = config;
                                else
                                    config.addinStatus [aid] = null;
                            }
                            tr.Skip ();
                            tr.MoveToContent ();
                        }
                        tr.ReadEndElement ();
                    }
                    tr.MoveToContent ();
                }
            }
            return config;
        }
예제 #4
0
 public void ResetConfiguration()
 {
     if (File.Exists (ConfigFile))
         File.Delete (ConfigFile);
     config = null;
     ResetCachedData ();
 }