public override bool TryInvokeMember(InvokeMemberBinder binder, object[] arguments, out object result) { if (CallTarget == null) { result = null; return(false); } object[] theArguments = TypeFactorization.MaybeRenameArguments(binder.CallInfo, arguments); try { result = InvocationBinding.InvokeMember(CallTarget, binder.Name, theArguments); } catch (RuntimeBinderException) { result = null; try { InvocationBinding.InvokeMemberAction(CallTarget, binder.Name, theArguments); } catch (RuntimeBinderException) { return(false); } } return(true); }
public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object result) { if (!base.TryInvokeMember(binder, args, out result)) { result = InvocationBinding.InvokeGet(CallTarget, binder.Name); if (result == null) { return(false); } var functor = result as Delegate; if (!binder.CallInfo.ArgumentNames.Any() && null != functor) { try { result = this.InvokeMethodDelegate(functor, args); } catch (RuntimeBinderException) { return(false); } } try { result = InvocationBinding.Invoke(result, TypeFactorization.MaybeRenameArguments(binder.CallInfo, args)); } catch (RuntimeBinderException) { return(false); } } return(this.WireUpForInterface(binder.Name, true, ref result)); }
public override bool TryGetIndex(GetIndexBinder binder, object[] indexes, out object result) { if (base.TryGetIndex(binder, indexes, out result)) { Recording.Add(new Invocation(InvocationKind.GetIndex, Invocation.IndexBinderName, TypeFactorization.MaybeRenameArguments(binder.CallInfo, indexes))); return(true); } return(false); }
public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object result) { if (base.TryInvokeMember(binder, args, out result)) { Recording.Add(new Invocation(InvocationKind.InvokeMemberUnknown, binder.Name, TypeFactorization.MaybeRenameArguments(binder.CallInfo, args))); return(true); } return(false); }
public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object result) { var sk = SignatureKey.Create(binder, args); SignatureKey nested = null; if (_nestedTargets.TryGetValue(sk, out nested)) { var member = _dynamicMembers[nested]; try { result = InvocationBinding.InvokeMember(member, binder.Name, args); } catch (RuntimeBinderException) { result = null; return(false); } return(this.WireUpForInterface(binder.Name, true, ref result)); } if (_dynamicMembers.TryGetValue(sk, out result)) { var functor = result as Delegate; if (result == null) { return(false); } if (!binder.CallInfo.ArgumentNames.Any() && functor != null) { try { result = this.InvokeMethodDelegate(functor, args); } catch (RuntimeBinderException) { return(false); } } else { try { result = InvocationBinding.Invoke(result, TypeFactorization.MaybeRenameArguments(binder.CallInfo, args)); } catch (RuntimeBinderException) { return(false); } } return(this.WireUpForInterface(binder.Name, true, ref result)); } return(this.WireUpForInterface(binder.Name, false, ref result)); }
public override bool TrySetIndex(SetIndexBinder binder, object[] indexes, object value) { if (base.TrySetIndex(binder, indexes, value)) { var combinedArguments = indexes.Concat(new[] { value }).ToArray(); Recording.Add(new Invocation(InvocationKind.GetIndex, Invocation.IndexBinderName, TypeFactorization.MaybeRenameArguments(binder.CallInfo, combinedArguments))); return(true); } return(false); }
public override bool TryGetIndex(GetIndexBinder binder, object[] indexes, out object result) { if (CallTarget == null) { result = null; return(false); } object[] theArguments = TypeFactorization.MaybeRenameArguments(binder.CallInfo, indexes); result = InvocationBinding.InvokeGetIndex(CallTarget, theArguments); return(true); }
public override bool TrySetIndex(SetIndexBinder binder, object[] indexes, object value) { if (CallTarget == null) { return(false); } var combinedArguments = indexes.Concat(new[] { value }).ToArray(); object[] tArgs = TypeFactorization.MaybeRenameArguments(binder.CallInfo, combinedArguments); InvocationBinding.InvokeSetIndex(CallTarget, tArgs); return(true); }
public override bool TryInvokeMember(InvokeMemberBinder binder, object[] arguments, out object result) { var invocation = new Invocation(InvocationKind.InvokeMemberUnknown, binder.Name, TypeFactorization.MaybeRenameArguments(binder.CallInfo, arguments)); var before = _aspectWeaver.Before(binder); var ok = true; result = null; foreach (var aspect in before) { ok = ok && aspect.InterceptBefore(invocation, OriginalTarget, _aspectExtensions, out result); } var instead = _aspectWeaver.InsteadOf(binder); if (instead.Any()) { foreach (var aspect in instead) { ok = ok && aspect.InterceptInstead(invocation, OriginalTarget, _aspectExtensions, out result); } } else { ok = ok && base.TryInvokeMember(binder, invocation.Arguments, out result); } var after = _aspectWeaver.After(binder); foreach (var aspect in after) { ok = ok && aspect.InterceptAfter(invocation, OriginalTarget, _aspectExtensions, out result); } return(ok); }
public override bool TryInvoke(InvokeBinder binder, object[] args, out object result) { result = InvocationBinding.CreateInstance(_type, TypeFactorization.MaybeRenameArguments(binder.CallInfo, args)); return(true); }