コード例 #1
0
 public static IESObject GetProperty(ESTable table, string name)
 {
     if (name == "add")
     {
         return(ToVirtual(new Action <string, object>((k, v) => table.Add(k, ToVirtual(v)))));
     }
     else if (name == "remove")
     {
         return(ToVirtual(new Action <string>(k => table.Remove(k))));
     }
     else if (name == "clear")
     {
         return(ToVirtual(new Action(table.Clear)));
     }
     else if (name == "keys")
     {
         return(ToVirtual(table.Keys));
     }
     else if (name == "values")
     {
         return(ToVirtual(table.Values));
     }
     else if (name == "count")
     {
         return(new ESNumber(table.Count));
     }
     else
     {
         return(new ESKey(table, name));
     }
 }
コード例 #2
0
ファイル: ESLibrary.cs プロジェクト: loqix/EasyScript
        public ESLibrary(EVM vm)
        {
            _string = new ESTable();
            _math   = new ESTable();

            vm.SetValue("tostring", new Func <object, string>(t => t.ToString()));
            vm.SetValue("typeof", new Func <object, Type>(t => t.GetType()));
            vm.SetValue("tolist", new Func <object, IESObject>(ESUtility.ToList));
            vm.SetValue("totable", new Func <object, IESObject>(ESUtility.ToTable));
            vm.SetValue("tonumber", new Func <object, float>(ESObject.ToFloat));

            vm.SetValue("string", _string);
            _string.Add("format", new Func <string, object, string>(string.Format));
            _string.Add("format2", new Func <string, object, object, string>(string.Format));
            _string.Add("format3", new Func <string, object, object, object, string>(string.Format));
            _string.Add("concat", new Func <string, string, string>(string.Concat));
            _string.Add("concat3", new Func <string, string, string, string>(string.Concat));
            _string.Add("concat4", new Func <string, string, string, string, string>(string.Concat));

            vm.SetValue("math", _math);
            _math.Add("min", new Func <float, float, float>(Math.Min));
            _math.Add("max", new Func <float, float, float>(Math.Max));
            _math.Add("abs", new Func <float, float>(Math.Abs));
        }
コード例 #3
0
ファイル: ESKey.cs プロジェクト: loqix/EasyScript
 public ESKey(ESTable table, string key)
 {
     _table = table;
     _key   = key;
 }