Beispiel #1
0
        private static Type GetRelevantInterceptorType(MethodInfo method)
        {
            Type returnType = method.ReturnType;
            Type genericArgument;
            Type interceptorType;

            if (!typeof(Task).IsAssignableFrom(returnType))
            {
                MethodInfoValidation.ValidateSyncMethod(method);

                genericArgument = returnType == typeof(void) ? typeof(object) : returnType;
                interceptorType = typeof(SyncCalleeProxyInterceptor <>);
            }
            else
            {
                genericArgument = TaskExtensions.UnwrapReturnType(returnType);

                if (method.IsDefined(typeof(WampProgressiveResultProcedureAttribute)))
                {
                    MethodInfoValidation.ValidateProgressiveMethod(method);
                    interceptorType = typeof(ProgressiveAsyncCalleeProxyInterceptor <>);
                }
                else
                {
                    MethodInfoValidation.ValidateAsyncMethod(method);
                    interceptorType = typeof(AsyncCalleeProxyInterceptor <>);
                }
            }

            Type closedGenericType = interceptorType.MakeGenericType(genericArgument);

            return(closedGenericType);
        }
 private static void ValidateMethod(MethodInfo method)
 {
     if (typeof(Task).IsAssignableFrom(method.ReturnType))
     {
         if (method.IsDefined(typeof(WampProgressiveResultProcedureAttribute)))
         {
             MethodInfoValidation.ValidateProgressiveMethod(method);
         }
         else
         {
             MethodInfoValidation.ValidateAsyncMethod(method);
         }
     }
 }