public void InitProvider(StonehengeHostOptions options) { foreach (var loader in Loaders) { loader.InitProvider(options); } }
public VueAppCreator(string appTitle, string rootPage, StonehengeHostOptions options, Dictionary <string, Resource> vueContent) { _appTitle = appTitle; _rootPage = rootPage; _options = options; _vueContent = vueContent; }
// ReSharper disable once UnusedMember.Global public Startup(IConfiguration configuration, IStonehengeResourceProvider resourceLoader) { Configuration = configuration; _resourceLoader = resourceLoader; _appTitle = Configuration["AppTitle"]; _options = JsonConvert.DeserializeObject <StonehengeHostOptions>(Configuration["HostOptions"]); }
public void Host_StartupOk_RespondsOnHttpRequest() { const string content = "<h1>Test</h1>"; var options = new StonehengeHostOptions { Title = "Test" }; var loader = new TestResourceLoader(content); var host = new KestrelHost(loader, options); var startOk = host.Start("localhost", 32001); Assert.True(startOk, "Start failed"); var response = string.Empty; try { using var client = new RedirectableWebClient(); response = client.DownloadString(host.BaseUrl); } catch (Exception ex) { _logger.LogError(ex, nameof(Host_StartupOk_RespondsOnHttpRequest)); } Assert.Equal(content, response); host.Terminate(); }
public void InitProvider(StonehengeResourceLoader loader, StonehengeHostOptions options) { foreach (var provider in Providers) { provider.InitProvider(loader, options); } }
private static void Main(string[] args) { Console.WriteLine(@"nossued website"); // client framework (use Vue.js) var vue = new VueResourceProvider(); var provider = StonehengeResourceLoader.CreateDefaultLoader(vue); // options var options = new StonehengeHostOptions { Title = "NOSSUED", StartPage = "home", ServerPushMode = ServerPushModes.LongPolling, PollIntervalMs = 5000 }; // hosting var host = new KestrelHost(provider, options); if (!host.Start("localhost", 32000)) { Console.WriteLine(@"Failed to start server on: " + host.BaseUrl); Environment.Exit(1); } // wait for user pressing Ctrl+C to terminate var terminate = new AutoResetEvent(false); Console.CancelKeyPress += (sender, eventArgs) => { terminate.Set(); }; Console.WriteLine(@"Started server on: " + host.BaseUrl); terminate.WaitOne(); Console.WriteLine(@"Server terminated."); host.Terminate(); }
public AureliaAppCreator(string appTitle, string rootPage, StonehengeHostOptions options, Dictionary <string, Resource> aureliaContent) { _appTitle = appTitle; _rootPage = rootPage; _options = options; _aureliaContent = aureliaContent; }
public KestrelHost(IStonehengeResourceProvider loader, StonehengeHostOptions options) { _resourceLoader = loader; Options = options; loader.InitProvider(options); }
// ReSharper disable once MemberCanBePrivate.Global public KestrelHost(IStonehengeResourceProvider provider, StonehengeHostOptions options, ILogger logger) { _resourceProvider = provider; _options = options; _logger = logger; provider.InitProvider(provider as StonehengeResourceLoader, options); }
// ReSharper disable once MemberCanBePrivate.Global public SimpleHttpHost(IStonehengeResourceProvider loader, StonehengeHostOptions options, IStonehengeSessionCache cache) { _resourceLoader = loader; Options = options; _sessionCache = cache; loader.InitProvider(options); }
public ControllerCreationTests() { _options = new StonehengeHostOptions(); _vue = new VueResourceProvider(StonehengeLogger.DefaultLogger); _loader = StonehengeResourceLoader.CreateDefaultLoader(StonehengeLogger.DefaultLogger, _vue); _loader.InitProvider(_loader, _options); _loader.Services.AddService(typeof(DiDependency), new DiDependency()); _session = new AppSession(_loader, _options); }
// ReSharper disable once UnusedParameter.Local private static void Main(string[] args) { Console.WriteLine("Sample showing stonehenge on Chromely"); // stonehenge backend var options = new StonehengeHostOptions { Title = "Demo" }; var provider = StonehengeResourceLoader .CreateDefaultLoader(new VueResourceProvider()); var host = new KestrelHost(provider, options); if (!host.Start(options.Title, false, "localhost", 8888)) { Console.WriteLine("Failed to start stonehenge server"); } // ensure CEF runtime files are present var path = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) ?? "."; Directory.SetCurrentDirectory(path); try { CefRuntime.Load(); } catch (Exception ex) { Console.WriteLine("Failed to load runtime: " + ex.Message); Console.WriteLine("Installing CEF runtime from " + CefLoader.CefBuildsDownloadUrl); CefLoader.Load(); } // chromely frontend var startUrl = host.BaseUrl; var config = ChromelyConfiguration .Create() .WithHostMode(WindowState.Normal, true) .WithHostTitle(options.Title) //.WithHostIconFile("chromely.ico") .WithAppArgs(args) .WithHostSize(1000, 600) .WithStartUrl(startUrl); using (var window = new CefGlueBrowserWindow(config)) { var exitCode = window.Run(args); if (exitCode != 0) { Console.WriteLine("Failed to start chromely frontend: code " + exitCode); } } Console.WriteLine("Demo done."); }
public StonehengeUi(ILogger logger, StonehengeHostOptions options, Assembly appAssembly) { _options = options; StonehengeLogger.DefaultLevel = LogLevel.Trace; Logger = logger; var vue = new VueResourceProvider(Logger); _loader = StonehengeResourceLoader.CreateDefaultLoader(Logger, vue, appAssembly); }
public void InitProvider(StonehengeHostOptions options) { _vueContent = new Dictionary <string, Resource>(); var appCreator = new VueAppCreator(options.Title, options.StartPage, options, _vueContent); AddFileSystemContent(options.AppFilesPath); AddResourceContent(); appCreator.CreateApplication(); appCreator.CreateComponents(); }
private static void Main(string[] args) { Trace.Listeners.Add(new TextWriterTraceListener(Console.Out)); var path = ApplicationInfo.ApplicationDirectory; Directory.SetCurrentDirectory(path); var settingsFile = new Profile(Path.Combine(path, "GitState.cfg")); new ProfileClassLoader().LoadClass(Settings, settingsFile); // Starting stonehenge backend var options = new StonehengeHostOptions { Title = "GitState", StartPage = "main", ServerPushMode = ServerPushModes.LongPolling, PollIntervalSec = 10 }; var logger = Logger.DefaultFactory.CreateLogger("GitState"); var provider = StonehengeResourceLoader .CreateDefaultLoader(logger, new VueResourceProvider(logger)); var host = new KestrelHost(provider, options); if (!host.Start("localhost", 8880)) { Console.WriteLine("Failed to start stonehenge server"); } // Starting chromely frontend Console.WriteLine("Starting chromely frontend"); var config = DefaultConfiguration.CreateForRuntimePlatform(); config.CefDownloadOptions = new CefDownloadOptions(true, true); config.StartUrl = host.BaseUrl; config.WindowOptions = new WindowOptions { Title = "GitState", Size = new WindowSize(Settings.WindowWidth, Settings.WindowHeight), RelativePathToIconFile = "GitState.ico" }; config.DebuggingMode = true; AppBuilder .Create() .UseApp <ChromelyBasicApp>() .UseConfig <IChromelyConfiguration>(config) .Build() .Run(args); Console.ReadLine(); Console.WriteLine("GitState done."); }
private static void Main() { Console.WriteLine("NOSSUED InfoScreenServer"); var cfgFile = Path.Combine(Application.GetApplicationDirectory(), "InfoScreen.cfg"); var profile = new Profile(cfgFile); var settings = new InfoSettings(); var spp = new ClassPropertyProvider(settings); spp.SetProperties(profile["Event"].Properties); spp.SetProperties(profile["Twitter"].Properties); Console.WriteLine($"Event {settings.Name}, Keyword = {settings.Keywords}"); var key = ""; //Environment.GetEnvironmentVariable("twitter-key"); var secret = ""; //Environment.GetEnvironmentVariable("twitter-secret"); _client = new TwitterClient(settings); if (string.IsNullOrEmpty(key) || string.IsNullOrEmpty(secret)) { Console.WriteLine("Missing twitter auth - start demo mode"); var tweets = Path.Combine(Application.GetApplicationDirectory(), "DemoTweets.json"); var json = File.ReadAllText(tweets); _client.Tweets = JsonConvert.DeserializeObject <List <TwitterMessage> >(json); } else { _client.Connect(key, secret); } var vue = new VueResourceProvider(); var provider = StonehengeResourceLoader.CreateDefaultLoader(vue); provider.Services.AddService(typeof(TwitterClient), _client); provider.Services.AddService(typeof(InfoSettings), settings); var options = new StonehengeHostOptions { Title = settings.Name }; var host = new KestrelHost(provider, options); host.Start("localhost", 32000); Process.Start(new ProcessStartInfo(host.BaseUrl) { UseShellExecute = true }); Console.ReadLine(); _client.Dispose(); }
static void Main(string[] args) { Console.WriteLine("SunSpec Explorer"); var consoleListener = new ConsoleTraceListener(); Trace.Listeners.Add(consoleListener); var options = new StonehengeHostOptions { Title = "SunSpec Explorer", StartPage = "explorer", ServerPushMode = ServerPushModes.LongPolling, PollIntervalMs = 5000 }; var vue = new VueResourceProvider(); var provider = StonehengeResourceLoader.CreateDefaultLoader(vue); //provider.Services.AddService(typeof(InformantEngine), _engine); var host = new KestrelHost(provider, options); if (!host.Start("localhost", 8080)) { Console.WriteLine("Failed to start stonehenge server"); } var config = DefaultConfiguration.CreateForRuntimePlatform(); config.CefDownloadOptions = new CefDownloadOptions { AutoDownloadWhenMissing = true, DownloadSilently = true }; config.WindowOptions = new WindowOptions { Title = " ", //RelativePathToIconFile = "Informant.ico", Size = new WindowSize( (int)(1000 * Display.GetScalingFactor()), (int)(600 * Display.GetScalingFactor())) }; config.DebuggingMode = true; config.StartUrl = host.BaseUrl; AppBuilder .Create() .UseConfiguration <IChromelyConfiguration>(config) .UseApp <ChromelyBasicApp>() .Build() .Run(args); }
public VueAppCreator(ILogger logger, StonehengeResourceLoader loader, StonehengeHostOptions options, Assembly appAssembly, Dictionary <string, Resource> vueContent) { _logger = logger; _loader = loader; _options = options; _appAssembly = appAssembly; _vueContent = vueContent; _vueAssembly = Assembly.GetAssembly(typeof(VueAppCreator)); _controllerTemplate = LoadResourceText(_vueAssembly, "IctBaden.Stonehenge3.Vue.Client.stonehengeComponent.js"); _elementTemplate = LoadResourceText(_vueAssembly, "IctBaden.Stonehenge3.Vue.Client.stonehengeElement.js"); }
public void Host_MultipleInstances_StartupOk_RespondsOnHttpRequest() { const string content1 = "<h1>Test 01</h1>"; const string content2 = "<h1>Test II</h1>"; var options = new StonehengeHostOptions { Title = "Test" }; var loader1 = new TestResourceLoader(content1); var host1 = new KestrelHost(loader1, options); var startOk = host1.Start("localhost", 32002); Assert.True(startOk, "Start host1 failed"); var loader2 = new TestResourceLoader(content2); var host2 = new KestrelHost(loader2, options); startOk = host2.Start("localhost", 32003); Assert.True(startOk, "Start host2 failed"); Assert.NotEqual(host1.BaseUrl, host2.BaseUrl); var response1 = string.Empty; var response2 = string.Empty; try { using (var client = new RedirectableWebClient()) { response1 = client.DownloadString(host1.BaseUrl); } using (var client = new RedirectableWebClient()) { response2 = client.DownloadString(host2.BaseUrl); } } catch (Exception ex) { _logger.LogError(ex, nameof(Host_MultipleInstances_StartupOk_RespondsOnHttpRequest)); Assert.True(false, ex.Message); } Assert.Equal(content1, response1); Assert.Equal(content2, response2); host1.Terminate(); host2.Terminate(); }
public void InitProvider(StonehengeHostOptions options) { _aureliaContent = new Dictionary <string, Resource>(); var appCreator = new AureliaAppCreator(options.Title, options.StartPage, options, _aureliaContent); if (!string.IsNullOrEmpty(options.AppFilesPath)) { AddFileSystemContent(options.AppFilesPath); } AddResourceContent(); appCreator.CreateApplication(); appCreator.CreateControllers(); appCreator.CreateElements(); }
public void InitProvider(StonehengeResourceLoader loader, StonehengeHostOptions options) { _vueContent = new Dictionary <string, Resource>(); if (loader?.Providers .FirstOrDefault(p => p.GetType() == typeof(ResourceLoader)) is ResourceLoader resourceLoader) { _assemblies = resourceLoader.ResourceAssemblies; _appAssembly = resourceLoader.AppAssembly; } var appCreator = new VueAppCreator(_logger, loader, options, _appAssembly, _vueContent); AddFileSystemContent(options.AppFilesPath); AddResourceContent(); appCreator.CreateApplication(); appCreator.CreateComponents(loader); }
// ReSharper disable once UnusedParameter.Local private static void Main(string[] args) { Console.WriteLine("IctBaden.Modbus.SampleDevice"); Trace.Listeners.Add(new TronTraceListener(true)); var logger = Framework.Logging.Logger.DefaultFactory.CreateLogger("Modbus"); var source = new TestData(); var device = new ModbusSlave("Sample", source, 1502, 1); device.Start(); var options = new StonehengeHostOptions { Title = "Modbus", StartPage = "device", ServerPushMode = ServerPushModes.LongPolling, PollIntervalSec = 5 }; var vue = new VueResourceProvider(logger); var provider = StonehengeResourceLoader.CreateDefaultLoader(logger, vue); provider.Services.AddService(typeof(TestData), source); provider.Services.AddService(typeof(ModbusSlave), device); var host = new KestrelHost(provider, options); if (!host.Start("*", 0)) { Console.WriteLine("Failed to start stonehenge server"); return; } var wnd = new HostWindow(host.BaseUrl, "Modbus", new Point(600, 800)); if (!wnd.Open()) { Console.WriteLine("Failed to open window"); } Console.WriteLine("Done."); }
public StonehengeUi(ILogger logger, StonehengeHostOptions options) : this(logger, options, Assembly.GetEntryAssembly()) { }
public KestrelHost(IStonehengeResourceProvider provider, StonehengeHostOptions options) : this(provider, options, StonehengeLogger.DefaultLogger) { }
public SimpleHttpHost(IStonehengeResourceProvider loader, StonehengeHostOptions options) : this(loader, options, new MemoryCache()) { }
public void InitProvider(StonehengeHostOptions options) { }
private static void Main() { Trace.Listeners.Add(new System.Diagnostics.ConsoleTraceListener()); StonehengeLogger.DefaultLevel = LogLevel.Trace; var logger = LoggerFactory.CreateLogger("stonehenge"); Console.WriteLine(@""); Console.WriteLine(@"Stonehenge 3 sample"); Console.WriteLine(@""); logger.LogInformation("Vue.SampleCore started"); // select hosting options var options = new StonehengeHostOptions { Title = "VueSample", ServerPushMode = ServerPushModes.LongPolling, PollIntervalSec = 10, SessionIdMode = SessionIdModes.Automatic, HandleWindowResized = true // SslCertificatePath = Path.Combine(StonehengeApplication.BaseDirectory, "stonehenge.pfx"), // SslCertificatePassword = "******" }; // Select client framework Console.WriteLine(@"Using client framework vue"); var vue = new VueResourceProvider(logger); var loader = StonehengeResourceLoader.CreateDefaultLoader(logger, vue); loader.Services.AddService(typeof(ILogger), logger); // Select hosting technology var hosting = "kestrel"; if (Environment.CommandLine.Contains("/simple")) { hosting = "simple"; } switch (hosting) { case "kestrel": Console.WriteLine(@"Using Kestrel hosting"); _server = new KestrelHost(loader, options); break; case "simple": Console.WriteLine(@"Using simple http hosting"); _server = new SimpleHttpHost(loader, options); break; } Console.WriteLine(@"Starting server"); var terminate = new AutoResetEvent(false); Console.CancelKeyPress += (_, _) => { terminate.Set(); }; var host = Environment.CommandLine.Contains("/localhost") ? "localhost" : "*"; if (_server.Start(host, 32000)) { Console.WriteLine(@"Server reachable on: " + _server.BaseUrl); if (Environment.CommandLine.Contains("/window")) { using var wnd = new HostWindow(_server.BaseUrl, options.Title); if (!wnd.Open()) { logger.LogError("Failed to open main window"); terminate.Set(); } } else { terminate.WaitOne(); } Console.WriteLine(@"Server terminated."); } else { Console.WriteLine(@"Failed to start server on: " + _server.BaseUrl); } #pragma warning disable 0162 // ReSharper disable once HeuristicUnreachableCode _server.Terminate(); Console.WriteLine(@"Exit sample app"); Environment.Exit(0); }
private static void Main() { var consoleListener = new ConsoleTraceListener(); Trace.Listeners.Add(consoleListener); Console.WriteLine(@""); Console.WriteLine(@"Stonehenge 3 sample"); Console.WriteLine(@""); // Select client framework Console.WriteLine(@"Using client framework aurelia"); var loader = StonehengeResourceLoader.CreateDefaultLoader(new AureliaResourceProvider()); var options = new StonehengeHostOptions { Title = "Sample", StartPage = "start", SessionIdMode = SessionIdModes.CookiesOnly }; // Select hosting technology var hosting = "kestrel"; if (Environment.CommandLine.Contains("/Simple")) { hosting = "simple"; } switch (hosting) { case "kestrel": Console.WriteLine(@"Using Kestrel hosting"); _server = new KestrelHost(loader, options); break; case "simple": Console.WriteLine(@"Using simple http hosting"); _server = new SimpleHttpHost(loader, options); break; } Console.WriteLine(@"Starting server"); var terminate = new AutoResetEvent(false); Console.CancelKeyPress += (sender, eventArgs) => { terminate.Set(); }; var host = Environment.CommandLine.Contains("/localhost") ? "localhost" : "*"; if (_server.Start(host, 32000)) { Console.WriteLine(@"Started server on: " + _server.BaseUrl); var wnd = new HostWindow(_server); if (!wnd.Open()) { Trace.TraceError("Failed to open main window."); terminate.WaitOne(); } Console.WriteLine(@"Server terminated."); } else { Console.WriteLine(@"Failed to start server on: " + _server.BaseUrl); } #pragma warning disable 0162 // ReSharper disable once HeuristicUnreachableCode _server.Terminate(); Environment.Exit(0); }
public void InitProvider(StonehengeResourceLoader loader, StonehengeHostOptions options) { }