public static IAppConfig UseCommands(this IAppConfig appConfig, Action <Config> configurator = null) { var config = appConfig.EnsureConfig("Commands", () => new Config(appConfig), c => { c.InitDefaults(); }); configurator?.Invoke(config); return(appConfig); }
/// <summary> /// Creates singleton config in <paramref name="module"/> and runs once <paramref name="oneTimeAction"/> /// Returns created or existing config /// </summary> /// <typeparam name="TConfig"></typeparam> /// <param name="appConfig"></param> /// <param name="module"></param> /// <param name="oneTimeAction"></param> /// <returns></returns> public static TConfig EnsureConfig <TConfig>(this IAppConfig appConfig, string module, Action <TConfig> oneTimeAction) where TConfig : new() { return(appConfig.EnsureConfig(module, () => new TConfig(), oneTimeAction)); }