コード例 #1
0
        public static TConfig FromPreferences(ExIni.IniFile prefs)
        {
            TConfig config = (TConfig)Activator.CreateInstance(typeof(TConfig));

            config.Preferences = prefs;
            config.LoadPreferences();
            return(config);
        }
コード例 #2
0
 public SectionLoader(string section, ExIni.IniFile pref)
 {
     _section = section;
     _preferences = pref;
     if (!_defaultValues.TryGetValue(_section, out _defaults))
     {
         _defaultValues[_section] = _defaults = new Dictionary<string, string>();
     }
 }
コード例 #3
0
        public static void Init(string path, ExIni.IniFile pref)
        {
            try
            {
                var v = pref["Debug"]["VerbosityLevel"];
                Verbosity = CoreUtil.ChangeType <int>(v.Value);
                var c = pref["Debug"]["ColorConsoleOutput"];
                ColorOutput = CoreUtil.ChangeType <bool>(c.Value);
            }
            catch (Exception)
            {
                // ignore exceptions
            }

            if (!File.Exists(path))
            {
                // assume sybaris
                //Log("Data path does not exist, assume sybaris");
                //Log("The current path is " + path);
                path = Path.Combine(path, @"../Config/");
            }
            _dataPath = path;
            try
            {
                if (!Directory.Exists(LogFolder))
                {
                    Directory.CreateDirectory(LogFolder);
                }
                if (File.Exists(LogFile))
                {
                    var bak = Path.Combine(LogFolder, _logBackupfileName);
                    if (File.Exists(bak))
                    {
                        File.Delete(bak);
                    }
                    File.Move(LogFile, bak);
                    Log($"Created Backup logfile", Level.Debug);
                }
            }
            catch (Exception e)
            {
                _logFileStream = null;
                LogError($"Failed initialization of Logfile {LogFile}", e);
            }
        }
コード例 #4
0
 public static void StartLoadingConfig(ExIni.IniFile pref)
 {
     _preferences = pref;
     LoadConfig();
 }