private void DiscoverHubMethods() { var hubType = typeof(THub); foreach (var methodInfo in hubType.GetMethods().Where(IsHubMethod)) { var methodName = methodInfo.Name; if (_methods.ContainsKey(methodName)) { throw new NotSupportedException($"Duplicate definitions of '{methodName}'. Overloading is not supported."); } var executor = ObjectMethodExecutor.Create(methodInfo, hubType.GetTypeInfo()); _methods[methodName] = new HubMethodDescriptor(executor); if (_logger.IsEnabled(LogLevel.Trace)) { _logger.LogTrace("Hub method '{methodName}' is bound", methodName); } } }
public HubMethodDescriptor(ObjectMethodExecutor methodExecutor) { MethodExecutor = methodExecutor; ParameterTypes = methodExecutor.ActionParameters.Select(p => p.ParameterType).ToArray(); AuthorizeData = methodExecutor.MethodInfo.GetCustomAttributes().OfType <AuthorizeAttribute>().ToArray(); }
public static ObjectMethodExecutor Create(MethodInfo methodInfo, TypeInfo targetTypeInfo) { var executor = new ObjectMethodExecutor(methodInfo, targetTypeInfo); return(executor); }