2021-04-27 21:22:48 +10:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
namespace UnityExplorer.UI.Inspectors.CacheObject
|
|
|
|
|
{
|
|
|
|
|
public class CacheField : CacheMember
|
|
|
|
|
{
|
|
|
|
|
public FieldInfo FieldInfo { get; internal set; }
|
|
|
|
|
|
2021-04-28 20:47:48 +10:00
|
|
|
|
public override bool ShouldAutoEvaluate => true;
|
|
|
|
|
|
2021-04-27 21:22:48 +10:00
|
|
|
|
public override void Initialize(ReflectionInspector inspector, Type declaringType, MemberInfo member, Type returnType)
|
|
|
|
|
{
|
|
|
|
|
base.Initialize(inspector, declaringType, member, returnType);
|
|
|
|
|
|
2021-04-28 20:47:48 +10:00
|
|
|
|
// not constant
|
|
|
|
|
CanWrite = !(FieldInfo.IsLiteral && !FieldInfo.IsInitOnly);
|
2021-04-27 21:22:48 +10:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void TryEvaluate()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Value = FieldInfo.GetValue(this.ParentInspector.Target.TryCast(this.DeclaringType));
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
HadException = true;
|
|
|
|
|
LastException = ex;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|