mirror of
https://github.com/BepInEx/BepInEx.ConfigurationManager.git
synced 2026-11-22 04:29:24 -10:00
Code was refactored to use a shared project. Based on source from HC.BepInEx.ConfigurationManager.Il2Cpp.CoreCLR-18.0_beta2_20230821
37 lines
1.3 KiB
C#
37 lines
1.3 KiB
C#
using System;
|
|
using System.Reflection;
|
|
using BepInEx;
|
|
|
|
#if IL2CPP
|
|
using BaseUnityPlugin = BepInEx.PluginInfo;
|
|
#endif
|
|
|
|
namespace ConfigurationManager
|
|
{
|
|
internal class PropertySettingEntry : SettingEntryBase
|
|
{
|
|
private Type _settingType;
|
|
|
|
public PropertySettingEntry(object instance, PropertyInfo settingProp, BaseUnityPlugin pluginInstance)
|
|
{
|
|
SetFromAttributes(settingProp.GetCustomAttributes(false), pluginInstance);
|
|
if (Browsable == null) Browsable = settingProp.CanRead && settingProp.CanWrite;
|
|
ReadOnly = settingProp.CanWrite;
|
|
Property = settingProp;
|
|
Instance = instance;
|
|
}
|
|
|
|
public object Instance { get; internal set; }
|
|
public PropertyInfo Property { get; internal set; }
|
|
|
|
public override string DispName
|
|
{
|
|
get => string.IsNullOrEmpty(base.DispName) ? Property.Name : base.DispName;
|
|
protected internal set => base.DispName = value;
|
|
}
|
|
public override Type SettingType => _settingType ?? (_settingType = Property.PropertyType);
|
|
public override object Get() => Property.GetValue(Instance, null);
|
|
protected override void SetValue(object newVal) => Property.SetValue(Instance, newVal, null);
|
|
}
|
|
}
|