コード例 #1
0
ファイル: ScriptQualifiedName.cs プロジェクト: ugurak/SSharp
        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);
            }
        }
コード例 #2
0
ファイル: ScriptNewArrStmt.cs プロジェクト: singba/SSharp
        //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;
            //}
        }
コード例 #3
0
ファイル: ScriptQualifiedName.cs プロジェクト: ugurak/SSharp
        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);
        }
コード例 #4
0
ファイル: ScriptQualifiedName.cs プロジェクト: HaKDMoDz/eStd
    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);
        }
    }
コード例 #5
0
ファイル: ScriptQualifiedName.cs プロジェクト: HaKDMoDz/eStd
    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);
    }