mirror of
https://github.com/sinai-dev/UnityExplorer.git
synced 2025-06-16 22:27:45 +08:00
67 lines
2.0 KiB
C#
67 lines
2.0 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using System.Text;
|
|
|
|
namespace UnityExplorer.Core.Runtime
|
|
{
|
|
public abstract class ReflectionProvider
|
|
{
|
|
public static ReflectionProvider Instance;
|
|
|
|
public ReflectionProvider()
|
|
{
|
|
Instance = this;
|
|
}
|
|
|
|
public abstract Type GetActualType(object obj);
|
|
|
|
public abstract Type GetDeobfuscatedType(Type type);
|
|
|
|
public abstract object Cast(object obj, Type castTo);
|
|
|
|
public abstract T TryCast<T>(object obj);
|
|
|
|
public abstract bool IsAssignableFrom(Type toAssignTo, Type toAssignFrom);
|
|
|
|
//public abstract bool IsReflectionSupported(Type type);
|
|
|
|
public abstract string ProcessTypeFullNameInString(Type type, string theString, ref string typeName);
|
|
|
|
public abstract bool LoadModule(string module);
|
|
|
|
public virtual bool IsString(object obj) => obj is string;
|
|
|
|
public abstract void BoxStringToType(ref object _string, Type castTo);
|
|
|
|
public virtual string UnboxString(object value) => (string)value;
|
|
|
|
public virtual IDictionary EnumerateDictionary(object value, Type typeOfKeys, Type typeOfValues)
|
|
=> null;
|
|
|
|
public virtual IEnumerable EnumerateEnumerable(object value)
|
|
=> null;
|
|
|
|
public virtual void FindSingleton(string[] s_instanceNames, Type type, BindingFlags flags, List<object> instances)
|
|
{
|
|
// Look for a typical Instance backing field.
|
|
FieldInfo fi;
|
|
foreach (var name in s_instanceNames)
|
|
{
|
|
fi = type.GetField(name, flags);
|
|
if (fi != null)
|
|
{
|
|
var instance = fi.GetValue(null);
|
|
if (instance != null)
|
|
{
|
|
instances.Add(instance);
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|