예제 #1
0
        public override void SetValue(EvaluationContext ctx, object value)
        {
            ctx.AssertTargetInvokeAllowed();

            var args = new object [indexerArgs != null ? indexerArgs.Length + 1 : 1];

            if (indexerArgs != null)
            {
                indexerArgs.CopyTo(args, 0);
            }

            args [args.Length - 1] = value;

            var setter = property.GetSetMethod(true);

            if (setter == null)
            {
                throw new EvaluatorException("Property is read-only");
            }

            this.value = null;
            haveValue  = false;

            setter.Invoke(obj ?? declaringType, args);

            this.value = value;
            haveValue  = true;
        }
        public override object CreateValue(EvaluationContext ctx, object type, params object[] args)
        {
            ctx.AssertTargetInvokeAllowed();

            SoftEvaluationContext cx = (SoftEvaluationContext)ctx;
            TypeMirror            t  = (TypeMirror)type;

            TypeMirror[] types = new TypeMirror [args.Length];
            for (int n = 0; n < args.Length; n++)
            {
                types [n] = ToTypeMirror(ctx, GetValueType(ctx, args [n]));
            }

            Value[] values = new Value[args.Length];
            for (int n = 0; n < args.Length; n++)
            {
                values[n] = (Value)args [n];
            }

            MethodMirror ctor = OverloadResolve(cx, ".ctor", t, types, true, true, true);

            return(t.NewInstance(cx.Thread, ctor, values));
        }