Esempio n. 1
0
		public object Intercept (InvocationInfo invocation)
		{
			//ReturnValue = invocation.TargetMethod.Invoke (invocation.Target, invocation.Arguments);
			if (invocation.TargetMethod.DeclaringType == typeof (IProxy))
				return Behaviors;

			var input = new MethodInvocation(invocation.Target, invocation.TargetMethod, invocation.Arguments);
			var returns = pipeline.Invoke(input, (i, next) => {
				try {
					var returnValue = invocation.TargetMethod.Invoke (invocation.Target, invocation.Arguments);
					return input.CreateValueReturn(returnValue, invocation.Arguments);
				}
				catch (TargetInvocationException tie) {
					return input.CreateExceptionReturn(tie.InnerException);
				}
				catch (Exception ex) {
					return input.CreateExceptionReturn(ex);
				}
			});

			var exception = returns.Exception;
			if (exception != null)
				throw exception;

			for (int i = 0; i < returns.Outputs.Count; i++) {
				var name = returns.Outputs.GetName(i);
				var index = input.Arguments.IndexOf (name);
				invocation.SetArgument (index, returns.Outputs[index]);
			}

			return returns.ReturnValue;
		}
Esempio n. 2
0
        public void Intercept(IInvocation invocation)
        {
            if (invocation.Method.DeclaringType == typeof(IProxy))
            {
                invocation.ReturnValue = Behaviors;
                return;
            }

            var input   = new MethodInvocation(invocation.InvocationTarget, invocation.Method, invocation.Arguments);
            var returns = pipeline.Invoke(input, (i, next) => {
                try  {
                    invocation.Proceed();
                    var returnValue = invocation.ReturnValue;
                    return(input.CreateValueReturn(returnValue, invocation.Arguments));
                } catch (Exception ex) {
                    return(input.CreateExceptionReturn(ex));
                }
            });

            var exception = returns.Exception;

            if (exception != null)
            {
                throw exception;
            }

            invocation.ReturnValue = returns.ReturnValue;
            for (int i = 0; i < returns.Outputs.Count; i++)
            {
                var name  = returns.Outputs.GetName(i);
                var index = input.Arguments.IndexOf(name);
                invocation.SetArgumentValue(index, returns.Outputs[index]);
            }
        }
Esempio n. 3
0
		public void Intercept (IInvocation invocation)
		{
			if (invocation.Method.DeclaringType == typeof (IProxy)) {
				invocation.ReturnValue = Behaviors;
				return;
			}

			var input = new MethodInvocation(invocation.InvocationTarget, invocation.Method, invocation.Arguments);
			var returns = pipeline.Invoke(input, (i, next) => {
				try  {
					invocation.Proceed();
					var returnValue = invocation.ReturnValue;
					return input.CreateValueReturn(returnValue, invocation.Arguments);
				} catch (Exception ex) {
					return input.CreateExceptionReturn(ex);
				}
			});

			var exception = returns.Exception;
			if (exception != null)
				throw exception;

			invocation.ReturnValue = returns.ReturnValue;
			for (int i = 0; i < returns.Outputs.Count; i++) {
				var name = returns.Outputs.GetName(i);
				var index = input.Arguments.IndexOf (name);
				invocation.SetArgumentValue (index, returns.Outputs[index]);
			}
		}
Esempio n. 4
0
        public object Intercept(InvocationInfo invocation)
        {
            //ReturnValue = invocation.TargetMethod.Invoke (invocation.Target, invocation.Arguments);
            if (invocation.TargetMethod.DeclaringType == typeof(IProxy))
            {
                return(Behaviors);
            }

            var input   = new MethodInvocation(invocation.Target, invocation.TargetMethod, invocation.Arguments);
            var returns = pipeline.Invoke(input, (i, next) => {
                try {
                    var returnValue = invocation.TargetMethod.Invoke(invocation.Target, invocation.Arguments);
                    return(input.CreateValueReturn(returnValue, invocation.Arguments));
                }
                catch (TargetInvocationException tie) {
                    return(input.CreateExceptionReturn(tie.InnerException));
                }
                catch (Exception ex) {
                    return(input.CreateExceptionReturn(ex));
                }
            });

            var exception = returns.Exception;

            if (exception != null)
            {
                throw exception;
            }

            for (int i = 0; i < returns.Outputs.Count; i++)
            {
                var name  = returns.Outputs.GetName(i);
                var index = input.Arguments.IndexOf(name);
                invocation.SetArgument(index, returns.Outputs[index]);
            }

            return(returns.ReturnValue);
        }