Handle boxing value types to Il2CppSystem.Object, some cleanups

This commit is contained in:
Sinai
2021-05-06 06:36:39 +10:00
parent e70a1e96da
commit 6c7acf7690
11 changed files with 307 additions and 269 deletions

View File

@ -43,7 +43,7 @@ namespace UnityExplorer.UI.CacheObject
{
try
{
FieldInfo.SetValue(FieldInfo.IsStatic ? null : Owner.Target.TryCast(this.DeclaringType), value);
FieldInfo.SetValue(DeclaringInstance, value);
}
catch (Exception ex)
{

View File

@ -82,7 +82,7 @@ namespace UnityExplorer.UI.CacheObject
}
}
public override void SetUserValue(object value)
public override void TrySetUserValue(object value)
{
throw new NotImplementedException("TODO");
}

View File

@ -31,7 +31,7 @@ namespace UnityExplorer.UI.CacheObject
listCell.Image.color = ListIndex % 2 == 0 ? CacheListEntryCell.EvenColor : CacheListEntryCell.OddColor;
}
public override void SetUserValue(object value)
public override void TrySetUserValue(object value)
{
throw new NotImplementedException("TODO");
}

View File

@ -4,6 +4,7 @@ using System.Linq;
using System.Reflection;
using System.Text;
using UnityEngine;
using UnityExplorer.Core.Runtime;
using UnityExplorer.UI.CacheObject.Views;
using UnityExplorer.UI.Inspectors;
using UnityExplorer.UI.ObjectPool;
@ -74,10 +75,11 @@ namespace UnityExplorer.UI.CacheObject
SetValueFromSource(TryEvaluate());
}
public override void SetUserValue(object value)
public override void TrySetUserValue(object value)
{
// TODO unbox string, cast, etc
if (State == ValueState.String)
ReflectionProvider.Instance.BoxStringToType(ref value, FallbackType);
TrySetValue(value);
Evaluate();

View File

@ -95,7 +95,13 @@ namespace UnityExplorer.UI.CacheObject
// Updating and applying values
public abstract void SetUserValue(object value);
public void SetUserValue(object value)
{
value = value.TryCast(FallbackType);
TrySetUserValue(value);
}
public abstract void TrySetUserValue(object value);
public virtual void SetValueFromSource(object value)
{

View File

@ -52,12 +52,11 @@ namespace UnityExplorer.UI.CacheObject
try
{
bool _static = PropertyInfo.GetAccessors(true)[0].IsStatic;
var target = _static ? null : Owner.Target.TryCast(DeclaringType);
if (HasArguments)
PropertyInfo.SetValue(target, value, Evaluator.TryParseArguments());
PropertyInfo.SetValue(DeclaringInstance, value, Evaluator.TryParseArguments());
else
PropertyInfo.SetValue(target, value, null);
PropertyInfo.SetValue(DeclaringInstance, value, null);
}
catch (Exception ex)
{