コード例 #1
0
        protected override async Task<Variable> EvaluateAsync(ParsingScript script)
        {
            List<Variable> args = await script.GetFunctionArgsAsync();
            AddOutput(args, script, m_newLine);

            return Variable.EmptyInstance;
        }
コード例 #2
0
        protected override async Task <Variable> EvaluateAsync(ParsingScript script)
        {
            List <Variable> args = await script.GetFunctionArgsAsync();

            Utils.CheckArgs(args.Count, 1, m_name);

            Variable newVariable = Utils.CreateVariableFromJsonString(args[0].AsString());

            return(newVariable);
        }
コード例 #3
0
        public async Task <Variable> GetPropertyAsync(string propName, ParsingScript script = null)
        {
            Variable result = Variable.EmptyInstance;

            int ind = propName.IndexOf('.');

            if (ind > 0)
            { // The case x = a.b.c ... is dealt here recursively
                string   varName        = propName.Substring(0, ind);
                string   actualPropName = propName.Substring(ind + 1);
                Variable property       = await GetPropertyAsync(varName, script);

                result = string.IsNullOrEmpty(actualPropName) ? property :
                         await property.GetPropertyAsync(actualPropName, script);

                return(result);
            }

            if (Object is ScriptObject)
            {
                ScriptObject obj   = Object as ScriptObject;
                string       match = GetActualPropertyName(propName, obj.GetProperties());
                if (!string.IsNullOrWhiteSpace(match))
                {
                    List <Variable> args = null;
                    if (script != null &&
                        (script.Pointer == 0 || script.Prev == Constants.START_ARG))
                    {
                        args = await script.GetFunctionArgsAsync();
                    }
                    else if (script != null)
                    {
                        args = new List <Variable>();
                    }
                    result = await obj.GetProperty(match, args, script);

                    if (result != null)
                    {
                        return(result);
                    }
                }
            }

            return(GetCoreProperty(propName, script));
        }