Ejemplo n.º 1
0
        public ScriptVariable Get(ScriptExecutionEnvironment environment)
        {
            if (_variable == null)
            {
                environment.Console.Warn("Cannot use indexer for null variable");
                return(null);
            }
            if (_index == null)
            {
                environment.Console.Warn("Cannot use null as indexer");
                return(null);
            }
            ListVariable   list = _variable as ListVariable;
            StringVariable key  = _index as StringVariable;

            if (list != null && key != null)
            {
                return(list[key.Value]);
            }

            int            indexInt = _index.ToInteger();
            ScriptVariable ret;

            if (!_variable.GetIndexedValue(indexInt, out ret))
            {
                environment.Console.Warn(string.Format("Invalid index : {0}", _index.ToString()));
                ret = null;
            }
            return(ret);
        }