protected ConfigBase(IKeyValueManager keyValues, IConfiguration?appSettings) { KeyValues = keyValues; Configuration = appSettings; var hasChange = false; var props = this.GetType().GetProperties(); foreach (var p in props) { if (p.IsDefined(typeof(NotMappedAttribute), false)) { continue; } if (p.SetMethod == null) { continue; } var defaultValue = p.GetValue(this); if (defaultValue != null) { var dbValue = KeyValues.GetOrAdd(p.Name, defaultValue.ToString()); if (!defaultValue.Equals(dbValue)) { p.SetValue(this, Convert.ChangeType(dbValue, p.PropertyType)); hasChange = true; } } } if (hasChange) { KeyValues.SaveAll(); } }
public static int HttpPostsMinimumIntervalMilliseconds(this IKeyValueManager keyValues, int defaultValueIfNotExist = 300) { return(keyValues.GetOrAdd(nameof(HttpPostsMinimumIntervalMilliseconds), defaultValueIfNotExist)); }
public Config(IKeyValueManager keyValues, IConfiguration?appSettings) : base(keyValues, appSettings) { }
public static int LogOperationAsRepeatedIfSameWithinSeconds(this IKeyValueManager keyValues, int defaultValueIfNotExist = 60) { return(keyValues.GetOrAdd(nameof(LogOperationAsRepeatedIfSameWithinSeconds), defaultValueIfNotExist)); }
public static int PrincipalCacheDataBagWillExpireAfterSeconds(this IKeyValueManager keyValues, int defaultValueIfNotExist = 1800) { return(keyValues.GetOrAdd(nameof(PrincipalCacheDataBagWillExpireAfterSeconds), defaultValueIfNotExist)); }