Пример #1
0
        public static int Main(string[] args)
        {
            Stopwatch commandStopwatch = new Stopwatch();

            commandStopwatch.Start();

            XmlConfigurator.Configure();

            IRazorCompiler razorCompiler = new InMemoryRazorCompiler();

            IFileSystem fileSystem = new WindowsFileSystem();
            //IFtpChannelFactory ftpChannelFactory = new FtpChannelFactoryUsingSockets ();
            //IFtpCommunicator ftpCommunicator = new FtpCommunicator ();
            //IFtpSessionFactory ftpSessionFactory = new FtpSessionFactory(ftpChannelFactory, ftpCommunicator, fileSystem);
            IFreudeTemplatingEngine freudeTemplatingEngine = new FreudeTemplatingEngine(razorCompiler);
            IWikiTextTokenizer      wikiTextTokenizer      = new WikiTextTokenizer();
            IFreudeTextParser       freudeTextParser       = new FreudeTextParser(wikiTextTokenizer);
            IProjectBuilder         projectBuilder         = new ProjectBuilder(fileSystem);

            ConsoleShell consoleShell = new ConsoleShell("Freude.Engine.exe");

            consoleShell.RegisterCommand(new BuildCommand(fileSystem, projectBuilder, freudeTextParser, freudeTemplatingEngine));
            //consoleShell.RegisterCommand (new DeployCommand(projectBuilder, ftpSessionFactory));

            try
            {
                ConsoleShellResult consoleShellResult = consoleShell.ParseCommandLine(args);

                if (consoleShellResult.ExitCode.HasValue)
                {
                    return(consoleShellResult.ExitCode.Value);
                }

                foreach (IConsoleCommand consoleCommand in consoleShellResult.CommandsToExecute)
                {
                    consoleCommand.Execute(consoleShell);
                }

                TimeSpan elapsed = commandStopwatch.Elapsed;
                log.InfoFormat("Command done in {0}", elapsed);

                return(0);
            }
            catch (Exception ex)
            {
                log.Fatal("Program failed", ex);
                return(1);
            }
        }
Пример #2
0
        public void Setup()
        {
            IFileSystem    fileSystem    = new WindowsFileSystem();
            IRazorCompiler razorCompiler = new InMemoryRazorCompiler();

            engine = new RazorViewRenderingEngine(fileSystem, razorCompiler);

            RazorEngineCompileSettings razorEngineCompileSettings = new RazorEngineCompileSettings();

            razorEngineCompileSettings.DefaultNamespace = "Syborg.Tests";
            razorEngineCompileSettings.DefaultClassName = "SyborgTestRazorTemplate";
            razorEngineCompileSettings.NamespaceImports.Add("System");
            razorEngineCompileSettings.NamespaceImports.Add("System.Collections");
            razorEngineCompileSettings.NamespaceImports.Add("System.Collections.Generic");
            razorEngineCompileSettings.DefaultBaseClass = typeof(RazorTemplateBase).FullName;
            razorEngineCompileSettings.ReferenceAssemblies.Add(typeof(HtmlString).Assembly);
            razorEngineCompileSettings.DebugMode = DebugMode;

            engine.Initialize("Views", razorEngineCompileSettings);
        }
Пример #3
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() });
        }
Пример #4
0
        public void Setup()
        {
            IFileSystem      fileSystem      = new WindowsFileSystem();
            IApplicationInfo applicationInfo = new ApplicationInfo();
            ITimeService     timeService     = new RealTimeService();

            ISignal serverStopSignal = new ManualResetSignal(false);

            IWebServerConfiguration configuration = new WebServerConfiguration();

            IRazorCompiler            razorCompiler       = new InMemoryRazorCompiler();
            IRazorViewRenderingEngine viewRenderingEngine = new RazorViewRenderingEngine(fileSystem, razorCompiler);

            IWebServerController webServerController = new WebServerController(serverStopSignal);
            IFileMimeTypesMap    fileMimeTypesMap    = new FileMimeTypesMap();
            IFileCache           fileCache           = new FileCache();

            List <IWebRequestRoute> routes      = new List <IWebRequestRoute>();
            string         contentRootDirectory = Path.Combine(TestContext.CurrentContext.TestDirectory, "sample-content");
            ContentCommand contentCommand       = new ContentCommand(contentRootDirectory, fileSystem, fileCache);

            routes.Add(new RegexWebRequestRoute("^content/(?<path>.+)$", HttpMethod.GET, contentCommand));

            // ReSharper disable once CollectionNeverUpdated.Local
            List <IWebPolicy> policies = new List <IWebPolicy>();

            const string ExternalUrl = "http://localhost";
            const int    Port        = 12345;

            testServiceUrl = "{0}:{1}/".Fmt(ExternalUrl, Port);

            host = new TestHost(
                configuration, ExternalUrl, Port, null, fileSystem, applicationInfo, timeService, viewRenderingEngine, fileMimeTypesMap, webServerController, routes, policies);
            host.Start();

            IWebConfiguration webConfiguration = new WebConfiguration("Syborg.Tests");

            restClientFactory = new RestClientFactory(webConfiguration);
        }
Пример #5
0
 public void Setup()
 {
     razorCompiler = new InMemoryRazorCompiler();
 }