Holds information about a single hub.
Наследование: Descriptor
Пример #1
0
 public bool AuthorizeHubConnection(HubDescriptor hubDescriptor, IRequest request)
 {
     VerifyArgument.IsNotNull("hubDescriptor", hubDescriptor);
     VerifyArgument.IsNotNull("request", request);
     var result = request.User.IsAuthenticated() && Service.IsAuthorized(hubDescriptor.GetAuthorizationRequest(request));
     return result;
 }
Пример #2
0
 protected override bool OnBeforeAuthorizeConnect(HubDescriptor hubDescriptor, Microsoft.AspNet.SignalR.IRequest request)
 {
     _logger.Log("OnBeforeAuthorizeConnect " +
         "RemoteIpAddress:\"" + request.Environment["server.RemoteIpAddress"] + "\" " +
         "User-Agent: \"" + request.Headers["User-Agent"] + "\"");
     return base.OnBeforeAuthorizeConnect(hubDescriptor, request);
 }
Пример #3
0
        public override bool AuthorizeHubConnection(Microsoft.AspNet.SignalR.Hubs.HubDescriptor hubDescriptor, IRequest request)
        {
            string id          = request.QueryString.Get("id");
            string hashedToken = request.QueryString.Get("hashToken");

            return(Service.CheckIdentity(hashedToken, id));
        }
        /// <summary>
        /// Searches the specified <paramref name="hub">Hub</paramref> for the specified <paramref name="method"/>.
        /// </summary>
        /// <remarks>
        /// In the case that there are multiple overloads of the specified <paramref name="method"/>, the <paramref name="parameters">parameter set</paramref> helps determine exactly which instance of the overload should be resolved. 
        /// If there are multiple overloads found with the same number of matching parameters, none of the methods will be returned because it is not possible to determine which overload of the method was intended to be resolved.
        /// </remarks>
        /// <param name="hub">Hub to search for the specified <paramref name="method"/> on.</param>
        /// <param name="method">The method name to search for.</param>
        /// <param name="descriptor">If successful, the <see cref="MethodDescriptor"/> that was resolved.</param>
        /// <param name="parameters">The set of parameters that will be used to help locate a specific overload of the specified <paramref name="method"/>.</param>
        /// <returns>True if the method matching the name/parameter set is found on the hub, otherwise false.</returns>
        public bool TryGetMethod(HubDescriptor hub, string method, out MethodDescriptor descriptor, IList<IJsonValue> parameters)
        {
            string hubMethodKey = BuildHubExecutableMethodCacheKey(hub, method, parameters);

            if (!_executableMethods.TryGetValue(hubMethodKey, out descriptor))
            {
                IEnumerable<MethodDescriptor> overloads;

                if (FetchMethodsFor(hub).TryGetValue(method, out overloads))
                {
                    var matches = overloads.Where(o => o.Matches(parameters)).ToList();

                    // If only one match is found, that is the "executable" version, otherwise none of the methods can be returned because we don't know which one was actually being targeted
                    descriptor = matches.Count == 1 ? matches[0] : null;
                }
                else
                {
                    descriptor = null;
                }

                // If an executable method was found, cache it for future lookups (NOTE: we don't cache null instances because it could be a surface area for DoS attack by supplying random method names to flood the cache)
                if (descriptor != null)
                {
                    _executableMethods.TryAdd(hubMethodKey, descriptor);
                }
            }

            return descriptor != null;
        }
Пример #5
0
        public bool TryGetMethod(HubDescriptor hub, string method, out MethodDescriptor descriptor, params IJsonValue[] parameters)
        {
            descriptor = new MethodDescriptor
            {
                Hub = hub,
                Invoker = (h, args) =>
                {
                    var pkg = ((dynamic)args[0]);

                    //default to broadcast only to others
                    IClientProxy proxy = h.Clients.Others;
                    if (pkg.recipients == "ALL")
                        proxy = h.Clients.All;
                    else if (pkg.recipients == "SELF")
                        proxy = h.Clients.Caller;

                    var _appId = h.Context.ConnectionId;
                    dynamic _op = false;

                    //How to deal with concurrent requests?
                    //This is the derby/racer conflict resolution problem
                    //Like -- what if two users perform an update at the same time?
                    //For now, the broadcast is just sent to all....
                    //but an in-out pub/sub redis store that caches the requests
                    //and only executes the LAST one might be a simple solution

                    if (pkg.appBoxr != null)
                    {
                        var _clientId = pkg.clientId.ToString();
                        var _repo = GlobalHost.DependencyResolver.Resolve<IDataLayer>();
                        var appBoxr = (dynamic)pkg.appBoxr;

                        string process = appBoxr.process.top.ToString();

                        if (process == "GET")
                        {
                            _op = _repo.Get(appBoxr.queries);
                        }
                        else if (process == "SAVE")
                        {
                            _op = _repo.Save(appBoxr.models.ToString());
                        }
                        else if (process == "DELETE")
                        {
                            _op = _repo.Delete(new { ids = appBoxr.ids.ToString(), collection = appBoxr.collection });
                        }
                    }

                    //result is always 2nd param of GET SAVE and DELETE ops
                    return proxy.Invoke(method, pkg, _op);
                },
                Name = method,
                Attributes = new List<AuthAttribute>() { new AuthAttribute() },
                Parameters = Enumerable.Range(0, parameters.Length).Select(i => new Microsoft.AspNet.SignalR.Hubs.ParameterDescriptor { Name = "p_" + i, ParameterType = typeof(object) }).ToArray(),
                ReturnType = typeof(Task)
            };

            return true;
        }
 /// <summary>
 /// Builds a dictionary of all possible methods on a given hub.
 /// Single entry contains a collection of available overloads for a given method name (key).
 /// This dictionary is being cached afterwards.
 /// </summary>
 /// <param name="hub">Hub to build cache for</param>
 /// <returns>Dictionary of available methods</returns>
 private static IDictionary<string, IEnumerable<MethodDescriptor>> BuildMethodCacheFor(HubDescriptor hub)
 {
     return ReflectionHelper.GetExportedHubMethods(hub.HubType)
         .GroupBy(GetMethodName, StringComparer.OrdinalIgnoreCase)
         .ToDictionary(group => group.Key,
                       group => group.Select(oload => GetMethodDescriptor(group.Key, hub, oload)),
                       StringComparer.OrdinalIgnoreCase);
 }
Пример #7
0
        public override bool AuthorizeHubConnection(HubDescriptor hubDescriptor, IRequest request)
        {
            var token = request.Cookies[AuthCookieName()].Value;
            var user = skUserRepository.GetUserByToken(token);

            if (user == null) return false;
            request.Environment["UserName"] = user.Alias.ToUpperInvariant();
            return true;
        }
Пример #8
0
        public IHub Create(HubDescriptor descriptor)
        {
            if(descriptor.Type == null)
            {
                return null;
            }

            object hub = _resolver.Resolve(descriptor.Type) ?? Activator.CreateInstance(descriptor.Type);
            return hub as IHub;
        }
        public override bool AuthorizeHubConnection(Microsoft.AspNet.SignalR.Hubs.HubDescriptor hubDescriptor, IRequest request)
        {
            string token = request.Headers["authtoken"];

            if (token == AuthToken)
            {
                return(true);
            }
            return(false);
        }
Пример #10
0
        public IHub Create(HubDescriptor descriptor)
        {
            if (descriptor == null)
                throw new ArgumentNullException("descriptor");

            if (descriptor.HubType == null)
                return null;

            object hub = _container.Resolve(descriptor.HubType) ?? Activator.CreateInstance(descriptor.HubType);
            return hub as IHub;
        }
Пример #11
0
        public void Create_Hub_ReturnsHubProxy()
        {                                    
            var container = new ServiceContainer();
            container.EnableSignalR();
            container.Register<SampleHub>(new PerScopeLifetime());
            var activator = new LightInjectHubActivator(container);                     
            var hubDescriptor = new HubDescriptor { HubType = typeof(SampleHub) };
            
            var hub = activator.Create(hubDescriptor);

            Assert.IsInstanceOfType(hub, typeof(IProxy));
        }
        public void CorrectQualifiedName()
        {
            string hubName = "MyHubDescriptor",
                   unqualifiedName = "MyUnqualifiedName";

            HubDescriptor hubDescriptor = new HubDescriptor()
            {
                Name = hubName
            };

            Assert.Equal(hubDescriptor.CreateQualifiedName(unqualifiedName), hubName + "." + unqualifiedName);
        }
Пример #13
0
 public void Create_Hub_StartsScope()
 {
     var container = new ServiceContainer();
     container.EnableSignalR();
     container.Register<SampleHub>();
     var activator = new LightInjectHubActivator(container);
     var hubDescriptor = new HubDescriptor { HubType = typeof(SampleHub) };
     using (activator.Create(hubDescriptor))
     {
         Assert.IsNotNull(container.ScopeManagerProvider.GetScopeManager().CurrentScope);
     }                       
 }
 public override bool AuthorizeHubConnection(HubDescriptor hubDescriptor, IRequest request)
 {
     try
     {
         return Authorize(request);
     }
     catch (Exception e)
     {
         log.ErrorFormat("AuthorizeHubConnection error: {0}, {1}, {2}", e, e.StackTrace, e.InnerException != null ? e.InnerException.Message : string.Empty);
         return false;
     }
 }
Пример #15
0
 public bool AuthorizeHubConnection(HubDescriptor hubDescriptor, IRequest request)
 {
     switch (Mode)
     {
         case AuthorizeMode.Both:
         case AuthorizeMode.Outgoing:
             return UserAuthorized(request.User);
         default:
             Debug.Assert(Mode == AuthorizeMode.Incoming); // Guard in case new values are added to the enum
             return true;
     }
 }
Пример #16
0
        public override bool AuthorizeHubConnection(HubDescriptor hubDescriptor, IRequest request)
        {
            var username = request.Headers[Settings.Default.UsernameHeader]??request.QueryString[Settings.Default.UsernameHeader];
            request.Environment["server.User"] = new GenericPrincipal(new ExcelServiceIdentity(username), new string[] { });
            //request.GetOwinContext().Authentication.User = new GenericPrincipal(new ExcelServiceIdentity(username), new string[] { });
            if (!string.IsNullOrWhiteSpace(username))
            {
                return true;
            }

            return false;
        }
 public override bool AuthorizeHubConnection(HubDescriptor hubDescriptor, IRequest request)
 {
     try
     {
         var login = request.Headers["login"];
         var token = new Guid(request.Headers["token"]);
         return _authorizeStrategy.Authorize(login, token);
     }
     catch (Exception ex)
     {
         return false;
     }
 }
Пример #18
0
 public IHub Create(HubDescriptor descriptor)
 {
     IHub hub;
     if (!typeof(ILifetimeHub).IsAssignableFrom(descriptor.HubType))
     {
         hub = _lifetimeScope.Resolve(descriptor.HubType) as IHub;
     }
     else
     {
         hub = _lifetimeHubManager.ResolveHub<ILifetimeHub>(descriptor.HubType, _lifetimeScope);
     }
     return hub;
 }
        public IHub Create(HubDescriptor descriptor)
        {
            if (descriptor == null)
            {
                throw new ArgumentNullException("descriptor");
            }

            if (descriptor.HubType == null)
            {
                return null;
            }

            return ActivatorUtilities.CreateInstance(_serviceProvider, descriptor.HubType) as IHub;
        }
Пример #20
0
        public void Dispose_Hub_ClosesScope()
        {
            var container = new ServiceContainer();
            container.EnableSignalR();
            container.Register<SampleHub>();
            var activator = new LightInjectHubActivator(container);
            var hubDescriptor = new HubDescriptor { HubType = typeof(SampleHub) };

            var hub = activator.Create(hubDescriptor);

            hub.Dispose();

            Assert.IsNull(container.ScopeManagerProvider.GetScopeManager().CurrentScope);
        }
Пример #21
0
        public IHub Create(HubDescriptor descriptor)
        {
            if (descriptor == null)
            {
                throw new ArgumentNullException("descriptor");
            }

            if (descriptor.HubType == null)
            {
                return null;
            }

            return _kernel.TryGet(descriptor.HubType) as IHub;
        }
        /// <summary>
        /// Determines whether client is authorized to connect to <see cref="IHub"/>.
        /// </summary>
        /// <param name="hubDescriptor">Description of the hub client is attempting to connect to.</param>
        /// <param name="request">The (re)connect request from the client.</param>
        /// <returns>true if the caller is authorized to connect to the hub; otherwise, false.</returns>
        public virtual bool AuthorizeHubConnection(HubDescriptor hubDescriptor, HttpRequest request)
        {
            if (request == null)
            {
                throw new ArgumentNullException("request");
            }

            // If RequireOutgoing is explicitly set to false, authorize all connections.
            if (_requireOutgoing.HasValue && !_requireOutgoing.Value)
            {
                return true;
            }

            return UserAuthorized(request.HttpContext.User);
        }
        public bool AuthorizeHubConnection(HubDescriptor hubDescriptor, IRequest request)
        {
            VerifyArgument.IsNotNull("hubDescriptor", hubDescriptor);
            VerifyArgument.IsNotNull("request", request);
            var result = request.User.IsAuthenticated() && Service.IsAuthorized(hubDescriptor.GetAuthorizationRequest(request));

            // ReSharper disable ConditionIsAlwaysTrueOrFalse
            if(request.User.Identity != null)
            // ReSharper restore ConditionIsAlwaysTrueOrFalse
            {
                Dev2Logger.Log.Debug("AuthorizeHubConnection For [ " + request.User.Identity.Name + " ]");
            }

            return result;
        }
        public override bool AuthorizeHubConnection(HubDescriptor hubDescriptor, IRequest request)
        {
            var token = request.QueryString.Get("Bearer");
            var authenticationTicket = Startup.AuthServerOptions.AccessTokenFormat.Unprotect(token);

            if (authenticationTicket == null || authenticationTicket.Identity == null || !authenticationTicket.Identity.IsAuthenticated)
            {
                return false;
            }

            request.Environment["server.User"] = new ClaimsPrincipal(authenticationTicket.Identity);
            request.Environment["server.Username"] = authenticationTicket.Identity.Name;
            request.GetHttpContext().User = new ClaimsPrincipal(authenticationTicket.Identity);
            return true;
        }
Пример #25
0
 public override bool AuthorizeHubConnection(HubDescriptor hubDescriptor, IRequest request)
 {
     // authenticate by using bearer token in query string
     var token = request.QueryString.Get("token");
     var ticket = Startup.OAuthOptions.AccessTokenFormat.Unprotect(token);
     if (ticket != null && ticket.Identity != null && ticket.Identity.IsAuthenticated && ticket.Identity.HasClaim(c => c.Type == Constants.HouseClaim))
     {
         // set the authenticated user principal into environment so that it can be used in the future
         request.Environment["server.User"] = new ClaimsPrincipal(ticket.Identity);
         return true;
     }
     else
     {
         return false;
     }
 }
Пример #26
0
        private static IEnumerable<HubMethodModel> GetHubMethodInfo(IHubManager hubManager, HubDescriptor hubDescriptor)
        {
            var hubMethodDescriptors = hubManager.GetHubMethods(hubDescriptor.Name, md => true).ToList();
            if (!hubMethodDescriptors.Any())
                return null;

            var hubMethodData = hubMethodDescriptors
                .Select(hubMethodDescriptor => new HubMethodModel
                {
                    Name = hubMethodDescriptor.Name,
                    ReturnType = hubMethodDescriptor.ReturnType,
                    Parameters = GetHubMethodParametersInfo(hubMethodDescriptor)
                })
                .ToList();

            return hubMethodData;
        }
        /// <summary>
        /// Allow only connections if a valid user security token has been passed from
        /// the Web application
        /// </summary>
        /// <param name="hubDescriptor"></param>
        /// <param name="request"></param>
        /// <returns></returns>
        public override bool AuthorizeHubConnection(HubDescriptor hubDescriptor, IRequest request)
        {            
            string token = request.QueryString["token"];

            //var tokenBus = new BusSecurityToken();
            //int userId = tokenBus.GetUserIdFromSecurityToken(token,true);
            
            //if (userId == -1)
            //    return false;

            //var userBus = new BusUser();
            //if (!userBus.IsUserInRole("Programmer_Role"))            
            //    ThrowException("You're not in the correct role to access this service.");

            // allowed access
            return true;
        }
Пример #28
0
        public bool TryGetMethod(HubDescriptor hub, string method, out MethodDescriptor descriptor, params IJsonValue[] parameters)
        {
            descriptor = new MethodDescriptor
            {
                Hub = hub,
                Invoker = (h, args) =>
                {
                    IClientProxy proxy = h.Clients.All;
                    return proxy.Invoke(method, args);
                },
                Name = method,
                Attributes = new List<AuthAttribute>() { new AuthAttribute() },
                Parameters = Enumerable.Range(0, parameters.Length).Select(i => new Microsoft.AspNet.SignalR.Hubs.ParameterDescriptor { Name = "p_" + i, Type = typeof(object) }).ToArray(),
                ReturnType = typeof(Task)
            };

            return true;
        }
        private static string BuildHubExecutableMethodCacheKey(HubDescriptor hub, string method, IJsonValue[] parameters)
        {
            string normalizedParameterCountKeyPart;

            if (parameters != null)
            {
                normalizedParameterCountKeyPart = parameters.Length.ToString(CultureInfo.InvariantCulture);
            }
            else
            {
                // NOTE: we normailize a null parameter array to be the same as an empty (i.e. Length == 0) parameter array
                normalizedParameterCountKeyPart = "0";
            }

            // NOTE: we always normalize to all uppercase since method names are case insensitive and could theoretically come in diff. variations per call
            string normalizedMethodName = method.ToUpperInvariant();

            string methodKey = hub.Name + "::" + normalizedMethodName + "(" + normalizedParameterCountKeyPart + ")";

            return methodKey;
        }
Пример #30
0
        public override bool AuthorizeHubConnection(HubDescriptor descriptor, IRequest request)
        {
            string tenant = TenantConvention.GetTenant();

            string clientToken = request.GetClientToken();
            var provider = new Provider();
            var token = provider.GetToken(clientToken);

            if(token != null)
            {
                bool isValid = AccessTokens.IsValidAsync(tenant, token.ClientToken, request.GetClientIpAddress(), request.Headers["user-agent"]).Result;

                if(isValid)
                {
                    AppUsers.SetCurrentLoginAsync(tenant, token.LoginId).Wait();
                    var loginView = AppUsers.GetCurrentAsync(tenant, token.LoginId).Result;

                    var identity = new ClaimsIdentity(token.GetClaims(), DefaultAuthenticationTypes.ApplicationCookie, ClaimTypes.NameIdentifier, ClaimTypes.Role);

                    identity.AddClaim(new Claim(ClaimTypes.NameIdentifier, token.LoginId.ToString(CultureInfo.InvariantCulture)));

                    if(loginView.RoleName != null)
                    {
                        identity.AddClaim(new Claim(ClaimTypes.Role, loginView.RoleName));
                    }

                    if(loginView.Email != null)
                    {
                        identity.AddClaim(new Claim(ClaimTypes.Email, loginView.Email));
                    }

                    request.Environment["server.User"] = new ClaimsPrincipal(identity);
                    return true;
                }
            }

            return false;
        }
 private static MethodDescriptor GetMethodDescriptor(string methodName, HubDescriptor hub, MethodInfo methodInfo)
 {
     Type progressReportingType;
     var parameters = ExtractProgressParameter(methodInfo.GetParameters(), out progressReportingType);
     
     return new MethodDescriptor
     {
         ReturnType = methodInfo.ReturnType,
         Name = methodName,
         NameSpecified = (GetMethodAttributeName(methodInfo) != null),
         Invoker = new HubMethodDispatcher(methodInfo).Execute,
         Hub = hub,
         Attributes = methodInfo.GetCustomAttributes(typeof(Attribute), inherit: true).Cast<Attribute>(),
         ProgressReportingType = progressReportingType,
         Parameters = parameters
         .Select(p => new ParameterDescriptor
         {
             Name = p.Name,
             ParameterType = p.ParameterType,
         })
         .ToList()
     };
 }
 /// <summary>
 /// Builds a dictionary of all possible methods on a given hub.
 /// Single entry contains a collection of available overloads for a given method name (key).
 /// This dictionary is being cached afterwards.
 /// </summary>
 /// <param name="hub">Hub to build cache for</param>
 /// <returns>Dictionary of available methods</returns>
 private static IDictionary<string, IEnumerable<MethodDescriptor>> BuildMethodCacheFor(HubDescriptor hub)
 {
     return ReflectionHelper.GetExportedHubMethods(hub.HubType)
         .GroupBy(GetMethodName, StringComparer.OrdinalIgnoreCase)
         .ToDictionary(group => group.Key,
                       group => group.Select(oload =>
                           new MethodDescriptor
                           {
                               ReturnType = oload.ReturnType,
                               Name = group.Key,
                               NameSpecified = (GetMethodAttributeName(oload) != null),
                               Invoker = new HubMethodDispatcher(oload).Execute,
                               Hub = hub,
                               Attributes = oload.GetCustomAttributes(typeof(Attribute), inherit: true).Cast<Attribute>(),
                               Parameters = oload.GetParameters()
                                   .Select(p => new ParameterDescriptor
                                       {
                                           Name = p.Name,
                                           ParameterType = p.ParameterType,
                                       })
                                   .ToList()
                           }),
                       StringComparer.OrdinalIgnoreCase);
 }
Пример #33
0
 public bool AuthorizeConnect(HubDescriptor hubDescriptor, IRequest request)
 {
     return(Pipeline.AuthorizeConnect(hubDescriptor, request));
 }
Пример #34
0
        public IHub ResolveHub(string hubName)
        {
            HubDescriptor hub = GetHub(hubName);

            return(hub == null ? null : _activator.Create(hub));
        }
Пример #35
0
 /// <summary>
 /// This method is called before the AuthorizeConnect components of any modules added later to the <see cref="IHubPipeline"/>
 /// are executed. If this returns false, then those later-added modules will not run and the client will not be allowed
 /// to subscribe to client-side invocations of methods belonging to the hub defined by the <see cref="HubDescriptor"/>.
 /// </summary>
 /// <param name="hubDescriptor">A description of the hub the client is trying to subscribe to.</param>
 /// <param name="request">The connect request of the client trying to subscribe to the hub.</param>
 /// <returns>true, if the client is authorized to connect to the hub, false otherwise.</returns>
 protected virtual bool OnBeforeAuthorizeConnect(HubDescriptor hubDescriptor, IRequest request)
 {
     return(true);
 }
 public bool TryGetHub(string hubName, out HubDescriptor descriptor)
 {
     return(_hubs.Value.TryGetValue(hubName, out descriptor));
 }
 public IEnumerable <MethodDescriptor> GetMethods(HubDescriptor hub)
 {
     return(FetchMethodsFor(hub)
            .SelectMany(kv => kv.Value)
            .ToList());
 }
 /// <summary>
 /// Retrieves an existing dictionary of all available methods for a given hub from cache.
 /// If cache entry does not exist - it is created automatically by BuildMethodCacheFor.
 /// </summary>
 /// <param name="hub"></param>
 /// <returns></returns>
 private IDictionary <string, IEnumerable <MethodDescriptor> > FetchMethodsFor(HubDescriptor hub)
 {
     return(_methods.GetOrAdd(
                hub.Name,
                key => BuildMethodCacheFor(hub)));
 }
Пример #39
0
 public NullMethodDescriptor(HubDescriptor descriptor, string methodName)
 {
     _methodName = methodName;
     Hub         = descriptor;
 }
Пример #40
0
 /// <summary>
 /// Builds a dictionary of all possible methods on a given hub.
 /// Single entry contains a collection of available overloads for a given method name (key).
 /// This dictionary is being cached afterwards.
 /// </summary>
 /// <param name="hub">Hub to build cache for</param>
 /// <returns>Dictionary of available methods</returns>
 private IDictionary <string, IEnumerable <MethodDescriptor> > BuildMethodCacheFor(HubDescriptor hub)
 {
     return(ReflectionHelper.GetExportedHubMethods(hub.Type)
            .GroupBy(GetMethodName, StringComparer.OrdinalIgnoreCase)
            .ToDictionary(group => group.Key,
                          group => group.Select(oload =>
                                                new MethodDescriptor
     {
         ReturnType = oload.ReturnType,
         Name = group.Key,
         NameSpecified = (GetMethodAttributeName(oload) != null),
         Invoker = oload.Invoke,
         Hub = hub,
         Attributes = oload.GetCustomAttributes(typeof(Attribute), inherit: true).Cast <Attribute>(),
         Parameters = oload.GetParameters()
                      .Select(p => new ParameterDescriptor
         {
             Name = p.Name,
             Type = p.ParameterType,
         })
                      .ToList()
     }),
                          StringComparer.OrdinalIgnoreCase));
 }
 /// <summary>
 /// Builds a dictionary of all possible methods on a given hub.
 /// Single entry contains a collection of available overloads for a given method name (key).
 /// This dictionary is being cached afterwards.
 /// </summary>
 /// <param name="hub">Hub to build cache for</param>
 /// <returns>Dictionary of available methods</returns>
 private static IDictionary <string, IEnumerable <MethodDescriptor> > BuildMethodCacheFor(HubDescriptor hub)
 {
     return(ReflectionHelper.GetExportedHubMethods(hub.HubType)
            .GroupBy(GetMethodName, StringComparer.OrdinalIgnoreCase)
            .ToDictionary(group => group.Key,
                          group => group.Select(oload => GetMethodDescriptor(group.Key, hub, oload)),
                          StringComparer.OrdinalIgnoreCase));
 }
 public NullMethodDescriptor(HubDescriptor descriptor, string methodName, IEnumerable <MethodDescriptor> availableMethods)
 {
     _methodName       = methodName;
     _availableMethods = availableMethods;
     Hub = descriptor;
 }
Пример #43
0
 private static IEnumerable <MethodDescriptor> GetMethods(IHubManager manager, HubDescriptor descriptor)
 {
     return(from method in manager.GetHubMethods(descriptor.Name)
            group method by method.Name into overloads
            let oload = (from overload in overloads
                         orderby overload.Parameters.Count
                         select overload).FirstOrDefault()
                        orderby oload.Name
                        select oload);
 }
Пример #44
0
 public IList <string> RejoiningGroups(HubDescriptor hubDescriptor, IRequest request, IList <string> groups)
 {
     return(Pipeline.RejoiningGroups(hubDescriptor, request, groups));
 }