Esempio n. 1
0
            public CustomHubActivator(IDependencyResolver resolver)
            {
                if (resolver == null)
                {
                    throw new ArgumentNullException(nameof(resolver));
                }

                _resolver = resolver;
            }
Esempio n. 2
0
            public CustomResolver(IDependencyResolver defaultResolver, IKernel kernel)
            {
                if (defaultResolver == null)
                {
                    throw new ArgumentNullException(nameof(defaultResolver));
                }
                if (kernel == null)
                {
                    throw new ArgumentNullException(nameof(kernel));
                }

                _defaultResolver = defaultResolver;
                _kernel          = kernel;
            }
        public SignalRMessageSender(IMessageContentFormatter formatter, Microsoft.AspNet.SignalR.IDependencyResolver signalRDependencyResolver)
        {
            if (formatter == null)
            {
                throw new ArgumentNullException(nameof(formatter));
            }

            if (signalRDependencyResolver == null)
            {
                throw new ArgumentNullException(nameof(signalRDependencyResolver));
            }

            _formatter         = formatter;
            _connectionManager = signalRDependencyResolver.Resolve <IConnectionManager>();
        }
Esempio n. 4
0
        private void Configure(IOwinConfiguration owin)
        {
            if (owin == null)
            {
                throw new ArgumentNullException(nameof(owin));
            }

            owin.Http.Routes.IgnoreRoute("signalR", "signalr/{*pathInfo}");

            IDependencyResolver resolver =
                GlobalHost.DependencyResolver =
                    new CustomResolver(GlobalHost.DependencyResolver, owin.Kernel);

            var hubConfiguration = new HubConfiguration
            {
                Resolver                = resolver,
                EnableDetailedErrors    = _enableDetailedErrors,
                EnableJavaScriptProxies = _enableJavaScriptProxies,
                EnableJSONP             = _enableJSONP
            };

            resolver.Register(typeof(IAssemblyLocator), () => new CustomAssemblyLocator(_assemblies));
            resolver.Register(typeof(IHubActivator), () => new CustomHubActivator(resolver));
            resolver.Register(typeof(IHubDescriptorProvider), () => new CustomHubDescriptorProvider(resolver, owin.Kernel.Resolve <IHubsProvider>()));

            IHubPipeline hubPipeline = resolver.Resolve <IHubPipeline>();

            foreach (var pipelineModule in owin.Kernel.ResolveAll <IHubPipelineModule>())
            {
                hubPipeline.AddModule(pipelineModule);
            }

            owin.App.Map(_path, subApp =>
            {
                _onMap?.Invoke(subApp);

                subApp.RunSignalR(hubConfiguration);
            });

            // TODO: Look at the possibility to add custom trace sources programatically
            // https://msdn.microsoft.com/en-us/library/ms228984(v=vs.110).aspx

            if (!_skipTraceConfiguration)
            {
                ITraceManager traceManager = resolver.Resolve <ITraceManager>();
                traceManager.Switch.Level = _traceLevel;
            }
        }
        public SignalRMiddlewareConfiguration(Microsoft.AspNet.SignalR.IDependencyResolver dependencyResolver, IAppEnvironmentProvider appEnvironmentProvider,
                                              IEnumerable <ISignalRConfiguration> signalRScaleoutConfigurations = null)
        {
            if (appEnvironmentProvider == null)
            {
                throw new ArgumentNullException(nameof(appEnvironmentProvider));
            }

            if (dependencyResolver == null)
            {
                throw new ArgumentNullException(nameof(dependencyResolver));
            }

            _appEnvironmentProvider        = appEnvironmentProvider;
            _dependencyResolver            = dependencyResolver;
            _signalRScaleoutConfigurations = signalRScaleoutConfigurations;
        }
Esempio n. 6
0
 private void ConfigureSignalR(IDependencyResolver configuration)
 {
     configuration.Register(typeof(JsonSerializer), () => SignalRJsonSerializer.Instance);
 }
Esempio n. 7
0
 public CustomHubDescriptorProvider(IDependencyResolver resolver, IHubsProvider hubsProvider)
     : base(resolver)
 {
     _hubs = new HashSet <Type>(hubsProvider.Hubs.Distinct());
 }