Esempio n. 1
0
 public void RunTest(Delegate f, ToStr toString)
 {
     foreach (List <object> test in tests)
     {
         string inputs = "";
         foreach (object item in test)
         {
             inputs = inputs + item.ToString() + " ";
         }
         Console.WriteLine("Testing " + inputs);
         T result = (T)f.DynamicInvoke(test.ToArray());
         Console.WriteLine(toString(result));
         Console.WriteLine("---");
     }
 }
Esempio n. 2
0
        public void TestToStr()
        {
            ToStr toStr = new ToStr();

            toStr.Parameters = new List <Token>()
            {
                "val".toToken(CefType.StringLiteral)
            };

            var res = toStr.Exec(null);

            res.Wait();



            Assert.AreEqual((string)res.Result.Value, "val");
        }
Esempio n. 3
0
        public void Method()
        {
            ToStr str = new ToStr(field.ToString);

            Console.WriteLine(str("x", null));
        }
Esempio n. 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ToStringRow"/> class.
 /// </summary>
 /// <param name="toStr">use ScenePathToString when null</param>
 /// <param name="toObj">use default casting when null</param>
 public ObjToString(ToStr toStr, ToObject toObj, bool showAsTooltip)
 {
     this.toString      = toStr != null ? toStr : ScenePathToString;
     this.toObject      = toObj != null ? toObj : DefaultToObject;
     this.showAsTooltip = showAsTooltip;
 }
Esempio n. 5
0
        public static bool PopupNullable <T>(string label, ref T selection, IList <T> items, ToStr toString, params GUILayoutOption[] options)
        {
            if (items.Count == 0)
            {
                bool  changed = false;
                Color old     = GUI.backgroundColor;
                GUI.backgroundColor = Color.red;
                if (label == null)
                {
                    int i = EditorGUILayout.Popup(1, new string[] { "-", selection.ToString() }, options);
                    if (i == 0)
                    {
                        selection = default(T);
                        changed   = true;
                    }
                }
                else
                {
                    int i = EditorGUILayout.Popup(label, 1, new string[] { "-", selection.ToString() }, options);
                    if (i == 0)
                    {
                        selection = default(T);
                        changed   = true;
                    }
                }
                GUI.backgroundColor = old;
                return(changed);
            }

            int index = 0;

            string[] str = new string[items.Count + 1];
            str[0] = "-";
            for (int i = 1; i <= items.Count; i++)
            {
                str[i] = toString(items[i - 1]);
                if (object.Equals(items[i - 1], selection))
                {
                    index = i;
                }
            }
            int newIndex = 0;

            if (label == null)
            {
                newIndex = EditorGUILayout.Popup(index, str, options);
            }
            else
            {
                newIndex = EditorGUILayout.Popup(label, index, str, options);
            }
            if (newIndex == 0)
            {
                selection = default(T);
            }
            else
            {
                selection = items[newIndex - 1];
            }
            return(newIndex != index);
        }