コード例 #1
0
ファイル: Configuration.cs プロジェクト: dl1109783/dclog
        public void Load()
        {
            if (!File.Exists(configfile))
            { // File not found, not a tragic error.
                return;
            }

            CfgContainer  container  = null;
            XmlSerializer serializer = new XmlSerializer(typeof(CfgContainer));
            FileStream    stream     = new FileStream(configfile, FileMode.Open);

            try
            {
                container = serializer.Deserialize(stream) as CfgContainer;
                stream.Close();
                if (container == null)
                {
                    throw new ApplicationException("Invalid configuration file.");
                }
                container.Configuration = this;
                this.container          = container;
            }
            catch (Exception ex)
            {
                stream.Close();
                throw ex; // rethrow
            }
        }
コード例 #2
0
ファイル: Configuration.cs プロジェクト: n0la/dclog
        public void Load()
        {
            if (!File.Exists(configfile))
              { // File not found, not a tragic error.
            return;
              }

              CfgContainer container = null;
              XmlSerializer serializer = new XmlSerializer(typeof(CfgContainer));
              FileStream stream = new FileStream(configfile, FileMode.Open);

              try
              {
            container = serializer.Deserialize(stream) as CfgContainer;
            stream.Close();
            if (container == null)
            {
              throw new ApplicationException("Invalid configuration file.");
            }
            container.Configuration = this;
            this.container = container;
              }
              catch (Exception ex)
              {
            stream.Close();
            throw ex; // rethrow
              }
        }