public void DynamicUnaryOperation() { dynamic d = new NegatableNum(23); dynamic r = -d; Assert.Equal(-23, r.Value); d = new NegatableNum(int.MinValue); r = -d; Assert.Equal(int.MinValue, r.Value); }
public override bool TryUnaryOperation(UnaryOperationBinder binder, out object result) { if (binder.Operation == ExpressionType.Negate) { result = new NegatableNum(unchecked (-Value)); return(true); } result = null; return(false); }
public void DynamicUnaryOperationNotSupported() { dynamic d = new NegatableNum(23); Assert.Throws <RuntimeBinderException>(() => ~d); }
public void DynamicUnaryOperationNotSupported() { dynamic d = new NegatableNum(23); Assert.Throws<RuntimeBinderException>(() => ~d); }
public override bool TryUnaryOperation(UnaryOperationBinder binder, out object result) { if (binder.Operation == ExpressionType.Negate) { result = new NegatableNum(unchecked(-Value)); return true; } result = null; return false; }