public IHttpHandler GetHttpHandler(RequestContext requestContext) { var factory = new PersistentConnectionFactory(_resolver); PersistentConnection connection = factory.CreateInstance(_handlerType); return(new AspNetHandler(_resolver, connection)); }
public IHttpHandler GetHttpHandler(RequestContext requestContext) { var factory = new PersistentConnectionFactory(_resolver); PersistentConnection connection = factory.CreateInstance(_handlerType); return new AspNetHandler(_resolver, connection); }
public bool TryGetConnection(string path, out PersistentConnection connection) { if (path == null) { throw new ArgumentNullException("path"); } connection = null; if (!String.IsNullOrEmpty(_hubPath) && path.StartsWith(_hubPath, StringComparison.OrdinalIgnoreCase)) { connection = new HubDispatcher(_hubPath); return(true); } foreach (var pair in _connectionMapping) { // If the url matches then create the connection type if (path.StartsWith(pair.Key, StringComparison.OrdinalIgnoreCase)) { var factory = new PersistentConnectionFactory(_resolver); connection = factory.CreateInstance(pair.Value); return(true); } } return(false); }
public void ThrowsIfTypeIsNull() { // Arrange var resolver = new Mock<IDependencyResolver>(); var factory = new PersistentConnectionFactory(resolver.Object); // Act & Assert Assert.Throws<ArgumentNullException>(() => factory.CreateInstance(null)); }
public void ThrowsIfTypeIsNotPersistentConnection() { // Arrange var resolver = new Mock<IDependencyResolver>(); var factory = new PersistentConnectionFactory(resolver.Object); // Act & Assert Assert.Throws<InvalidOperationException>(() => factory.CreateInstance(typeof(PersistentConnectionFactoryFacts))); }
public void ThrowsIfTypeIsNotPersistentConnection() { // Arrange var resolver = new Mock <IDependencyResolver>(); var factory = new PersistentConnectionFactory(resolver.Object); // Act & Assert Assert.Throws <InvalidOperationException>(() => factory.CreateInstance(typeof(PersistentConnectionFactoryFacts))); }
public void ThrowsIfTypeIsNull() { // Arrange var resolver = new Mock <IDependencyResolver>(); var factory = new PersistentConnectionFactory(resolver.Object); // Act & Assert Assert.Throws <ArgumentNullException>(() => factory.CreateInstance(null)); }
/// <summary> /// Sends all requests to a PersistentConnection type. RunSignalR should be used as the last item in a pipeline, or /// inside a Map statement. /// </summary> /// <typeparam name="T">PersistentConnection type to expose</typeparam> /// <param name="builder"></param> /// <param name="resolver">Used by components to acquire the services they depend on</param> /// <returns></returns> public static IAppBuilder RunSignalR <T>(this IAppBuilder builder, IDependencyResolver resolver) where T : PersistentConnection { return(builder.Use <AppDelegate>(_ => ExecuteConnection(env => { var factory = new PersistentConnectionFactory(resolver); var connection = factory.CreateInstance(typeof(T)); connection.Initialize(resolver); return connection; }))); }
public void CreatesInstanceIfTypeIsPersistentConnection() { // Arrange var resolver = new Mock<IDependencyResolver>(); var factory = new PersistentConnectionFactory(resolver.Object); // Act PersistentConnection connection = factory.CreateInstance(typeof(MyConnection)); // Assert Assert.NotNull(connection); }
public void CreatesInstanceIfTypeIsPersistentConnection() { // Arrange var resolver = new Mock <IDependencyResolver>(); var factory = new PersistentConnectionFactory(resolver.Object); // Act PersistentConnection connection = factory.CreateInstance(typeof(MyConnection)); // Assert Assert.NotNull(connection); }
public Task Invoke(IDictionary<string, object> environment) { var path = environment.Get<string>(OwinConstants.RequestPath); if (path == null || !path.StartsWith(_path, StringComparison.OrdinalIgnoreCase)) { return _app.Invoke(environment); } var connectionFactory = new PersistentConnectionFactory(_resolver); var connection = connectionFactory.CreateInstance(_connectionType); var handler = new CallHandler(_resolver, connection); return handler.Invoke(environment); }
public void UsesDependencyResolver() { // Arrange var resolver = new Mock<IDependencyResolver>(); var factory = new PersistentConnectionFactory(resolver.Object); var otherConnection = new MyOtherConnection(); resolver.Setup(m => m.GetService(typeof(MyConnection))) .Returns(otherConnection); // Act PersistentConnection connection = factory.CreateInstance(typeof(MyConnection)); // Assert Assert.NotNull(connection); Assert.Same(otherConnection, connection); }
public Task Invoke(IDictionary <string, object> environment) { var path = environment.Get <string>(OwinConstants.RequestPath); if (path == null || !PrefixMatcher.IsMatch(_path, path)) { return(_next(environment)); } var connectionFactory = new PersistentConnectionFactory(_configuration.Resolver); var connection = connectionFactory.CreateInstance(_connectionType); var handler = new CallHandler(_configuration, connection); return(handler.Invoke(environment)); }
public Task Invoke(IDictionary <string, object> environment) { var path = environment.Get <string>(OwinConstants.RequestPath); if (path == null || !path.StartsWith(_path, StringComparison.OrdinalIgnoreCase)) { return(_app.Invoke(environment)); } var connectionFactory = new PersistentConnectionFactory(_resolver); var connection = connectionFactory.CreateInstance(_connectionType); var handler = new CallHandler(_resolver, connection); return(handler.Invoke(environment)); }
public void UsesDependencyResolver() { // Arrange var resolver = new Mock <IDependencyResolver>(); var factory = new PersistentConnectionFactory(resolver.Object); var otherConnection = new MyOtherConnection(); resolver.Setup(m => m.GetService(typeof(MyConnection))) .Returns(otherConnection); // Act PersistentConnection connection = factory.CreateInstance(typeof(MyConnection)); // Assert Assert.NotNull(connection); Assert.Same(otherConnection, connection); }
public override Task Invoke(IOwinContext context) { if (context == null) { throw new ArgumentNullException("context"); } if (JsonUtility.TryRejectJSONPRequest(_configuration, context)) { return(TaskAsyncHelper.Empty); } var connectionFactory = new PersistentConnectionFactory(_configuration.Resolver); PersistentConnection connection = connectionFactory.CreateInstance(_connectionType); connection.Initialize(_configuration.Resolver); return(connection.ProcessRequest(context.Environment)); }