CreateInstance() публичный Метод

Creates an instance of the specified type using the dependency resolver or the type's default constructor.
public CreateInstance ( Type connectionType ) : PersistentConnection
connectionType System.Type The type of to create.
Результат PersistentConnection
            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));
            }
            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 || !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 _next(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);
        }