/// <summary> /// Utility function that invokes the actual user interceptor extension method. If entityType is null /// it looks for the generic interceptor. If its not null then it looks for a typed interceptor for the /// specific type being passed. /// </summary> /// <param name="context">The context to pass as parameter to user code</param> /// <param name="entityType">Type of the entity being processed</param> /// <param name="isRequest">True if intercepting a request operation else false.</param> internal void InvokeOperationInterceptors(SyncOperationContext context, Type entityType, bool isRequest) { SyncInterceptorsInfoWrapper wrapper = null; if (this.SyncInterceptors.TryGetValue(context.ScopeName, out wrapper)) { MethodInfo methodInfo = null; switch (context.Operation) { case SyncOperations.Download: if (entityType == null) { methodInfo = (isRequest) ? wrapper.DownloadRequestInterceptor : wrapper.DownloadResponseInterceptor; } else { Debug.Assert(!isRequest, "Cannot fire typed interceptor for DownloadRequest"); methodInfo = wrapper.GetResponseInterceptor(SyncOperations.Download, entityType); } break; case SyncOperations.Upload: if (entityType == null) { methodInfo = (isRequest) ? wrapper.UploadRequestInterceptor : wrapper.UploadResponseInterceptor; } else { methodInfo = (isRequest) ? wrapper.GetRequestInterceptor(entityType) : wrapper.GetResponseInterceptor(SyncOperations.Upload, entityType); } break; } if (methodInfo != null) { InvokeUserInterceptorMethod(methodInfo, OperationContext.Current.InstanceContext.GetServiceInstance(), new object[] { context }); } } }