Tanoda
PropertyCacheEntry.cs
Go to the documentation of this file.
1
using
System;
2
using
System.Reflection;
3
4
namespace
RuntimeUnityEditor.Core.Inspector.Entries
5
{
6
public
class
PropertyCacheEntry
:
CacheEntryBase
7
{
8
public
PropertyCacheEntry
(
object
ins,
PropertyInfo
p) : this(ins, p, null) { }
9
public
PropertyCacheEntry
(
object
ins,
PropertyInfo
p,
ICacheEntry
parent) : base(
FieldCacheEntry
.GetMemberName(ins, p))
10
{
11
if
(p ==
null
)
12
throw
new
ArgumentNullException();
13
14
_instance = ins;
15
PropertyInfo
= p;
16
_parent = parent;
17
}
18
19
public
PropertyInfo
PropertyInfo
{
get
;
private
set
; }
20
private
readonly
object
_instance;
21
private
readonly
ICacheEntry
_parent;
22
23
public
override
object
GetValueToCache
()
24
{
25
if
(!
PropertyInfo
.CanRead)
26
return
"WRITE ONLY"
;
27
28
try
29
{
30
return
PropertyInfo
.GetValue(_instance,
null
);
31
}
32
catch
(TargetInvocationException ex)
33
{
34
return
ex.InnerException ?? ex;
35
}
36
catch
(Exception ex)
37
{
38
return
ex;
39
}
40
}
41
42
protected
override
bool
OnSetValue
(
object
newValue)
43
{
44
if
(
PropertyInfo
.CanWrite)
45
{
46
PropertyInfo
.SetValue(_instance, newValue,
null
);
47
// Needed for structs to propagate changes back to the original field/prop
48
if
(_parent !=
null
&& _parent.CanSetValue()) _parent.SetValue(_instance);
49
return
true
;
50
}
51
return
false
;
52
}
53
54
public
override
Type
Type
()
55
{
56
return
PropertyInfo
.PropertyType;
57
}
58
59
public
override
bool
CanSetValue
()
60
{
61
return
PropertyInfo
.CanWrite && (_parent ==
null
|| _parent.CanSetValue());
62
}
63
}
64
}
RuntimeUnityEditor.Core.Inspector.Entries.CacheEntryBase
Definition:
CacheEntryBase.cs:7
RuntimeUnityEditor.Core.Inspector.Entries.FieldCacheEntry
Definition:
FieldCacheEntry.cs:7
RuntimeUnityEditor.Core.Inspector.Entries.PropertyCacheEntry
Definition:
PropertyCacheEntry.cs:7
RuntimeUnityEditor.Core.Inspector.Entries.PropertyCacheEntry.PropertyCacheEntry
PropertyCacheEntry(object ins, PropertyInfo p, ICacheEntry parent)
Definition:
PropertyCacheEntry.cs:9
RuntimeUnityEditor.Core.Inspector.Entries.PropertyCacheEntry.PropertyInfo
PropertyInfo PropertyInfo
Definition:
PropertyCacheEntry.cs:19
RuntimeUnityEditor.Core.Inspector.Entries.PropertyCacheEntry.Type
override Type Type()
Definition:
PropertyCacheEntry.cs:54
RuntimeUnityEditor.Core.Inspector.Entries.PropertyCacheEntry.PropertyCacheEntry
PropertyCacheEntry(object ins, PropertyInfo p)
Definition:
PropertyCacheEntry.cs:8
RuntimeUnityEditor.Core.Inspector.Entries.PropertyCacheEntry.GetValueToCache
override object GetValueToCache()
Definition:
PropertyCacheEntry.cs:23
RuntimeUnityEditor.Core.Inspector.Entries.PropertyCacheEntry.CanSetValue
override bool CanSetValue()
Definition:
PropertyCacheEntry.cs:59
RuntimeUnityEditor.Core.Inspector.Entries.PropertyCacheEntry.OnSetValue
override bool OnSetValue(object newValue)
Definition:
PropertyCacheEntry.cs:42
RuntimeUnityEditor.Core.Inspector.Entries.ICacheEntry
Definition:
ICacheEntry.cs:6
RuntimeUnityEditor.Core.Inspector.Entries
Definition:
CacheEntryBase.cs:5
Source
Assets
Scripts
BepinRUE
Inspector
Entries
Contents
PropertyCacheEntry.cs
Generated by
1.9.3