Beispiel #1
0
        protected IWampRpcOperation CreateRpcMethod(object instance, ICalleeRegistrationInterceptor interceptor, MethodInfo method)
        {
            string procedureUri =
                interceptor.GetProcedureUri(method);

            if (!typeof(Task).IsAssignableFrom(method.ReturnType))
            {
                return(new SyncMethodInfoRpcOperation(instance, method, procedureUri));
            }
            else
            {
#if !NET40
                if (method.IsDefined(typeof(WampProgressiveResultProcedureAttribute)))
                {
                    MethodInfoValidation.ValidateProgressiveMethod(method);
                    return(CreateProgressiveOperation(instance, method, procedureUri));
                }
                else
#endif
                {
                    MethodInfoValidation.ValidateAsyncMethod(method);
                    return(new AsyncMethodInfoRpcOperation(instance, method, procedureUri));
                }
            }
        }
        protected IWampRpcOperation CreateRpcMethod(Func <object> instanceProvider, ICalleeRegistrationInterceptor interceptor, MethodInfo method)
        {
            string procedureUri =
                interceptor.GetProcedureUri(method);

            if (method.ReturnType.IsGenericType && method.ReturnType.GetGenericTypeDefinition() == typeof(IObservable <>))
            {
                MethodInfoValidation.ValidateProgressiveObservableMethod(method);
                return(CreateProgressiveObservableOperation(instanceProvider, method, procedureUri));
            }
            else if (!typeof(Task).IsAssignableFrom(method.ReturnType))
            {
                MethodInfoValidation.ValidateSyncMethod(method);
                return(new SyncMethodInfoRpcOperation(instanceProvider, method, procedureUri));
            }
            else
            {
                if (method.IsDefined(typeof(WampProgressiveResultProcedureAttribute)))
                {
                    MethodInfoValidation.ValidateProgressiveMethod(method);
                    return(CreateProgressiveOperation(instanceProvider, method, procedureUri));
                }
                else
                {
                    MethodInfoValidation.ValidateAsyncMethod(method);
                    return(new AsyncMethodInfoRpcOperation(instanceProvider, method, procedureUri));
                }
            }
        }