コード例 #1
0
ファイル: RequestFilter.cs プロジェクト: dgknrdm/WebServer2
 public static IAppBase DoMapping(string url)
 {
     if (url.ToLowerInvariant() == "nextfibonacci")
     {
         return(AppLifecycleManager.Resolve <IAppBase>("AppFibonacci"));
     }
     else if (url == "")
     {
         return(AppLifecycleManager.Resolve <IAppBase>("AppIndex"));
     }
     else if (StringExtensions.After(url, ".") == "txt")
     {
         return(AppLifecycleManager.Resolve <IAppBase>("AppTextFileReader"));
     }
     else
     {
         return(AppLifecycleManager.Resolve <IAppBase>("AppNotFound"));
     }
 }
コード例 #2
0
ファイル: ServerProgram.cs プロジェクト: dgknrdm/WebServer2
        static void MainServer()
        {
            //Server Root Folder
            //String sMyWebServerRoot = "C:\\WebServerRoot\\";

            Console.WriteLine("Server");
            listener = new HttpListener();
            listener.Prefixes.Add(baseUrl);
            listener.AuthenticationSchemes = AuthenticationSchemes.Anonymous;

            listener.Start();


            AppLifecycleManager.RegisterApp <IAppBase, AppFibonacci>("AppFibonacci");
            AppLifecycleManager.RegisterApp <IAppBase, AppTextFileReader>("AppTextFileReader");
            AppLifecycleManager.RegisterApp <IAppBase, AppIndex>("AppIndex");
            AppLifecycleManager.RegisterApp <IAppBase, AppNotFound>("AppNotFound");

            IAppBase appfin = AppLifecycleManager.Resolve <IAppBase>("AppFibonacci");

            appfin.Start();

            IAppBase apptex = AppLifecycleManager.Resolve <IAppBase>("AppTextFileReader");

            apptex.Start();

            IAppBase appindex = AppLifecycleManager.Resolve <IAppBase>("AppIndex");
            //appindex.Start();

            IAppBase apperror = AppLifecycleManager.Resolve <IAppBase>("AppNotFound");

            apperror.Start();

            while (true)
            {
                ProcessRequest();
            }
        }