Example #1
0
        internal static string GetHubAttributeName(this Type type)
        {
            if (!typeof(IHub).IsAssignableFrom(type))
            {
                return(null);
            }

            // We can still return null if there is no attribute name
            return(ReflectionHelper.GetAttributeValue <HubNameAttribute, string>(type, attr => attr.HubName));
        }
Example #2
0
        internal static string GetHubName(this Type type)
        {
            if (!typeof(IHub).IsAssignableFrom(type))
            {
                return(null);
            }

            return(ReflectionHelper.GetAttributeValue <HubNameAttribute, string>(type, attr => attr.HubName)
                   ?? type.Name);
        }
Example #3
0
        private void BuildCache(IHubLocator hubLocator)
        {
            foreach (var hubType in hubLocator.GetHubs())
            {
                // Always cache by full name
                AddCacheKey(hubType.FullName, hubType);

                // If there's a hub name attribute then use it as an alternative name
                var hubName = ReflectionHelper.GetAttributeValue <HubNameAttribute, string>(hubType, a => a.HubName);

                // Don't add it if it's the same as the short name
                if (!String.Equals(hubName, hubType.Name, StringComparison.OrdinalIgnoreCase))
                {
                    AddCacheKey(hubName, hubType);
                }

                // Add an entry for the type's short name
                AddCacheKey(hubType.Name, hubType);
            }
        }
 private static string GetMethodName(MethodInfo method)
 {
     return(ReflectionHelper.GetAttributeValue <HubMethodNameAttribute, string>(method, a => a.MethodName)
            ?? method.Name);
 }
 protected virtual string GetHubName(Type type)
 {
     return(ReflectionHelper.GetAttributeValue <HubNameAttribute, string>(type, a => a.HubName) ?? Json.CamelCase(type.Name));
 }