mirror of
https://github.com/sinai-dev/UnityExplorer.git
synced 2025-06-16 22:27:45 +08:00
Remove formatting from ToStringUtility
This commit is contained in:
parent
9f0f7f9b57
commit
4f0553d293
@ -13,7 +13,6 @@ namespace UnityExplorer
|
|||||||
public static class ToStringUtility
|
public static class ToStringUtility
|
||||||
{
|
{
|
||||||
internal static Dictionary<string, MethodInfo> toStringMethods = new Dictionary<string, MethodInfo>();
|
internal static Dictionary<string, MethodInfo> toStringMethods = new Dictionary<string, MethodInfo>();
|
||||||
internal static Dictionary<string, MethodInfo> toStringFormattedMethods = new Dictionary<string, MethodInfo>();
|
|
||||||
|
|
||||||
private const string nullString = "<color=grey>null</color>";
|
private const string nullString = "<color=grey>null</color>";
|
||||||
private const string nullUnknown = nullString + " (?)";
|
private const string nullUnknown = nullString + " (?)";
|
||||||
@ -132,22 +131,12 @@ namespace UnityExplorer
|
|||||||
|
|
||||||
var type = value.GetActualType();
|
var type = value.GetActualType();
|
||||||
|
|
||||||
// Find and cache the relevant ToString method for this Type, if haven't already.
|
// Find and cache the ToString method for this Type, if haven't already.
|
||||||
|
|
||||||
if (!toStringMethods.ContainsKey(type.AssemblyQualifiedName))
|
if (!toStringMethods.ContainsKey(type.AssemblyQualifiedName))
|
||||||
{
|
{
|
||||||
try
|
var toStringMethod = type.GetMethod("ToString", ArgumentUtility.EmptyTypes);
|
||||||
{
|
toStringMethods.Add(type.AssemblyQualifiedName, toStringMethod);
|
||||||
var formatMethod = type.GetMethod("ToString", ArgumentUtility.ParseArgs);
|
|
||||||
formatMethod.Invoke(value, new object[] { ParseUtility.NUMBER_FORMAT });
|
|
||||||
toStringFormattedMethods.Add(type.AssemblyQualifiedName, formatMethod);
|
|
||||||
toStringMethods.Add(type.AssemblyQualifiedName, null);
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
var toStringMethod = type.GetMethod("ToString", ArgumentUtility.EmptyTypes);
|
|
||||||
toStringMethods.Add(type.AssemblyQualifiedName, toStringMethod);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Invoke the ToString method on the object
|
// Invoke the ToString method on the object
|
||||||
@ -157,10 +146,7 @@ namespace UnityExplorer
|
|||||||
string toString;
|
string toString;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (toStringFormattedMethods.TryGetValue(type.AssemblyQualifiedName, out MethodInfo formatMethod))
|
toString = (string)toStringMethods[type.AssemblyQualifiedName].Invoke(value, ArgumentUtility.EmptyArgs);
|
||||||
toString = (string)formatMethod.Invoke(value, new object[] { ParseUtility.NUMBER_FORMAT });
|
|
||||||
else
|
|
||||||
toString = (string)toStringMethods[type.AssemblyQualifiedName].Invoke(value, ArgumentUtility.EmptyArgs);
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user