public override DynamicMetaObject BindBinaryOperation(BinaryOperationBinder binder, DynamicMetaObject arg) { if (Value is KumaInstance) { var KumaName = InteropBinder.MapExpressionType(binder.Operation); if (KumaName == null) { return(InteropBinder.Binary.Bind(binder, this, arg)); } if ( InteropBinder.InvokeMember.SearchForFunction(((KumaInstance)Value).Class, KumaName, (KumaInstance)Value, L(Arg(arg.Value)), true) != null) { return (InteropBinder.InvokeMember.Bind( new InteropBinder.InvokeMember(KumaName, new CallInfo(0), Scope), this, _DMO(DMO(Scope), DMO(Arg(arg.Value))))); } var clrName = InteropBinder.ToClrOperatorName(KumaName); if ( InteropBinder.InvokeMember.SearchForFunction(((KumaInstance)Value).Class, clrName, (KumaInstance)Value, L(Arg(arg.Value)), true) != null) { return (InteropBinder.InvokeMember.Bind( new InteropBinder.InvokeMember(clrName, new CallInfo(0), Scope), this, _DMO(DMO(Scope), DMO(Arg(arg.Value))))); } return(InteropBinder.Binary.Bind(binder, this, arg)); } return(InteropBinder.Binary.Bind(binder, this, arg)); }
public override DynamicMetaObject BindUnaryOperation(UnaryOperationBinder binder) { if (Value is KumaInstance) { // Check to see which method we should try to call var KumaName = InteropBinder.MapExpressionType(binder.Operation); if (KumaName == null) { return(InteropBinder.Unary.Bind(binder, this)); } if ( InteropBinder.InvokeMember.SearchForFunction(((KumaInstance)Value).Class, KumaName, (KumaInstance)Value, L(), true) != null) { return (InteropBinder.InvokeMember.Bind( new InteropBinder.InvokeMember(KumaName, new CallInfo(0), Scope), this, _DMO(DMO(Scope)))); } var clrName = InteropBinder.ToClrOperatorName(KumaName); if ( InteropBinder.InvokeMember.SearchForFunction(((KumaInstance)Value).Class, clrName, (KumaInstance)Value, L(), true) != null) { return(InteropBinder.Unary.Bind(binder, this)); } return(new DynamicMetaObject(Expression.Constant(null), BindingRestrictions.GetExpressionRestriction(Expression.Constant(true)))); } return(InteropBinder.Unary.Bind(binder, this)); }