Exemplo n.º 1
0
        public void HubWithMethodsHasHubMethods()
        {
            var hubType    = typeof(BaseMethodHub);
            var hubMethods = HubReflectionHelper.GetHubMethods(hubType);

            Assert.Equal(3, hubMethods.Count());
            Assert.Contains(hubMethods, m => m == hubType.GetMethod("VoidMethod"));
            Assert.Contains(hubMethods, m => m == hubType.GetMethod("IntMethod"));
            Assert.Contains(hubMethods, m => m == hubType.GetMethod("ArgMethod"));
        }
Exemplo n.º 2
0
        public void InheritedHubHasBaseHubMethodsAndOwnMethods()
        {
            var hubType    = typeof(InheritedMethodHub);
            var hubMethods = HubReflectionHelper.GetHubMethods(hubType);

            Assert.Equal(4, hubMethods.Count());
            Assert.Contains(hubMethods, m => m == hubType.GetMethod("ExtraMethod"));
            Assert.Contains(hubMethods, m => m == hubType.GetMethod("VoidMethod"));
            Assert.Contains(hubMethods, m => m == hubType.GetMethod("IntMethod"));
            Assert.Contains(hubMethods, m => m == hubType.GetMethod("ArgMethod"));
        }
Exemplo n.º 3
0
        private void DiscoverHubMethods()
        {
            var hubType     = typeof(THub);
            var hubTypeInfo = hubType.GetTypeInfo();

            foreach (var methodInfo in HubReflectionHelper.GetHubMethods(hubType))
            {
                var methodName = methodInfo.Name;

                if (_methods.ContainsKey(methodName))
                {
                    throw new NotSupportedException($"Duplicate definitions of '{methodName}'. Overloading is not supported.");
                }

                var executor            = ObjectMethodExecutor.Create(methodInfo, hubTypeInfo);
                var authorizeAttributes = methodInfo.GetCustomAttributes <AuthorizeAttribute>(inherit: true);
                _methods[methodName] = new HubMethodDescriptor(executor, authorizeAttributes);

                _logger.HubMethodBound(methodName);
            }
        }
Exemplo n.º 4
0
        public void EmptyHubHasNoHubMethods()
        {
            var hubMethods = HubReflectionHelper.GetHubMethods(typeof(EmptyHub));

            Assert.Empty(hubMethods);
        }