예제 #1
0
 public OwinContext(IDictionary<string, object> data)
 {
     this.data = data;
     request = new OwinRequest(data);
     response = new OwinResponse(data);
     ssl = new OwinSsl(data);
     host = new OwinHost(data);
     server = new OwinServer(data);
 }
예제 #2
0
 public void SetServer(IOwinServer server) {
     switch (_state) {
         case OwinHostState.ConfigureHost:
             _server = server;
             _server.Configure(new OwinHostContext(_hostContext.Environment));
             _state = OwinHostState.ConfigureApp;
             return;
         case OwinHostState.ConfigureApp:
         case OwinHostState.Runnable:
             throw new Exception("The Server may only be set once.");
         default:
             throw new ArgumentOutOfRangeException("Unknown Host State: " + _state);
     }
 }
예제 #3
0
        public void SetServer(IOwinServer server)
        {
            switch (_state)
            {
            case OwinHostState.ConfigureHost:
                _server = server;
                _server.Configure(new OwinHostContext(_hostContext.Environment));
                _state = OwinHostState.ConfigureApp;
                return;

            case OwinHostState.ConfigureApp:
            case OwinHostState.Runnable:
                throw new Exception("The Server may only be set once.");

            default:
                throw new ArgumentOutOfRangeException("Unknown Host State: " + _state);
            }
        }
예제 #4
0
        /// <summary>
        ///     Configure FileServer for Owin
        /// </summary>
        /// <param name="server">IOwinServer</param>
        /// <param name="appBuilder">IAppBuilder</param>
        public override void Configure(IOwinServer server, IAppBuilder appBuilder)
        {
            // This removes multiple entries in the debug console
            // It should be called sooner, but not to soon, need to check
            Trace.Listeners.Remove("HostingTraceListener");

            Log.Verbose().WriteLine("Enabling file server: {0}", WebserverConfiguration.EnableFileServer);
            if (!WebserverConfiguration.EnableFileServer)
            {
                return;
            }

            // Handle errors like 404 (not founds)
            appBuilder.Use((owinContext, next) =>
            {
                return(next().ContinueWith(x =>
                {
                    if (owinContext.Response.StatusCode < 400)
                    {
                        return;
                    }
                    var request = owinContext.Request;
                    var statusCode = owinContext.Response.StatusCode;
                    Log.Warn().WriteLine("{1} -> {0}", statusCode, request.Uri.AbsolutePath);
                    owinContext.Response.Redirect(owinContext.Request.Uri.AbsoluteUri.Replace(request.Uri.PathAndQuery, request.PathBase + $"/html/error/{statusCode}.html"));
                }));
            });

            switch (WebserverConfiguration.FileServerType)
            {
            case FileServerTypes.Embedded:
                ConfigureEmbeddedFileServer(appBuilder, WebserverConfiguration.FileServerPath, Assembly.GetExecutingAssembly(), WebserverConfiguration.FileServerLocation);
                break;

            case FileServerTypes.Physical:
                ConfigurePhysicalFileServer(appBuilder, WebserverConfiguration.FileServerPath, WebserverConfiguration.FileServerLocation);
                break;
            }
        }
예제 #5
0
파일: IOCTests.cs 프로젝트: yonglehou/BTDB
 public World(IOwinServer server, ISupport support, INotify notifyChanges)
 {
 }
예제 #6
0
 public World(IOwinServer server, ISupport support, INotify notifyChanges)
 {
 }