public override async Task <bool> Execute(CheckEnvironmentInput input) { AnsiConsole.Render( new FigletText("Oakton") .LeftAligned()); using (var host = input.BuildHost()) { var results = await EnvironmentChecker.ExecuteAllEnvironmentChecks(host.Services); if (input.FileFlag.IsNotEmpty()) { results.WriteToFile(input.FileFlag); Console.WriteLine("Writing environment checks to " + input.FileFlag); } if (results.Failures.Any()) { ConsoleWriter.Write(ConsoleColor.Red, "Some environment checks failed!"); return(false); } else { ConsoleWriter.Write(ConsoleColor.Green, "All environment checks are good!"); return(true); } } }
public override bool Execute(RunInput input) { Host = input.BuildHost(); if (input.CheckFlag) { EnvironmentChecker.ExecuteAllEnvironmentChecks(Host.Services) .GetAwaiter().GetResult() .Assert(); } var assembly = typeof(RunCommand).GetTypeInfo().Assembly; AssemblyLoadContext.GetLoadContext(assembly).Unloading += context => Shutdown(); Console.CancelKeyPress += (sender, eventArgs) => { Shutdown(); eventArgs.Cancel = true; }; using (Host) { Host.Start(); Started.Set(); var shutdownMessage = "Press CTRL + C to quit"; // TODO -- do this with a flag //Console.WriteLine("Running all environment checks..."); //host.ExecuteAllEnvironmentChecks(); IHostingEnvironment service = Host.Services.GetService <IHostingEnvironment>(); Console.WriteLine("Hosting environment: " + service.EnvironmentName); Console.WriteLine("Content root path: " + service.ContentRootPath); ICollection <string> addresses = Host.ServerFeatures.Get <IServerAddressesFeature>()?.Addresses; if (addresses != null) { foreach (string str in addresses) { Console.WriteLine("Now listening on: " + str); } } if (!string.IsNullOrEmpty(shutdownMessage)) { Console.WriteLine(shutdownMessage); } Reset.Wait(); } return(true); }
private static async Task <JasperRuntime> bootstrap(JasperRegistry registry) { if (registry.Logging.UseConsoleLogging) { registry.Services.AddTransient <IMessageLogger, ConsoleMessageLogger>(); registry.Services.AddTransient <ITransportLogger, ConsoleTransportLogger>(); } var timer = new PerfTimer(); timer.Start("Bootstrapping"); timer.Record("Finding and Applying Extensions", () => { applyExtensions(registry); }); timer.Record("Bootstrapping Settings", () => registry.Settings.Bootstrap()); var handlerCompilation = registry.Bus.CompileHandlers(registry, timer); var services = registry.CombinedServices(); var runtime = new JasperRuntime(registry, services, timer); var featureBuilding = registry.BuildFeatures(runtime, timer); await handlerCompilation; await registry.Bus.Activate(runtime, registry.Generation, timer); await featureBuilding; await registry.Startup(runtime); // Run environment checks timer.Record("Environment Checks", () => { var recorder = EnvironmentChecker.ExecuteAll(runtime); if (runtime.Get <BusSettings>().ThrowOnValidationErrors) { recorder.AssertAllSuccessful(); } }); timer.MarkStart("Register Node"); await registerRunningNode(runtime); timer.MarkFinished("Register Node"); timer.Stop(); return(runtime); }
static App() { if (EnvironmentChecker.CheckEnviornment()) { Initializer.ConfigLogger(); Initializer.WriteConfig(); Logger.Info("程序正常启动"); } else { Environment.Exit(0); } }
void Awake() { spriteRenderer = GetComponent <SpriteRenderer>(); body = GetComponent <Rigidbody2D> (); moveCollider = transform.Find("MoveCollider").GetComponent <Collider2D> (); animator = GetComponent <Animator> (); direction = new Direction(Direction4.EAST); environment = gameObject.AddComponent <EnvironmentChecker>(); environment.colliderOffset = (Vector3)moveCollider.offset; connectedRopes = 0; }
public void RunTutorial(int tutorialId) { try { EnvironmentChecker.RunAllChecks(tutorialId); } catch (NoShortcutsAssignedException e) { var shList = (List <string>)e.Data["Shortcuts"]; var listText = shList.Aggregate("\n", (current, sh) => current + sh + "\n"); MessageBox.ShowError( "Some of the ReSharper shortcuts are not assigned:" + listText + "\nPlease assign these shortcuts in 'Tools | Options... | Environment | Keyboard' " + "or apply a keyboard scheme in 'ReSharper | Options... | Environment | Keyboard & Menus' " + "before running the tutorial.", "ReSharper Tutorials"); return; } catch (NoShortcutSchemeSelectedException e) { MessageBox.ShowError( "ReSharper shortcut scheme is not selected! Please select a scheme in " + "ReSharper | Options... | Environment | Keyboard & Menus before running the tutorial.", "ReSharper Tutorials"); return; } var result = MessageBox.ShowYesNo( "This will close your current solution and open the tutorial solution. Run the tutorial?", "ReSharper Tutorials"); if (!result) { return; } var loadingLifetime = Lifetimes.Define(); _solutionStateTracker.AgreeToRunTutorial.Advise(loadingLifetime.Lifetime, () => { var loadingImgPath = _globalSettings.GetGlobalImgPath() + "\\loading20x20.gif"; _homeWindow.EnableButtons(false); _homeWindow.AgreeToRunTutorial(tutorialId, loadingImgPath); }); _solutionStateTracker.AfterSolutionOpened.Advise(loadingLifetime.Lifetime, () => loadingLifetime.Terminate()); TutorialSolutionOpener.OpenTutorialSolution(_solutionStateTracker, tutorialId); }
private void AppStartup(object sender, StartupEventArgs e) { if (EnvironmentChecker.CheckEnviornment()) { Initializer.ConfigLogger(); Initializer.WriteConfig(); Initializer.ClearOldLogs(); Initializer.CheckUpdate(); Logger.Info("程序正常启动"); } else { Environment.Exit(0); } }
public override async Task <bool> Execute(RunInput input) { using (Host = input.BuildHost()) { if (input.CheckFlag) { var report = await EnvironmentChecker.ExecuteAllEnvironmentChecks(Host.Services); report.Assert(); } await Host.RunAsync(); } return(true); }
static void Main(string[] args) { EnvironmentChecker.EnsureIsAdministrator(); HostFactory.New(x => { x.SetServiceName("servicedog"); x.SetDescription("Captures and analyses problems that interfere on the communications between local and remote applications."); x.Service <ServiceRunner>(sc => { sc.ConstructUsing(() => new ServiceRunner(new MessageDispatcher(), new ProcessTable())); sc.WhenStarted(s => s.Start()); sc.WhenStopped(s => s.Stop()); sc.WhenShutdown(s => s.Shutdown()); }); }); }
public void IsValid_EnvironmentInContextNotMatchingChecks_ReturnsFalse() { // Arrange var context = new Context(); context.Add(new EnvironmentContextData { Data = "prodEnv" }); var environmentChecker = new EnvironmentChecker(context); // Act var isValid = environmentChecker.IsValid(new Feature { Name = "some funky feature" }, "test"); // Assert isValid.Should().BeFalse(); }
public void IsValid_ValidEnvironmentInContext_ReturnsTrue() { // Arrange var context = new Context(); context.Add(new EnvironmentContextData { Data = "prodEnv" }); var environmentChecker = new EnvironmentChecker(context); // Act var isValid = environmentChecker.IsValid(new Feature { Name = "some funky feature" }, "prodEnv"); // Assert isValid.Should().BeTrue(); }
private static async Task <JasperRuntime> bootstrap(JasperRegistry registry) { applyExtensions(registry); registry.Settings.Bootstrap(); var features = registry.Features; var serviceRegistries = await Task.WhenAll(features.Select(x => x.Bootstrap(registry))) .ConfigureAwait(false); var collections = new List <IServiceCollection>(); collections.AddRange(serviceRegistries); collections.Add(registry.ExtensionServices); collections.Add(registry.Services); var services = await ServiceCollectionExtensions.Combine(collections.ToArray()); registry.Generation.ReadServices(services); var runtime = new JasperRuntime(registry, services); registry.Http.As <IWebHostBuilder>().UseSetting(WebHostDefaults.ApplicationKey, registry.ApplicationAssembly.FullName); runtime.HttpAddresses = registry.Http.As <IWebHostBuilder>().GetSetting(WebHostDefaults.ServerUrlsKey); await Task.WhenAll(features.Select(x => x.Activate(runtime, registry.Generation))) .ConfigureAwait(false); // Run environment checks var recorder = EnvironmentChecker.ExecuteAll(runtime); if (runtime.Get <BusSettings>().ThrowOnValidationErrors) { recorder.AssertAllSuccessful(); } await registerRunningNode(runtime); return(runtime); }
public override async Task <bool> Execute(CheckEnvironmentInput input) { using (var host = input.BuildHost()) { var results = await EnvironmentChecker.ExecuteAllEnvironmentChecks(host.Services); if (input.FileFlag.IsNotEmpty()) { results.WriteToFile(input.FileFlag); Console.WriteLine("Writing environment checks to " + input.FileFlag); } results.Assert(); ConsoleWriter.Write(ConsoleColor.Green, "All environment checks are good!"); } return(true); }
public override async Task <bool> Execute(RunInput input) { input.ApplyHostBuilderInput(); input.HostBuilder.ConfigureServices(services => services.AddHostedService <Job1>()); using (Host = input.BuildHost()) { if (input.CheckFlag) { var report = await EnvironmentChecker.ExecuteAllEnvironmentChecks(Host.Services); report.Assert(); } await Host.RunAsync(); } return(true); }
private void InstallSkin(object sender, EventArgs e) { var linkToSelected = (SkinLink)SkinsListBox.SelectedItem; var skin = linkToSelected.Load(); if (skin == null) { MessageBox.Show("Can not install nothing. Please, select skin in list on left form side or add new skin and try again", "Installation Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (cleanInstallCheck.Checked) { Clean(EnvironmentalVeriables.gamePath); InstallSkin(skinPackager.Decompile(@"Skins\default.askin"), forcedInstall: true); } InstallSkin(skin); EnvironmentChecker.SaveState(EnvironmentalVeriables.gamePath, skin.Name); GetCurrentlyInstalledSkinDirect(); MessageBox.Show("Done!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); }
public async override Task <bool> Execute(RunInput input) { using (var host = input.BuildHost()) { if (input.CheckFlag) { (await EnvironmentChecker.ExecuteAllEnvironmentChecks(host.Services)).Assert(); } var reset = new ManualResetEventSlim(); AssemblyLoadContext.GetLoadContext(typeof(RunCommand).GetTypeInfo().Assembly).Unloading += (Action <AssemblyLoadContext>)(context => reset.Set()); Console.CancelKeyPress += (ConsoleCancelEventHandler)((sender, eventArgs) => { reset.Set(); eventArgs.Cancel = true; }); await host.StartAsync(); reset.Wait(); await host.StopAsync(); } return(true); }
public IServiceProvider ConfigureServices(IServiceCollection services) { var others = services .Where(x => x.ServiceType == typeof(IStartup)) .Where(x => x.ImplementationInstance != this).ToArray(); services.RemoveAll(s => others.Contains(s)); var combined = _runtime.Registry.CombineServices(services); combined.AddSingleton(_runtime); // TODO -- need to pass in the perf timer here _runtime.Container = new Container(combined); _startups = others.Select(x => Build(_runtime.Container, x)).ToArray(); var additional = new ServiceCollection(); // I know this is goofy as all hell, but there is code // in MVC that tries to pick things out of the service collection // during bootstrapping additional.AddRange(services); foreach (var startup in _startups) { startup.ConfigureServices(additional); } // See the rant-y comment above additional.RemoveAll(services.Contains); _runtime.Container.Configure(additional); if (!_runtime.Container.Model.HasRegistrationFor <IServer>()) { _runtime.Container.Configure(x => x.AddSingleton <IServer>(new NulloServer())); } if (_runtime.Registry.HttpRoutes.Enabled) { _runtime .Registry .HttpRoutes .FindRoutes(_runtime, _runtime.Registry, _timer) .GetAwaiter() .GetResult(); } _handlerCompilation.GetAwaiter().GetResult(); // Run environment checks _timer.Record("Environment Checks", () => { var recorder = EnvironmentChecker.ExecuteAll(_runtime); if (_runtime.Registry.MessagingSettings.ThrowOnValidationErrors) { recorder.AssertAllSuccessful(); } }); _timer.Stop(); return(_runtime.Container); }
private static async Task <JasperRuntime> bootstrap(JasperRegistry registry) { var timer = new PerfTimer(); timer.Start("Bootstrapping"); timer.Record("Finding and Applying Extensions", () => { applyExtensions(registry); }); var buildingServices = Task.Factory.StartNew(() => { return(timer.Record("Combining Services and Building Settings", registry.CompileConfigurationAndServicesForIdiomaticBootstrapping)); }); var handlerCompilation = registry.Messaging.CompileHandlers(registry, timer); var runtime = new JasperRuntime(registry, timer); var services = await buildingServices; services.AddSingleton(runtime); var container = await Lamar.Container.BuildAsync(services, timer); container.DisposalLock = DisposalLock.Ignore; runtime.Container = container; var routeDiscovery = registry.HttpRoutes.Enabled ? registry.HttpRoutes.FindRoutes(runtime, registry, timer) : Task.CompletedTask; runtime.buildAspNetCoreServer(services); await routeDiscovery; await Task.WhenAll(runtime.startAspNetCoreServer(), handlerCompilation, runtime.startHostedServices()); // Run environment checks timer.Record("Environment Checks", () => { var recorder = EnvironmentChecker.ExecuteAll(runtime); if (runtime.Settings.ThrowOnValidationErrors) { recorder.AssertAllSuccessful(); } }); _lifetime = TypeExtensions.As <ApplicationLifetime>(container.GetInstance <IApplicationLifetime>()); _lifetime.NotifyStarted(); timer.Stop(); return(runtime); }
public void SetLandChecker() { landSize = new Vector2(thisCollider.bounds.size.x, thisCollider.bounds.size.y * 0.1f); landStart = new Vector2(thisCollider.bounds.center.x, thisCollider.bounds.center.y - thisCollider.bounds.extents.y); land = new EnvironmentChecker(thisObject, landStart, landSize, thisCollider.bounds.size.y * 0.1f, Vector2.down, whatIsGround); }
public void SetLedgeChecker() { ledgeSize = new Vector2(thisCollider.bounds.size.y / 10.0f, thisCollider.bounds.size.y * 0.4f); ledgeStart = new Vector2(thisCollider.bounds.center.x + thisCollider.bounds.extents.x + ledgeSize.x / 2, thisCollider.bounds.center.y + thisCollider.bounds.extents.y * 0.9f); ledge = new EnvironmentChecker(thisObject, ledgeStart, ledgeSize, thisCollider.bounds.size.y * 0.1f, facingRight ? Vector2.right : Vector2.left, landLayer); }
public void SetWallChecker() { wallSize = new Vector2(thisCollider.bounds.size.y / 10.0f, thisCollider.bounds.size.y * 0.4f); wallStart = new Vector2(thisCollider.bounds.center.x + thisCollider.bounds.extents.x + wallSize.x / 2, thisCollider.bounds.center.y + thisCollider.bounds.extents.y * 0.1f); wall = new EnvironmentChecker(thisObject, wallStart, wallSize, thisCollider.bounds.size.y * 0.1f, facingRight ? Vector2.right : Vector2.left, landLayer); }
public void SetStepChecker() { stepSize = new Vector2(thisCollider.bounds.size.y / 10.0f, thisCollider.bounds.size.y * 0.2f); stepStart = new Vector2(thisCollider.bounds.center.x + thisCollider.bounds.extents.x + stepSize.x / 2, thisCollider.bounds.center.y - thisCollider.bounds.extents.y * 0.8f); step = new EnvironmentChecker(thisObject, stepStart, stepSize, thisCollider.bounds.size.y * 0.1f, facingRight? Vector2.right: Vector2.left, landLayer); }
private void FixCurrentState(string stateName) { EnvironmentChecker.SaveState(EnvironmentalVeriables.gamePath, stateName); }
public void EnsureConfiguration() { EnvironmentChecker.EnsureIsAdministrator(); }