コード例 #1
0
        public static IDisposable Create(AppFunc app, IDictionary <string, object> properties)
        {
            if (app == null)
            {
                throw new ArgumentNullException(nameof(app));
            }
            if (properties == null)
            {
                throw new ArgumentNullException(nameof(properties));
            }

            // Retrieve the instances created in Initialize
            OwinWebListener wrapper = properties.Get <OwinWebListener>(typeof(OwinWebListener).FullName)
                                      ?? new OwinWebListener();
            WebListener listener = properties.Get <WebListener>(typeof(WebListener).FullName)
                                   ?? new WebListener();

            AddressList addresses = properties.Get <AddressList>(Constants.HostAddressesKey)
                                    ?? new List <IDictionary <string, object> >();

            CapabilitiesDictionary capabilities =
                properties.Get <CapabilitiesDictionary>(Constants.ServerCapabilitiesKey)
                ?? new Dictionary <string, object>();

            var loggerFactory = properties.Get <LoggerFactoryFunc>(Constants.ServerLoggerFactoryKey);

            wrapper.Start(listener, app, addresses, capabilities, loggerFactory);
            return(wrapper);
        }
コード例 #2
0
        public static void Initialize(CapabilitiesDictionary properties)
        {
            if (properties == null)
            {
                throw new ArgumentNullException(nameof(properties));
            }

            properties[Constants.VersionKey] = Constants.OwinVersion;

            CapabilitiesDictionary capabilities =
                properties.Get <CapabilitiesDictionary>(Constants.ServerCapabilitiesKey)
                ?? new Dictionary <string, object>();

            properties[Constants.ServerCapabilitiesKey] = capabilities;

            DetectWebSocketSupport(properties);

            // Let users set advanced configurations directly.
            var wrapper = new OwinWebListener();

            properties[typeof(OwinWebListener).FullName]         = wrapper;
            properties[typeof(System.Net.HttpListener).FullName] = wrapper.Listener;
        }