Exemplo n.º 1
0
        public void Start()
        {
            Uri[] listenPrefixes = GetListenPrefixes();
            _portalBootstrapper.State         = ServerState.Starting;
            _portalBootstrapper.StatusMessage = "Starting...";
            IPortalBootstrapper portalBootstrapper = _portalBootstrapper;
            HostConfiguration   hostConfiguration  = new HostConfiguration();

            hostConfiguration.UnhandledExceptionCallback = (OnException);
            HostConfiguration configuration = hostConfiguration;

            Uri[] uriArray = listenPrefixes;
            _host = new CustomNancyHost(portalBootstrapper, configuration, uriArray)
            {
                AuthenticationSchemeSelector = request => AuthenticationSchemes.Anonymous
            };
            try
            {
                _host.Start();
            }
            catch (AutomaticUrlReservationCreationFailureException ex)
            {
                throw new Exception(ExceptionExtensions.SuggestUrlReservations(listenPrefixes));
            }
            catch (HttpListenerException ex)
            {
                string message = ex.SuggestSolution(listenPrefixes);
                if (message != null)
                {
                    throw new Exception(message, ex);
                }
                throw;
            }
            foreach (Uri uri in listenPrefixes)
            {
                _log.InfoFormat("NuFridge server available at: {0}://localhost:{1}{2}", uri.Scheme, uri.Port, uri.PathAndQuery);
            }
        }
Exemplo n.º 2
0
 public WebServerInitializer(IWebPortalConfiguration configuration, IPortalBootstrapper portalBootstrapper)
 {
     _configuration      = configuration;
     _portalBootstrapper = portalBootstrapper;
 }