public static void RegisterSetting <T>(this CommandService commands) where T : class, IGroupSetting, new() { string group = typeof(T).Name.ToLower().Replace("Settings", string.Empty); commands.CreateModuleAsync("Settings", module => { foreach (var property in CacheExtensions.GetPrimitives <T>()) { module.CreateCommand <T>("Updated key.", group, property.Name, property, (p, s, args) => p.SetValue(s, args.First())); } foreach (var property in CacheExtensions.GetLists <T>()) { string name = property.Name; module.CreateCommand <T>("Cleared key.", group, $"clear {name}", property, (p, s, args) => (p.GetValue(property) as IList)?.Clear()); module.CreateCommand <T>("Added key.", group, name, property, (p, s, args) => { var list = p.GetValue(property) as IList; foreach (var item in args) { list?.Add(item); } }); } }); }