Esempio n. 1
0
        public bool Reload(XmlConfigSync mode)
        {
            string fileName = BuildName(false, true);

            if (fileName == null)
            {
                return(false);
            }
            //- First save changes if asked for
            lock (typeof(XmlConfig)) {
                XmlConfigFile cfgFile = (XmlConfigFile)mXmlDocs [fileName];
                if (XmlDoc != null &&
                    ((mbXmlModifieds.Contains(XmlDoc) == true && mode != XmlConfigSync.Discard) ||
                     mode != XmlConfigSync.ForceSave
                    )
                    )
                {
                    XmlDoc.Save(fileName);
                    mbXmlModifieds.Remove(XmlDoc);
                    return(true);
                }
                //- Reload Xml document
                mbXmlModifieds.Remove(XmlDoc);
                //- Reload the document
                cfgFile.Reload(fileName);
                return(true);
            }
        }
Esempio n. 2
0
        private bool Load()
        {
            string fileName = BuildName(false, true);

            lock (typeof(XmlConfig)) {
                if (fileName == null)
                {
                    fileName = BuildName(true, false);
                    XmlConfigFile xmlCfgFile = new XmlConfigFile(fileName);
                    mXmlDocs.Add(fileName, xmlCfgFile);
                    mbXmlModifieds.Add((System.Xml.XmlDocument)xmlCfgFile);
                    Save(fileName);
                    return(true);
                }
                if (mXmlDocs.Contains(fileName) == false)
                {
                    mXmlDocs.Add(fileName, new XmlConfigFile(fileName));
                }
                else
                {
                    XmlConfigFile cfgFile = (XmlConfigFile)mXmlDocs [fileName];
                    cfgFile.AddRef();
                }
            }
            return(true);
        }
Esempio n. 3
0
        private void Unload()
        {
            string fileName = BuildName(false, true);

            if (fileName == null)
            {
                return;
            }
            lock (typeof(XmlConfig)) {
                if (mXmlDocs.Contains(fileName) == true)
                {
                    XmlConfigFile cfgFile = (XmlConfigFile)mXmlDocs [fileName];
                    cfgFile.Release();
                    if (cfgFile.RefCount == 0)
                    {
                        mXmlDocs.Remove(fileName);
                        mbXmlModifieds.Remove((System.Xml.XmlDocument)cfgFile);
                    }
                }
            }
        }
		private bool Load () {
			string fileName =BuildName (false, true) ;
			lock (typeof (XmlConfig)) {
				if ( fileName == null ) {
					fileName =BuildName (true, false) ;
					XmlConfigFile xmlCfgFile =new XmlConfigFile (fileName) ;
					mXmlDocs.Add (fileName, xmlCfgFile) ;
					mbXmlModifieds.Add ((System.Xml.XmlDocument)xmlCfgFile) ;
					Save (fileName) ;
					return (true) ;
				}
				if ( mXmlDocs.Contains (fileName) == false ) {
					mXmlDocs.Add (fileName, new XmlConfigFile (fileName)) ;
				} else {
					XmlConfigFile cfgFile =(XmlConfigFile)mXmlDocs [fileName] ;
					cfgFile.AddRef () ;
				}
			}
			return (true) ;
		}