Ejemplo n.º 1
0
        public override void OnInvocation(Invocation invocation)
        {
            Type type = invocation.Arguments[0].GetType();

            int value = Convert.ToInt32(invocation.Arguments[0]);
            value += 1;
            invocation.Arguments[0] = Convert.ChangeType(value, type);
        }
Ejemplo n.º 2
0
        public override void OnInvocation(Invocation invocation)
        {
            try
            {
                invocation.Proceed();
            }
            catch
            {
            }

            invocation.Result = 42;
        }
Ejemplo n.º 3
0
        public override void OnInvocation(Invocation invocation)
        {
            invocation.Proceed();

            string args = string.Join(", ",
                                      invocation.Arguments
                                        .Select(arg => arg == null ? "null" : arg.ToString())
                                        .ToArray());

            Console.WriteLine("{0}({1}) : {2}",
                              invocation.Method.Name, args, invocation.Result ?? "null");
        }
Ejemplo n.º 4
0
 public override void OnInvocation(Invocation invocation)
 {
     invocation.Result = 911;
     invocation.Cancel();
 }
Ejemplo n.º 5
0
 public virtual void OnInvocation(Invocation invocation)
 {
 }
Ejemplo n.º 6
0
 void IInterceptor.Intercept(Invocation invocation)
 {
     OnInvocation(invocation);
 }