Esempio n. 1
0
        public static object GetValueObject(string name, bool NoResolve = false)
        {
            if (!NoResolve)
            {
                object dots = DotsResolver.Resolve(name);
                if (dots != null && dots.GetType() != typeof(VNull))
                {
                    if (dots.GetType() == typeof(EProperty))
                    {
                        return(((EProperty)dots).GetValue());
                    }
                    else if (dots.GetType() == typeof(EField))
                    {
                        return(((EField)dots).GetValue());
                    }
                    else if (dots.GetType() == typeof(EMethodNew))
                    {
                        return(((EMethodNew)dots).Invoke());
                    }
                    else
                    {
                        throw new Exception($"Excpeted field, but '{dots.GetType().Name}' received.");
                    }
                }
            }

            EVariable a = GetVariable(name);

            if (a == null)
            {
                return(new VNull());
            }

            return(a.Value);
        }
Esempio n. 2
0
 public static object Remove(EVariable v, bool force = false)
 {
     if (v != null)
     {
         if (!force)
         {
             if (v.Options.Contains("CmdSharp"))
             {
                 return("ESCRIPT_ERROR_REMOVE_PROTECTED_VARIABLE");
             }
         }
         VarList.Remove(v);
         return(1);
     }
     return("ESCRIPT_ERROR_VARIABLE_NOT_FOUND");
 }
Esempio n. 3
0
        public static string GetValue(string name, bool replace = true)
        {
            EVariable a = GetVariable(name);

            if (a == null)
            {
                return("");
            }
            else
            {/*
              * if (a.Value.ToString().Contains("{") && a.Value.ToString().Contains("}") && replace)
              * {
              *     if (GetValue("varCanBeMethod") == "1")
              *     {
              *
              *         List<iString> list = new List<iString>();
              *
              *         for (int i = 0; i < a.Value.ToString().Length; i++)
              *         {
              *             if (a.Value.ToString()[i] == '{')
              *             {
              *                 iString test = new iString() { startIdx = i };
              *                 for (int c = test.startIdx; c < a.Value.ToString().Length; c++)
              *                 {
              *                     if (a.Value.ToString()[c] == '}')
              *                     {
              *                         test.text.Append("}");
              *                         test.endIdx = c + 1;
              *                         break;
              *                     }
              *                     test.text.Append(a.Value.ToString()[c]);
              *                 }
              *                 i = test.endIdx;
              *                 list.Add(test);
              *             }
              *         }
              *
              *         foreach (var r in list)
              *         {
              *             return a.Value.ToString().Replace(r.text.ToString(), Cmd.Process(r.text.ToString().TrimStart('{').TrimEnd('}')));
              *         }
              *     }
              * }*/
                return(a.Value.ToString());
            }
        }
Esempio n. 4
0
        public static void SetVariable(string name, object value, List <string> options = null)
        {
            object dots = DotsResolver.Resolve(name);

            if (dots != null && dots.GetType() != typeof(VNull))
            {
                if (dots.GetType() == typeof(EProperty))
                {
                    ((EProperty)dots).SetValue(value);
                }
                else if (dots.GetType() == typeof(EField))
                {
                    ((EField)dots).SetValue(value);
                }
                else
                {
                    throw new Exception($"Excpeted field or method, but '{dots.GetType().Name}' received.");
                }
            }

            EVariable e = GetVariable(name);

            if (e == null)
            {
                EVariable variable = new EVariable(name, value, options);
                VarList.Add(variable);
            }
            else
            {
                if (e.Options.Contains("ReadOnly"))
                {
                    throw new Exception("ESCRIPT_ERROR_EDIT_READONLY_VARIABLE");
                }

                e.Edit(value, options);
            }
        }
Esempio n. 5
0
        public static object Remove(string name, bool force = false)
        {
            EVariable v = GetVariable(name);

            return(Remove(v, force));
        }