Example #1
0
 public void Add(IProxyInterceptor visitor)
 {
     if (visitor != null)
     {
         _visitors.AddLast(visitor);
     }
 }
 private Task CreateSuspendedTaskForExecution(IInvocation invocation, IProxyInterceptor callInterceptor)
 {
     return(Task.Run(() =>
     {
         var firstInterceptor = ChainInterceptors(GlobalInterceptors, callInterceptor);
         firstInterceptor.Proceed(invocation);
     }));
 }
        private IProxyInterceptor ChainInterceptors(IOrderedEnumerable <IProxyInterceptor> globalInterceptors, IProxyInterceptor callInterceptor)
        {
            var globalInterceptorsArray = globalInterceptors.ToArray();

            for (int i = 0; i < globalInterceptorsArray.Length; i++)
            {
                GetNextInterceptor(i, globalInterceptorsArray, callInterceptor).Next = GetNextInterceptor(i + 1, globalInterceptorsArray, callInterceptor);
            }

            return(globalInterceptorsArray.First());
        }
 private Task <ReturnType> CreateSuspendedTaskForExecution <ReturnType>(Task <ReturnType> originalTask, IInvocation invocation, IProxyInterceptor callInterceptor)
 {
     return(Task.Run(async() =>
     {
         var firstInterceptor = ChainInterceptors(GlobalInterceptors, callInterceptor);
         firstInterceptor.Proceed(invocation);
         return await(Task <ReturnType>) invocation.ReturnValue;
     }));
 }
 private IProxyInterceptor GetNextInterceptor(int i, IProxyInterceptor[] globalInterceptors, IProxyInterceptor callInterceptor)
 {
     if (i == globalInterceptors.Length)
     {
         return(callInterceptor);
     }
     if (i > globalInterceptors.Length)
     {
         return(null);
     }
     return(globalInterceptors[i]);
 }