/// <summary> /// Merge with config source specified. /// </summary> /// <param name="source"></param> /// <param name="dest"></param> protected virtual void Merge(IConfigSection source, IConfigSection dest) { // Get all the sections. foreach (DictionaryEntry entry in source) { // Create new config section. if (entry.Value is IConfigSection) { IConfigSection newDest = null; if (dest.Contains(entry.Key)) { newDest = dest.GetSection(entry.Key.ToString()); } else { newDest = new ConfigSection(entry.Key.ToString()); dest.Add(newDest.Name, newDest); } Merge(entry.Value as IConfigSection, newDest); } else // Just overwrite the keys. { dest[entry.Key] = entry.Value; } } }
public void Configure(IConfig config) { var section = config.GetSection("log4net", throwIfNotFound: false); _config = section; if (_config == null) { return; } var appenders = ConfigureAppenders(section); lock (_createLoggerLock) { var bakAppenders = Appenders; Appenders = appenders; foreach (var logger in _instances.Values) { Configure(logger); } foreach (var appender in bakAppenders) { (appender as IDisposable)?.Dispose(); } var rootConf = _config.GetSection("root"); var rootLogger = new Logger("Root", this); rootLogger.Configure(rootConf, appenders); _root = rootLogger; LogLevel = rootLogger.LogLevel; } }
/// <inheritdoc /> public void Configure(IConfigSection configSection) { _tileSize = configSection.GetFloat("size", 500); _offset = configSection.GetFloat("offset", 50); _moveSensitivity = configSection.GetFloat("sensitivity", 10); var renderModeString = configSection.GetString("render_mode", "scene").ToLower(); _renderMode = renderModeString == "scene" ? RenderMode.Scene : RenderMode.Overview; var viewportConfig = configSection.GetSection("viewport"); var width = viewportConfig != null?viewportConfig.GetFloat("w", 0) : 0; var height = viewportConfig != null?viewportConfig.GetFloat("h", 0) : 0; _viewport = new Rectangle2d(0, 0, width, height); RecalculateOverviewTileCount(); _thresholdDistance = Math.Sqrt(2) * _tileSize; }