mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 18:23:04 +08:00
Apply code quality improvements
This commit is contained in:
parent
f84705ab96
commit
5347e7c4a2
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
@ -36,11 +35,13 @@ namespace osu.Game.Configuration
|
|||||||
{
|
{
|
||||||
public static IEnumerable<Drawable> CreateSettingsControls(this object obj)
|
public static IEnumerable<Drawable> CreateSettingsControls(this object obj)
|
||||||
{
|
{
|
||||||
var configProperties = obj.GetType().GetProperties(BindingFlags.GetProperty | BindingFlags.Public | BindingFlags.Instance).Where(p => p.GetCustomAttribute<SettingSourceAttribute>(true) != null);
|
foreach (var property in obj.GetType().GetProperties(BindingFlags.GetProperty | BindingFlags.Public | BindingFlags.Instance))
|
||||||
|
|
||||||
foreach (var property in configProperties)
|
|
||||||
{
|
{
|
||||||
var attr = property.GetCustomAttribute<SettingSourceAttribute>(true);
|
var attr = property.GetCustomAttribute<SettingSourceAttribute>(true);
|
||||||
|
|
||||||
|
if (attr == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
var prop = property.GetValue(obj);
|
var prop = property.GetValue(obj);
|
||||||
|
|
||||||
switch (prop)
|
switch (prop)
|
||||||
@ -91,9 +92,7 @@ namespace osu.Game.Configuration
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case IBindable bindable:
|
case IBindable bindable:
|
||||||
|
|
||||||
var dropdownType = typeof(SettingsEnumDropdown<>).MakeGenericType(bindable.GetType().GetGenericArguments()[0]);
|
var dropdownType = typeof(SettingsEnumDropdown<>).MakeGenericType(bindable.GetType().GetGenericArguments()[0]);
|
||||||
|
|
||||||
var dropdown = (Drawable)Activator.CreateInstance(dropdownType);
|
var dropdown = (Drawable)Activator.CreateInstance(dropdownType);
|
||||||
|
|
||||||
dropdown.GetType().GetProperty(nameof(IHasCurrentValue<object>.Current))?.SetValue(dropdown, obj);
|
dropdown.GetType().GetProperty(nameof(IHasCurrentValue<object>.Current))?.SetValue(dropdown, obj);
|
||||||
|
Loading…
Reference in New Issue
Block a user