Exemplo n.º 1
0
        private static void GetArrayValue(object obj, ScriptArrayResolution scriptArrayResolution, IScriptContext context)
        {
            scriptArrayResolution.Evaluate(context);
            object[] param     = (object[])context.Result;
            IBinding indexBind = RuntimeHost.Binder.BindToIndex(obj, param, false);

            if (indexBind != null)
            {
                context.Result = indexBind.Invoke(context, null);
            }
            else
            {
                throw MethodNotFoundException("indexer[]", param);
            }
        }
Exemplo n.º 2
0
        //TODO: Refactor
        public override void Evaluate(IScriptContext context)
        {
            _constrExpr.Evaluate(context);
            var type = (Type)context.Result;

            _arrRank.Evaluate(context);
            var rank = Scripting.SSharp.CustomFunctions.ArrayFunc.FunctionDefinition.Invoke(null, (object[])context.Result);

            //(int)Convert.ChangeType(((object[])context.Result)[0], typeof(int), CultureInfo.CurrentCulture.NumberFormat);

            context.Result = Array.CreateInstance(type, (int[])rank);

            //long[] longRank = rank as long[];
            //if (longRank != null) {
            //    context.Result = Array.CreateInstance(type, longRank);
            //    return;
            //}
        }
Exemplo n.º 3
0
        private static void SetArrayValue(object obj, ScriptArrayResolution scriptArrayResolution, IScriptContext context, object value)
        {
            scriptArrayResolution.Evaluate(context);

            object[] indexParameters  = (object[])context.Result;
            object[] setterParameters = new object[indexParameters.Length + 1];
            indexParameters.CopyTo(setterParameters, 0);
            setterParameters[indexParameters.Length] = value;

            IBinding setter = RuntimeHost.Binder.BindToIndex(obj, setterParameters, true);

            if (setter != null)
            {
                setter.Invoke(context, null);
                return;
            }

            throw MethodNotFoundException("setter", indexParameters);
        }
Exemplo n.º 4
0
    private static void GetArrayValue(object obj, ScriptArrayResolution scriptArrayResolution, IScriptContext context) {
        scriptArrayResolution.Evaluate(context);
        object[] param = (object[])context.Result;
        IBinding indexBind = RuntimeHost.Binder.BindToIndex(obj, param, false);

        if (indexBind != null) {
            context.Result = indexBind.Invoke(context, null);
        } else {
            throw MethodNotFoundException("indexer[]", param);
        }
    }
Exemplo n.º 5
0
    private static void SetArrayValue(object obj, ScriptArrayResolution scriptArrayResolution, IScriptContext context, object value) {
        scriptArrayResolution.Evaluate(context);

        object[] indexParameters = (object[])context.Result;
        object[] setterParameters = new object[indexParameters.Length + 1];
        indexParameters.CopyTo(setterParameters, 0);
        setterParameters[indexParameters.Length] = value;

        IBinding setter = RuntimeHost.Binder.BindToIndex(obj, setterParameters, true);
        if (setter != null) {
            setter.Invoke(context, null);
            return;
        }

        throw MethodNotFoundException("setter", indexParameters);
    }