Пример #1
0
        public EvaluationResult SetValue(ObjectPath path, string value, EvaluationOptions options)
        {
            if (path.Length != 2)
            {
                throw new NotSupportedException();
            }

            int[] idx = StringToIndices(path [1]);

            object val;

            try {
                EvaluationContext cctx = ctx.Clone();
                EvaluationOptions ops  = options ?? cctx.Options;
                ops.AllowMethodEvaluation = true;
                ops.AllowTargetInvoke     = true;
                cctx.Options = ops;
                ValueReference var = ctx.Evaluator.Evaluate(ctx, value, array.ElementType);
                val = var.Value;
                val = ctx.Adapter.Convert(ctx, val, array.ElementType);
                array.SetElement(idx, val);
            } catch {
                val = array.GetElement(idx);
            }
            try {
                return(ctx.Evaluator.TargetObjectToExpression(ctx, val));
            } catch (Exception ex) {
                ctx.WriteDebuggerError(ex);
                return(new EvaluationResult("? (" + ex.Message + ")"));
            }
        }
        EvaluationResult IObjectValueSource.SetValue(ObjectPath path, string value, EvaluationOptions options)
        {
            if (path.Length != 2)
            {
                throw new InvalidOperationException(string.Format("ObjectPath for array element is invalid: {0}", path));
            }

            int[] idx  = StringToIndices(path [1]);
            var   cctx = ctx.WithOptions(options);

            return(ValueModificationUtil.ModifyValue(cctx, value, array.ElementType, newVal => array.SetElement(idx, newVal)));
        }
Пример #3
0
 public void SetValue(int[] index, object value)
 {
     targetArray.SetElement(index, ctx.Adapter.FromRawValue(ctx, value));
 }