Пример #1
0
        /// <summary>
        /// Loads the object from the Data.ConfigNode structure in the previously supplied file
        /// </summary>
        /// <returns>Succes of Load</returns>
        public Boolean Load()
        {
            Log.dbg("Loading Data.ConfigNode");

            Boolean blnReturn = false;

            try
            {
                if (FileExists)
                {
                    //Load the file into a config node
                    this.configNode.Load();
                    //plug it in to the object
                    ConfigNode.LoadObjectFromConfig(this, this.configNode.Node);
                    blnReturn = true;
                }
                else
                {
                    Log.warn("File could not be found to load({0})", this.configNode.Path);
                    blnReturn = false;
                }
            }
            catch (Exception ex)
            {
                Log.error(ex, "Failed to Load Data.ConfigNode from file({0})", this.configNode.Path);
                string emergencyFilename = String.Format("{0}.err-{1}", this.configNode.Path, string.Format("ddMMyyyy-HHmmss", DateTime.Now));
                Log.warn("Storing old config - {0}", emergencyFilename);
                System.IO.File.Copy(this.configNode.Path, emergencyFilename, true);
                blnReturn = false;
            }
            return(blnReturn);
        }