diff --git a/src/CachedObjects/CacheMethod.cs b/src/CachedObjects/CacheMethod.cs
index 14659e6..6cb9b6a 100644
--- a/src/CachedObjects/CacheMethod.cs
+++ b/src/CachedObjects/CacheMethod.cs
@@ -16,6 +16,10 @@ namespace Explorer
private bool m_evaluated = false;
private CacheObjectBase m_cachedReturnValue;
+ private bool m_isEvaluating;
+ private ParameterInfo[] m_arguments;
+ private string[] m_argumentInput;
+
public bool HasParameters
{
get
@@ -29,13 +33,6 @@ namespace Explorer
}
private bool? m_hasParams;
- // ======= TODO =======
- private bool m_isEvaluating;
- private string[] m_argumentNames;
- private Type[] m_argumentTypes;
- private string[] m_argumentInput;
- // =====================
-
public static bool CanEvaluate(MethodInfo mi)
{
// generic type args not supported yet
@@ -44,21 +41,15 @@ namespace Explorer
return false;
}
- // TODO primitive params (commented out impl below)
- if (mi.GetParameters().Length > 0)
+ // only primitive and string args supported
+ foreach (var param in mi.GetParameters())
{
- return false;
+ if (!param.ParameterType.IsPrimitive && param.ParameterType != typeof(string))
+ {
+ return false;
+ }
}
- //// only primitive and string args supported
- //foreach (var param in mi.GetParameters())
- //{
- // if (!param.ParameterType.IsPrimitive && param.ParameterType != typeof(string))
- // {
- // return false;
- // }
- //}
-
return true;
}
@@ -66,69 +57,68 @@ namespace Explorer
{
base.Init();
- // TODO cache params
+ var mi = MemberInfo as MethodInfo;
+
+ m_arguments = mi.GetParameters();
+ m_argumentInput = new string[m_arguments.Length];
}
public override void UpdateValue()
{
base.UpdateValue();
-
- // TODO update params (?)
- }
-
- private void Evaluate()
- {
- m_evaluated = true;
-
- var mi = MemberInfo as MethodInfo;
-
- object ret;
-
- if (!HasParameters)
- {
- ret = mi.Invoke(mi.IsStatic ? null : DeclaringInstance, new object[0]);
- }
- else
- {
- // TODO parse params, invoke if valid
- throw new NotImplementedException("TODO");
- }
-
- if (ret != null)
- {
- m_cachedReturnValue = GetCacheObject(ret);
- if (m_cachedReturnValue is CacheList cacheList)
- {
- cacheList.WhiteSpace = 0f;
- cacheList.ButtonWidthOffset += 70f;
- }
- m_cachedReturnValue.UpdateValue();
- }
- else
- {
- m_cachedReturnValue = null;
- }
- }
+ }
public override void DrawValue(Rect window, float width)
{
GUILayout.BeginVertical(null);
- GUILayout.BeginHorizontal(null);
- if (GUILayout.Button("Evaluate", new GUILayoutOption[] { GUILayout.Width(70) }))
+ string evaluateLabel = "Evaluate";
+ if (HasParameters)
{
- if (HasParameters)
+ if (m_isEvaluating)
{
- throw new NotImplementedException("TODO");
+ for (int i = 0; i < m_arguments.Length; i++)
+ {
+ var name = m_arguments[i].Name;
+ var input = m_argumentInput[i];
+ var type = m_arguments[i].ParameterType.Name;
+
+ GUILayout.BeginHorizontal(null);
+ m_argumentInput[i] = GUILayout.TextField(input, new GUILayoutOption[] { GUILayout.Width(150) });
+ GUILayout.Label(i + ": " + name + " (" + type + ")", null);
+
+ GUILayout.EndHorizontal();
+ }
+
+ GUILayout.BeginHorizontal(null);
+ if (GUILayout.Button(evaluateLabel, new GUILayoutOption[] { GUILayout.Width(70) }))
+ {
+ Evaluate();
+ m_isEvaluating = false;
+ }
+ if (GUILayout.Button("Cancel", new GUILayoutOption[] { GUILayout.Width(70) }))
+ {
+ m_isEvaluating = false;
+ }
}
else
+ {
+ GUILayout.BeginHorizontal(null);
+ if (GUILayout.Button($"Evaluate ({m_arguments.Length} params)", new GUILayoutOption[] { GUILayout.Width(150) }))
+ {
+ m_isEvaluating = true;
+ }
+ }
+ }
+ else
+ {
+ GUILayout.BeginHorizontal(null);
+ if (GUILayout.Button(evaluateLabel, new GUILayoutOption[] { GUILayout.Width(70) }))
{
Evaluate();
}
}
- GUI.skin.label.wordWrap = false;
- GUILayout.Label($"{ValueType}", null);
- GUI.skin.label.wordWrap = true;
+
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal(null);
@@ -148,16 +138,88 @@ namespace Explorer
}
else
{
- GUILayout.Label($"null", null);
+ GUILayout.Label($"null ({ValueType})", null);
}
}
else
{
- GUILayout.Label($"Not yet evaluated", null);
+ GUILayout.Label($"Not yet evaluated ({ValueType})", null);
}
GUILayout.EndHorizontal();
GUILayout.EndVertical();
}
+
+ private void Evaluate()
+ {
+ m_evaluated = true;
+
+ var mi = MemberInfo as MethodInfo;
+
+ object ret = null;
+
+ if (!HasParameters)
+ {
+ ret = mi.Invoke(mi.IsStatic ? null : DeclaringInstance, new object[0]);
+ }
+ else
+ {
+ var arguments = new List