示例#1
0
        public static void SetVariable(string name, string value, List <string> options = null)
        {
            if (value == null)
            {
                value = "null";
            }
            if (value.Length == 0)
            {
                value = "null";
            }
            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);
            }
        }
示例#2
0
        public static void SetVariableObject(string name, object value, List <string> options = null)
        {
            if (value == null)
            {
                value = "";
            }
            EVariable e = GetVariable(name);

            if (e == null)
            {
                EVariable variable = new EVariable(name, value, options);
                if (options != null)
                {
                    variable.Options = options;
                }
                VarList.Add(variable);
            }
            else
            {
                e.Edit(value);
            }
        }