mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-23 01:10:08 +00:00
3.0 - inspector
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
public static class DateTimeUtil
|
||||
{
|
||||
private static readonly DateTime k_DateTime1970 = TimeZoneInfo.ConvertTime(new DateTime(1970, 1, 1), TimeZoneInfo.Local);
|
||||
//private static readonly DateTime k_DateTime1970 = TimeZoneInfo.ConvertTime(new DateTime(1970, 1, 1), TimeZoneInfo.Local);
|
||||
private static readonly DateTime k_DateTime1970 = new DateTime(1970, 1, 1);
|
||||
public static readonly int ONE_SECOND = 1;
|
||||
public static readonly int ONE_MINUTE = ONE_SECOND * 60;
|
||||
public static readonly int ONE_HOUR = ONE_MINUTE * 60;
|
||||
|
||||
@@ -9,10 +9,18 @@ namespace XCharts.Runtime
|
||||
{
|
||||
public static class ReflectionUtil
|
||||
{
|
||||
private static Dictionary<object, MethodInfo> listClearMethodInfoCaches = new Dictionary<object, MethodInfo>();
|
||||
private static Dictionary<object, MethodInfo> listAddMethodInfoCaches = new Dictionary<object, MethodInfo>();
|
||||
|
||||
public static void InvokeListClear(object obj, FieldInfo field)
|
||||
{
|
||||
var list = field.GetValue(obj);
|
||||
var method = list.GetType().GetMethod("Clear");
|
||||
MethodInfo method;
|
||||
if (!listClearMethodInfoCaches.TryGetValue(list, out method))
|
||||
{
|
||||
method = list.GetType().GetMethod("Clear");
|
||||
listClearMethodInfoCaches[list] = method;
|
||||
}
|
||||
method.Invoke(list, new object[] { });
|
||||
}
|
||||
public static int InvokeListCount(object obj, FieldInfo field)
|
||||
@@ -24,7 +32,12 @@ namespace XCharts.Runtime
|
||||
public static void InvokeListAdd(object obj, FieldInfo field, object item)
|
||||
{
|
||||
var list = field.GetValue(obj);
|
||||
var method = list.GetType().GetMethod("Add");
|
||||
MethodInfo method;
|
||||
if (!listAddMethodInfoCaches.TryGetValue(list, out method))
|
||||
{
|
||||
method = list.GetType().GetMethod("Add");
|
||||
listAddMethodInfoCaches[list] = method;
|
||||
}
|
||||
method.Invoke(list, new object[] { item });
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user