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."); } }
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."); } }