示例#1
0
        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);
                }
            }
        }
示例#2
0
 public HubMethodDescriptor(ObjectMethodExecutor methodExecutor)
 {
     MethodExecutor = methodExecutor;
     ParameterTypes = methodExecutor.ActionParameters.Select(p => p.ParameterType).ToArray();
     AuthorizeData  = methodExecutor.MethodInfo.GetCustomAttributes().OfType <AuthorizeAttribute>().ToArray();
 }
示例#3
0
        public static ObjectMethodExecutor Create(MethodInfo methodInfo, TypeInfo targetTypeInfo)
        {
            var executor = new ObjectMethodExecutor(methodInfo, targetTypeInfo);

            return(executor);
        }