Exemplo n.º 1
0
        public SyborgTestHttpModuleAppHost()
        {
            IFileSystem               fileSystem          = new WindowsFileSystem();
            IApplicationInfo          applicationInfo     = new ApplicationInfo();
            ITimeService              timeService         = new RealTimeService();
            IRazorCompiler            razorCompiler       = new InMemoryRazorCompiler();
            IRazorViewRenderingEngine viewRenderingEngine = new RazorViewRenderingEngine(fileSystem, razorCompiler);

            IWebServerConfiguration config = new WebServerConfiguration();

            FileMimeTypesMap fileMimeTypesMap = new FileMimeTypesMap().RegisterStandardMimeTypes();

            Initialize(config, fileSystem, applicationInfo, timeService, fileMimeTypesMap, viewRenderingEngine);

            IFileCache fileCache = new FileCache();

            string webAppRootDir;

            if (!WebServerConfiguration.WebServerDevelopmentMode)
            {
#if NCRUNCH
                webAppRootDir = @"D:\hg\ScalableMaps\WebApp\ScalableMaps\ScalableMaps.Web2";
#else
                webAppRootDir = ApplicationInfo.GetAppDirectoryPath("..");
#endif
            }
            else
            {
                webAppRootDir = ApplicationInfo.GetAppDirectoryPath("..");
            }

            ContentCommand    contentCommand = RegisterWebContent(webAppRootDir, fileCache, config);
            TestStreamCommand streamCommand  = new TestStreamCommand();

            AddRoute(new RegexWebRequestRoute("^Content/(?<path>.+)$", HttpMethod.GET, contentCommand));
            AddRoute(new RegexWebRequestRoute("^stream/(?<path>.+)$", HttpMethod.GET, streamCommand));

            AddPolicies(new IWebPolicy[] { new SecureResponseHeadersPolicy() });
        }