-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPropertySettingEntry.cs
More file actions
35 lines (30 loc) · 1.29 KB
/
PropertySettingEntry.cs
File metadata and controls
35 lines (30 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Based on code made by MarC0 / ManlyMarco
// Copyright 2018 GNU General Public License v3.0
using System;
using System.Reflection;
using BepInEx;
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);
}
}