Example #1
0
 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"));
     }
 }
Example #2
0
        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();
            }
        }