예제 #1
0
        /// <summary>
        /// Configures the OWIN pipeline.
        /// </summary>
        /// <typeparam name="TStartup">Class containing a startup function used to configure the OWIN pipeline.</typeparam>
        /// <param name="options">Settings to control the startup behavior of an OWIN application.</param>
        protected void Configure <TStartup>(StartOptions options)
        {
            // Compare with WebApp.StartImplementation
            options            = options ?? new StartOptions();
            options.AppStartup = typeof(TStartup).AssemblyQualifiedName;

            var webSocketHttpServerFactory = new OwinHttpServerFactory();
            var services = ServicesFactory.Create();
            var engine   = services.GetService <IHostingEngine>();
            var context  = new StartContext(options);

            context.ServerFactory = new ServerFactoryAdapter(webSocketHttpServerFactory);
            _started = engine.Start(context);
        }
예제 #2
0
        /// <summary>
        /// Configures the OWIN pipeline.
        /// </summary>
        /// <param name="startup">Startup function used to configure the OWIN pipeline.</param>
        /// <param name="options">Settings to control the startup behavior of an OWIN application</param>
        protected void Configure(Action <IAppBuilder> startup, StartOptions options)
        {
            // Compare with WebApp.StartImplementation
            if (startup == null)
            {
                throw new ArgumentNullException(nameof(startup));
            }

            options = options ?? new StartOptions();
            if (string.IsNullOrWhiteSpace(options.AppStartup))
            {
                // Populate AppStartup for use in host.AppName
                options.AppStartup = startup.Method.ReflectedType.FullName;
            }

            var webSocketHttpServerFactory = new OwinHttpServerFactory();
            var services = ServicesFactory.Create();
            var engine   = services.GetService <IHostingEngine>();
            var context  = new StartContext(options);

            context.ServerFactory = new ServerFactoryAdapter(webSocketHttpServerFactory);
            context.Startup       = startup;
            _started = engine.Start(context);
        }