コード例 #1
0
 public Config(string path)
 {
     if (String.IsNullOrEmpty(path))
     {
         throw new ArgumentNullException("path");
     }
     DatabaseSetting      = new DatabaseSetting();
     LdapSetting          = new LdapSetting();
     AuthListentIp        = "127.0.0.1";
     AccountListentIp     = "127.0.0.1";
     AcctPort             = 1813;
     AuthPort             = 1812;
     EnableAccount        = true;
     EnableAuthentication = true;
     Log.Debug("try to find setting file's path " + path);
     _filePath = Path.Combine(path, FileName);
     Log.Debug("try to find setting file " + _filePath);
     if (File.Exists(_filePath))
     {
         Log.Debug("Read setting from filePath:" + _filePath);
         var        mySerializer = new DataContractSerializer(typeof(Config));
         FileStream stream       = File.OpenRead(_filePath);
         try
         {
             var config = (Config)mySerializer.ReadObject(stream);
             InitBy(config);
         }
         finally
         {
             stream.Close();
         }
     }
     else
     {
         Log.Debug("setting file not find, use default value.");
     }
 }
コード例 #2
0
ファイル: Config.cs プロジェクト: helioelias/tinyradius4net
 public Config(string path)
 {
     if (String.IsNullOrEmpty(path))
     {
         throw new ArgumentNullException("path");
     }
     DatabaseSetting = new DatabaseSetting();
     LdapSetting = new LdapSetting();
     AuthListentIp = "127.0.0.1";
     AccountListentIp = "127.0.0.1";
     AcctPort = 1813;
     AuthPort = 1812;
     EnableAccount = true;
     EnableAuthentication = true;
     Log.Debug("try to find setting file's path " + path);
     _filePath = Path.Combine(path, FileName);
     Log.Debug("try to find setting file " + _filePath);
     if (File.Exists(_filePath))
     {
         Log.Debug("Read setting from filePath:" + _filePath);
         var mySerializer = new DataContractSerializer(typeof (Config));
         FileStream stream = File.OpenRead(_filePath);
         try
         {
             var config = (Config) mySerializer.ReadObject(stream);
             InitBy(config);
         }
         finally
         {
             stream.Close();
         }
     }
     else
     {
         Log.Debug("setting file not find, use default value.");
     }
 }