Represents the unary dynamic operation at the call site, providing the binding semantic and the details about the operation.
Inheritance: DynamicMetaObjectBinder
コード例 #1
0
        public override bool TryUnaryOperation(UnaryOperationBinder binder, out object result)
        {
            if (binder.Operation != ExpressionType.OnesComplement)
            {
                return base.TryUnaryOperation(binder, out result);
            }

            result = get_xml_value();
            return true;
        }
コード例 #2
0
ファイル: String.cs プロジェクト: gavin-zyi/Rin
        internal override bool UnaryOperation(UnaryOperationBinder binder, out Any result)
        {
            switch (binder.Operation)
            {
                case ExpressionType.IsTrue:
                    result = Value.Length > 0 ? Bool.True : Bool.False;
                    return true;
            }

            return base.UnaryOperation(binder, out result);
        }
コード例 #3
0
ファイル: Number.cs プロジェクト: gavin-zyi/Rin
        internal override bool UnaryOperation(UnaryOperationBinder binder, out Any result)
        {
            switch (binder.Operation)
            {
                case ExpressionType.IsTrue:
                    result = ((int)Value) != 0 ? Bool.True : Bool.False;
                    return true;
                case ExpressionType.Negate:
                    result = new Number(-Value);
                    return true;
            }

            return base.UnaryOperation(binder, out result);
        }
コード例 #4
0
ファイル: pyobject.cs プロジェクト: patstew/pythonnet_old
 public override bool TryUnaryOperation(UnaryOperationBinder binder, out Object result)
 {
     int r;
     IntPtr res;
     switch (binder.Operation)
     {
     case ExpressionType.Negate:
         res = Runtime.PyNumber_Negative(this.obj);
         break;
     case ExpressionType.UnaryPlus:
         res = Runtime.PyNumber_Positive(this.obj);
         break;
     case ExpressionType.OnesComplement:
         res = Runtime.PyNumber_Invert(this.obj);
         break;
     case ExpressionType.Not:
         r = Runtime.PyObject_Not(this.obj);
         result = r == 1;
         return r != -1;
     case ExpressionType.IsFalse:
         r = Runtime.PyObject_IsTrue(this.obj);
         result = r == 0;
         return r != -1;
     case ExpressionType.IsTrue:
         r = Runtime.PyObject_IsTrue(this.obj);
         result = r == 1;
         return r != -1;
     case ExpressionType.Decrement:
     case ExpressionType.Increment:
     default:
         result = null;
         return false;
     }
     result = new PyObject(res);
     return true;
 }
コード例 #5
0
 /// <summary>
 /// Override on DynamicObject
 /// </summary>
 /// <param name="binder"></param>
 /// <param name="result"></param>
 /// <returns></returns>
 public override bool TryUnaryOperation(UnaryOperationBinder binder, out object result)
 {
     result = new Mimic();
     return true;
 }
コード例 #6
0
		public override bool TryUnaryOperation(UnaryOperationBinder binder, out object result)
		{
			if(binder.Operation == System.Linq.Expressions.ExpressionType.IsTrue)
			{
			 result = this;
				return true;
			}
			throw new NotImplementedException();
			
		}
コード例 #7
0
        public override Boolean TryUnaryOperation(UnaryOperationBinder binder, out Object result)
        {
            result = null;
            Boolean boolResult;

            switch (binder.Operation) {
                case ExpressionType.IsTrue: {
                    if (TypeConversion.TryConvertTo(_target, out boolResult)) {
                        result = boolResult;
                        return true;
                    }
                    return false;
                }
            }

            throw new NotImplementedException(String.Format("TryUnaryOperation op={0}", binder.Operation));
        }
コード例 #8
0
 /// <summary>
 /// Performs the binding of the dynamic unary operation.
 /// </summary>
 /// <param name="binder">An instance of the <see cref="UnaryOperationBinder"/> that represents the details of the dynamic operation.</param>
 /// <returns>The new <see cref="DynamicMetaObject"/> representing the result of the binding.</returns>
 public virtual DynamicMetaObject BindUnaryOperation(UnaryOperationBinder binder) {
     ContractUtils.RequiresNotNull(binder, "binder");
     return binder.FallbackUnaryOperation(this);
 }
コード例 #9
0
ファイル: ScriptItem.cs プロジェクト: dirkelfman/ClearScript
 public override DynamicMetaObject BindUnaryOperation(UnaryOperationBinder binder)
 {
     return scriptItem.PostProcessBindResult(metaDynamic.BindUnaryOperation(binder));
 }
コード例 #10
0
ファイル: RubyMetaObject.cs プロジェクト: TerabyteX/main
 /*!*/
 public override DynamicMetaObject BindUnaryOperation(UnaryOperationBinder/*!*/ binder)
 {
     return InteropBinder.UnaryOperation.Bind(CreateMetaContext(), binder, this, binder.FallbackUnaryOperation);
 }
コード例 #11
0
 public override DynamicMetaObject BindUnaryOperation(UnaryOperationBinder binder)
 {
     throw new NotImplementedException();
 }
コード例 #12
0
ファイル: DynamicEBuilder.cs プロジェクト: respu/SimplyFast
 public override DynamicMetaObject BindUnaryOperation(UnaryOperationBinder binder)
 {
     return BuildCallSelf(_unaryMethod, Expression.Constant(binder.Operation));
 }
コード例 #13
0
        public virtual new bool TryUnaryOperation(UnaryOperationBinder binder, out Object result)
        {
            result = default(Object);

            return(default(bool));
        }
コード例 #14
0
ファイル: PrototypalObject.cs プロジェクト: larsw/Archetype
 public override bool TryUnaryOperation( UnaryOperationBinder binder, out object result )
 {
     if ( TryUnaryOperationMissing == null )
     {
         result = null;
         return false;
     }
     return TryUnaryOperationMissing( binder, out result );
 }
コード例 #15
0
 public virtual bool TryUnaryOperation(UnaryOperationBinder binder, out object result)
 {
     result = null;
     return(false);
 }
コード例 #16
0
 /// <summary>
 /// Performs the binding of the dynamic unary operation.
 /// </summary>
 /// <param name="binder">An instance of the <see cref="UnaryOperationBinder"/> that represents the details of the dynamic operation.</param>
 /// <returns>The new <see cref="DynamicMetaObject"/> representing the result of the binding.</returns>
 public virtual DynamicMetaObject BindUnaryOperation(UnaryOperationBinder binder)
 {
     ContractUtils.RequiresNotNull(binder, nameof(binder));
     return(binder.FallbackUnaryOperation(this));
 }
コード例 #17
0
 public virtual DynamicMetaObject BindUnaryOperation(UnaryOperationBinder binder)
 {
     throw new NotImplementedException();
 }
コード例 #18
0
 //
 // Summary:
 //     Provides implementation for unary operations. Classes derived from the System.Dynamic.DynamicObject
 //     class can override this method to specify dynamic behavior for operations such
 //     as negation, increment, or decrement.
 //
 // Parameters:
 //   binder:
 //     Provides information about the unary operation. The binder.Operation property
 //     returns an System.Linq.Expressions.ExpressionType object. For example, for the
 //     negativeNumber = -number statement, where number is derived from the DynamicObject
 //     class, binder.Operation returns "Negate".
 //
 //   result:
 //     The result of the unary operation.
 //
 // Returns:
 //     true if the operation is successful; otherwise, false. If this method returns
 //     false, the run-time binder of the language determines the behavior. (In most
 //     cases, a language-specific run-time exception is thrown.)
 public virtual bool TryUnaryOperation(UnaryOperationBinder binder, out object result);
コード例 #19
0
		public override bool TryUnaryOperation(UnaryOperationBinder binder, out object result)
		{
			if (binder.Operation != ExpressionType.OnesComplement)
			{
				return base.TryUnaryOperation(binder, out result);
			}

			result = (_nodeType == NodeType.Element) ? InternalContent : InternalValue;

			return true;
		}
コード例 #20
0
        public override bool TryUnaryOperation(UnaryOperationBinder binder, out object result)
        {
            if (binder.Operation == ExpressionType.IsFalse || binder.Operation == ExpressionType.IsTrue)
            {
                result = false;
                return true;
            }

            result = new DynamicExpressionBuilder(Expression.MakeUnary(binder.Operation, Expression, binder.ReturnType));
            return true;
        }
コード例 #21
0
ファイル: DynamicRenderer.cs プロジェクト: tsudonymn/RedDeer
 public override bool TryUnaryOperation(UnaryOperationBinder binder, out object result)
 {
     MessageBox.Show("Here");
     return base.TryUnaryOperation(binder, out result);
 }
コード例 #22
0
        public override bool TryUnaryOperation(UnaryOperationBinder binder, out object result)
        {
            var eng = GetEngine();

            switch (binder.Operation)
            {
                case ExpressionType.IsFalse:
                    result = !IsTruthy;
                    return true;
                case ExpressionType.IsTrue:
                    result = IsTruthy;
                    return true;

                case ExpressionType.Negate:
                case ExpressionType.NegateChecked:
                    switch (Type)
                    {
                        case JavaScriptValueType.Number:
                            double n = eng.Converter.ToDouble(this);
                            result = -n;
                            return true;

                        case JavaScriptValueType.Boolean:
                            if (IsTruthy)
                                result = -1;
                            else
                                result = -0;
                            return true;
                            
                        // TODO
                        // case JavaScriptValueType.String:
                    }

                    result = double.NaN;
                    return true;

                case ExpressionType.UnaryPlus:
                    switch (Type)
                    {
                        case JavaScriptValueType.Number:
                            result = eng.Converter.ToDouble(this);
                            return true;

                        case JavaScriptValueType.Boolean:
                            if (IsTruthy)
                                result = 1;
                            else
                                result = 0;

                            return true;
                    }

                    result = double.NaN;
                    return true;
            }

            return base.TryUnaryOperation(binder, out result);
        }
コード例 #23
0
    public virtual new System.Dynamic.DynamicMetaObject BindUnaryOperation(UnaryOperationBinder binder)
    {
      Contract.Requires(binder != null);

      return default(System.Dynamic.DynamicMetaObject);
    }
コード例 #24
0
ファイル: JsStore.cs プロジェクト: devhost/Corelicious
 public override Boolean TryUnaryOperation(UnaryOperationBinder binder, out Object result)
 {
     throw new NotImplementedException("JsValue.TryUnaryOperation");
 }
コード例 #25
0
ファイル: TotemType.cs プロジェクト: Alxandr/IronTotem
 public override DynamicMetaObject BindUnaryOperation(UnaryOperationBinder binder)
 {
     return binder.FallbackUnaryOperation(this);
 }
コード例 #26
0
            public override DynamicMetaObject BindUnaryOperation(UnaryOperationBinder binder)
            {
                /*
                 * Effectively returns the following code:
                 * {
                 *      var thisEvaled = (JsonObject)<Expression>;
                 *      object res;
                 *      ReturnType finalResult;
                 *      if(!Value.InnerTryUnaryOperation(ExpressionType, ReturnType, out res))
                 *      {
                 *          throw new InvalidCastException("Unable to get dynamic member <MemberName> of type <ReturnType> from ["+thisRef+"]");
                 *      }
                 *      finalResult = (ReturnType)res;
                 * }
                 */

                var thisRef = Expression.Type != typeof(JsonObject) ? Expression.Convert(Expression, typeof(JsonObject)) : Expression;
                var thisEvaled = ThisEvaled;
                var thisAssigned = Expression.Assign(thisEvaled, thisRef);
                var finalResult = Expression.Variable(binder.ReturnType);
                var res = Res;
                var tryUnaryOperationCall = Expression.Call(thisEvaled, InnerTryUnaryOperation, Expression.Constant(binder.Operation), Expression.Constant(binder.ReturnType), res);
                var throwExc =
                    Expression.Throw(
                        Expression.New(
                            InvalidCastExceptionCons,
                            Expression.Call(
                                StringConcat,
                                Expression.Constant("Unable to perform dynamic unary operation [" + binder.Operation + "] of type [" + binder.ReturnType.FullName + "] from ["),
                                thisEvaled,
                                CloseSquareBracket
                            )
                        )
                    );

                var notIf =
                    Expression.IfThen(
                        Expression.Not(tryUnaryOperationCall),
                        throwExc
                    );
                var finalAssign = Expression.Assign(finalResult, Expression.Convert(res, binder.ReturnType));

                var retBlock = Expression.Block(new[] { thisEvaled, finalResult, res }, thisAssigned, notIf, finalAssign);
                var restrictions = BindingRestrictions.GetTypeRestriction(Expression, LimitType);

                return new DynamicMetaObject(retBlock, restrictions);
            }
コード例 #27
0
		public virtual bool TryUnaryOperation (UnaryOperationBinder binder, out object result)
		{
			Console.WriteLine ("System.Windows.Interop.ComAutomationMetaObjectProviderBase.TryUnaryOperation: NIEX");
			throw new NotImplementedException ();
		}
コード例 #28
0
 /// <summary>
 /// Forwards the unary operation.
 /// </summary>
 /// <param name="binder"></param>
 /// <param name="result"></param>
 /// <returns></returns>
 public override bool TryUnaryOperation(UnaryOperationBinder binder, out object result)
 {
     result = null;
     try
     {
         result = Impromptu.InvokeUnaryOperator(binder.Operation, CallTarget);
         return true;
     }
     catch (RuntimeBinderException)
     {
         return false;
     }
 }
コード例 #29
0
 public virtual bool TryUnaryOperation(UnaryOperationBinder binder, out object result) {
     result = null;
     return false;
 }
コード例 #30
0
 public override bool TryUnaryOperation(UnaryOperationBinder binder, out object result)
 {
     return base.TryUnaryOperation(binder, out result);
 }
コード例 #31
0
        public virtual new System.Dynamic.DynamicMetaObject BindUnaryOperation(UnaryOperationBinder binder)
        {
            Contract.Requires(binder != null);

            return(default(System.Dynamic.DynamicMetaObject));
        }
コード例 #32
0
    public virtual new bool TryUnaryOperation(UnaryOperationBinder binder, out Object result)
    {
      result = default(Object);

      return default(bool);
    }
コード例 #33
0
ファイル: SimpleMetaObject.cs プロジェクト: xeno-by/xenogears
        private DispatchResult DispatchUnaryOperation(UnaryOperationBinder binder, Object arg1)
        {
            var old_value = Value;
            Value = arg1;

            try
            {
                try
                {
                    try
                    {
                        var result = UnaryOperation(binder);
                        if (result is FallbackException) throw (FallbackException)result;
                        return Succeed(result);
                    }
                    catch (FallbackException)
                    {
                        var dynamic_object = Value as IDynamicObject;
                        if (dynamic_object != null) return Succeed(dynamic_object.UnaryOperation(binder));
                        else throw;
                    }
                }
                catch (FallbackException)
                {
                    return Fail();
                }
                catch (Exception ex)
                {
                    if (WrapExceptions)
                    {
                        var bind_args = new OrderedDictionary<String, Object>();
                        bind_args.Add("arg1", arg1);
                        throw new BindException(binder, bind_args, ex);
                    }
                    else
                    {
                        throw;
                    }
                }
            }
            finally
            {
                Value = old_value;
            }
        }
コード例 #34
0
ファイル: SimpleMetaObject.cs プロジェクト: xeno-by/xenogears
        public sealed override DynamicMetaObject BindUnaryOperation(UnaryOperationBinder binder)
        {
            var fallback = ((Func<Expression>)(() =>
            {
                try { return base.BindUnaryOperation(binder).Expression; }
                catch (Exception ex) { return Expression.Throw(Expression.Constant(ex)); }
            }))();

            var dispatchResult = Expression.Parameter(typeof(DispatchResult), "dispatchResult");
            var shim = Expression.Block(dispatchResult.MkArray(),
                // 1. var dispatchResult = DispatchUnaryOperation(binder, `expression`);
                Expression.Assign(dispatchResult, Expression.Call(
                    Expression.Constant(this),
                    typeof(SimpleMetaObject).GetMethod("DispatchUnaryOperation", BF.PrivateInstance),
                    Expression.Constant(binder),
                    Expression)),
                // 2. return dispatchResult.Success ? dispatchResult.Result : `fallback`;
                Expression.Condition(
                    Expression.Property(dispatchResult, "Success"),
                    Expression.Convert(Expression.Property(dispatchResult, "Result"), binder.ReturnType),
                    fallback,
                    binder.ReturnType));
            return new DynamicMetaObject(shim, BindingRestrictions.GetTypeRestriction(Expression, LimitType));
        }
コード例 #35
0
ファイル: DynamicObject.cs プロジェクト: csharpHub/Theraot
 /// <summary>
 ///     Provides the implementation of performing a unary operation.  Derived classes can
 ///     override this method to customize behavior.  When not overridden the call site requesting
 ///     the binder determines the behavior.
 /// </summary>
 /// <param name="binder">The binder provided by the call site.</param>
 /// <param name="result">The result of the operation.</param>
 /// <returns>true if the operation is complete, false if the call site should determine behavior.</returns>
 public virtual bool TryUnaryOperation(UnaryOperationBinder binder, [NotNullWhen(true)] out object?result)
 {
     No.Op(binder);
     result = null;
     return(false);
 }
コード例 #36
0
            public override DynamicMetaObject BindUnaryOperation(UnaryOperationBinder binder) {
                if (IsOverridden("TryUnaryOperation")) {
                    return CallMethodWithResult("TryUnaryOperation", binder, NoArgs, (e) => binder.FallbackUnaryOperation(this, e));
                }

                return base.BindUnaryOperation(binder);
            }
コード例 #37
0
ファイル: SimpleMetaObject.cs プロジェクト: xeno-by/xenogears
 public virtual Object UnaryOperation(UnaryOperationBinder binder){ throw Fallback(); }