private void OnStartupCommand(object sender, ExecutedRoutedEventArgs e) { e.Handled = true; StartupParameters param = (StartupParameters)e.Parameter; switch (param.Command) { case eStartupCommand.New: NewProject(); break; case eStartupCommand.Open: OpenProject(); break; case eStartupCommand.QuickOpen: OpenProject(param.File); break; case eStartupCommand.Help: DisplayHelpDocument(@"Help\ReflectionStudio.Help.xps"); break; case eStartupCommand.HelpTechnical: DisplayHelpDocument(@"Help\ReflectionStudio.Technical.xps"); break; case eStartupCommand.Sample: OpenProject(param.File); break; } }
public int[] GetRecordsIndexToScan(StartupParameters request, ushort[] recordsStatus) { if (request == null || recordsStatus.Length < 1) { throw new Exception("Invalid arguments for 'GetRecordsIndexToScan' method"); } var avaliableRecordsRange = Enumerable.Range(recordsStatus[0], (recordsStatus[1] - recordsStatus[0] + 1)); var firstIndexRequestExists = avaliableRecordsRange.Contains(request.FirstIndex); var lastIndexRequestExists = avaliableRecordsRange.Contains(request.LastIndex); if (firstIndexRequestExists && lastIndexRequestExists) { return(new int[] { request.FirstIndex, request.LastIndex }); } else if (firstIndexRequestExists == false && lastIndexRequestExists) { return(new int[] { recordsStatus[0], request.LastIndex }); } else if (firstIndexRequestExists && lastIndexRequestExists == false) { return(new int[] { request.FirstIndex, recordsStatus[1] }); } else if (request.FirstIndex < recordsStatus[0] && request.LastIndex > recordsStatus[1]) { return(new int[] { recordsStatus[0], recordsStatus[1] }); } else { throw new Exception("O Intervalo informado está fora dos limites disponíveis para leitura!"); } }
public TestWindow(StartupParameters startupParameters) { InitializeComponent(); WebPageViewer viewer = new WebPageViewer(startupParameters.Domain + "/miyun/clientTeaTest.aspx?liveid=" + startupParameters.LiveId, startupParameters.Domain, startupParameters.Guid); MainGrid.Children.Insert(0, viewer); }
public static StartupParameters Create(string[] args) { logger.Debug("CommandLine: " + string.Join(" ", args)); StartupParameters startupParams = new StartupParameters(); foreach (var arg in args) { var _arg = arg?.ToLower(); if (_arg == "-norestart") { startupParams.NoRestart = true; } else if (_arg == "-system") { startupParams.RunAsSystem = true; } else { //... } } using (var wi = System.Security.Principal.WindowsIdentity.GetCurrent()) { startupParams.UserName = wi.Name; startupParams.IsElevated = (wi.Owner != wi.User); startupParams.IsSystem = wi.IsSystem; logger.Info(startupParams.ToString()); } return(startupParams); }
public BoundaryRegistry(StartupParameters parameters) { For <HttpClient>().Use(_ => new HttpClient()).Singleton(); SetupLocalDependencies(parameters); SetupAwsDependencies(parameters); }
private void SetupAwsDependencies(StartupParameters parameters) { var region = AwsStartup.ParseRegion(parameters.AwsRegion); var creds = AwsStartup.CredentialsWithFallback( parameters.AwsAccessKey, parameters.AwsSecretKey, parameters.AwsProfile); For <IAmazonDynamoDB>() .Use(ctx => new AmazonDynamoDBClient(creds, CreateClientConfig <AmazonDynamoDBConfig>(region, ctx.GetInstance <HttpClient>()))) .Singleton(); For <IAmazonCloudWatch>() .Use(ctx => new AmazonCloudWatchClient(creds, CreateClientConfig <AmazonCloudWatchConfig>(region, ctx.GetInstance <HttpClient>()))) .Singleton(); For <IAmazonSimpleNotificationService>() .Use(ctx => new AmazonSimpleNotificationServiceClient(creds, CreateClientConfig <AmazonSimpleNotificationServiceConfig>(region, ctx.GetInstance <HttpClient>()))) .Singleton(); For <IAmazonRDS>() .Use(ctx => new AmazonRDSClient(creds, CreateClientConfig <AmazonRDSConfig>(region, ctx.GetInstance <HttpClient>()))) .Singleton(); For <IAmazonAutoScaling>() .Use(ctx => new AmazonAutoScalingClient(creds, CreateClientConfig <AmazonAutoScalingConfig>(region, ctx.GetInstance <HttpClient>()))) .Singleton(); For <IAmazonCloudFormation>() .Use(ctx => new AmazonCloudFormationClient(creds, CreateClientConfig <AmazonCloudFormationConfig>(region, ctx.GetInstance <HttpClient>()))) .Singleton(); For <IAmazonLambda>() .Use(ctx => new AmazonLambdaClient(creds, CreateClientConfig <AmazonLambdaConfig>(region, ctx.GetInstance <HttpClient>()))) .Singleton(); For <IAmazonEC2>() .Use(ctx => new AmazonEC2Client(creds, CreateClientConfig <AmazonEC2Config>(region, ctx.GetInstance <HttpClient>()))) .Singleton(); For <IAmazonElasticLoadBalancing>() .Use(ctx => new AmazonElasticLoadBalancingClient(creds, CreateClientConfig <AmazonElasticLoadBalancingConfig>(region, ctx.GetInstance <HttpClient>()))) .Singleton(); For <IAmazonElasticLoadBalancingV2>() .Use(ctx => new AmazonElasticLoadBalancingV2Client(creds, CreateClientConfig <AmazonElasticLoadBalancingV2Config>(region, ctx.GetInstance <HttpClient>()))) .Singleton(); For <IAmazonS3>() .Use(ctx => new AmazonS3Client(creds, CreateClientConfig <AmazonS3Config>(region, ctx.GetInstance <HttpClient>()))) .Singleton(); For <IAmazonStepFunctions>() .Use(ctx => new AmazonStepFunctionsClient(creds, CreateClientConfig <AmazonStepFunctionsConfig>(region, ctx.GetInstance <HttpClient>()))) .Singleton(); For <IAmazonCloudWatch>() .Use(ctx => new AmazonCloudWatchClient(creds, CreateClientConfig <AmazonCloudWatchConfig>(region, ctx.GetInstance <HttpClient>()))) .Singleton(); }
public IContainer ConfigureContainer(StartupParameters parameters) { var registry = new Registry(); registry.IncludeRegistry(new ApplicationRegistry(parameters)); registry.IncludeRegistry <AwsServiceRegistry>(); registry.IncludeRegistry(new BoundaryRegistry(parameters)); return(new Container(registry)); }
public void GetRecordsIndexToScan_AvaliableIndexIsNull() { var endpoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 10002); var startupParameters = new StartupParameters { EndPoint = endpoint, FirstIndex = 0, LastIndex = 100 }; var avaliableIndex = new ushort[] { 300, 500 }; var range = RecordHandler.GetRecordsIndexToScan(startupParameters, null); }
public void GetRecordsIndexToScan_RequestedIndexAfterOfAvaliableRange() { var endpoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 10002); var startupParameters = new StartupParameters { EndPoint = endpoint, FirstIndex = 900, LastIndex = 1000 }; var avaliableIndex = new ushort[] { 300, 500 }; var range = RecordHandler.GetRecordsIndexToScan(startupParameters, avaliableIndex); }
private void SetupLocalDependencies(StartupParameters parameters) { var alarmLogger = new ConsoleAlarmLogger(parameters.Verbose); var loadLogger = new ConsoleConfigLoadLogger(parameters.Verbose); For <IAlarmLogger>().Use(alarmLogger); For <IConfigLoadLogger>().Use(loadLogger); For <IConfigLoader>().Use <ConfigLoader>(); For <ICurrentTimeProvider>().Use <CurrentTimeProvider>(); }
/// <summary> /// Starts the test form. /// </summary> /// <param name="state"> /// The state object containing our startup parameters. /// </param> private static void StartTest(object state) { StartupParameters parameters = state as StartupParameters; YourTestForm yourTestForm = new YourTestForm(); //// Set the needed parameters before we run the form. //// Add your parameters here. yourTestForm.Text = string.Format("Test form {0}", parameters.Index); //// Run the test. Application.Run(yourTestForm); }
public TestingIocBootstrapper(StartupParameters startupParameters = null) { StartupParameters = startupParameters ?? new StartupParameters() { ConfigFolderLocation = @"c:\test-path" }; _container = new Lazy <IContainer>(ConfigureContainer); _registry.IncludeRegistry(new ApplicationRegistry(StartupParameters)); _registry.IncludeRegistry <AwsServiceRegistry>(); _registry.IncludeRegistry <FakeBoundaryRegistry>(); }
public void GetRecordsIndexToScan_RequestedIndexInsideOfAvaliableRange() { var endpoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 10002); var startupParameters = new StartupParameters { EndPoint = endpoint, FirstIndex = 420, LastIndex = 470 }; var avaliableIndex = new ushort[] { 300, 500 }; var range = RecordHandler.GetRecordsIndexToScan(startupParameters, avaliableIndex); Assert.AreEqual(420, range[0]); Assert.AreEqual(470, range[1]); }
private void ConfigureInternalDependencies(StartupParameters parameters) { For <ISnsTopicCreator>().Use <SnsTopicCreator>(); For <ISnsSubscriptionCreator>().Use <SnsSubscriptionCreator>(); For <ITableAlarmCreator>().Use <TableAlarmCreator>(); For <IIndexAlarmCreator>().Use <IndexAlarmCreator>(); For <IAlarmFinder>().Use <AlarmFinder>().Singleton(); For <IQueueAlarmCreator>().Use <QueueAlarmCreator>(); For <IDynamoAlarmGenerator>().Use <DynamoAlarmGenerator>(); For <IOrphanTablesReporter>().Use <OrphanTablesReporter>(); For <IOrphanQueuesReporter>().Use <OrphanQueuesReporter>(); For <ISqsAlarmGenerator>().Use <SqsAlarmGenerator>(); if (!string.IsNullOrWhiteSpace(parameters.WriteCloudFormationTemplatesToDirectory)) { For <ICloudformationStackDeployer>() .Use( ctx => new DummyCloudFormationStackDeployer( parameters.WriteCloudFormationTemplatesToDirectory, ctx.GetInstance <IAlarmLogger>())); } else { var s3Location = GetS3Location(parameters); For <ICloudformationStackDeployer>() .Use(ctx => new CloudFormationStackDeployer( ctx.GetInstance <IAlarmLogger>(), ctx.GetInstance <IAmazonCloudFormation>(), ctx.GetInstance <IAmazonS3>(), s3Location )); } For <IAlarmCreator>().Use <CloudFormationAlarmCreator>(); var fileSettings = new FileSettings(parameters.ConfigFolderLocation); For <FileSettings>().Use(fileSettings); For <ILegacyAlarmTracker>().Use <LegacyAlarmTracker>().Singleton(); For <IOrphanedAlarmReporter>().Use <OrphanedAlarmReporter>(); }
private static S3Location GetS3Location(StartupParameters parameters) { if (string.IsNullOrWhiteSpace(parameters.TemplateS3Path)) { return(null); } var regex = new Regex("^s3://([^/]+)/(.*)", RegexOptions.IgnoreCase); var match = regex.Match(parameters.TemplateS3Path); if (!match.Success) { throw new Exception("Parameter TemplateS3Path does not match format s3://bucket/path"); } return(new S3Location(match.Groups[1].Value, match.Groups[2].Value)); }
public async Task StartAsync() { try { Process = new Process(); Process.StartInfo.FileName = StartupParameters.GetProcessPath(); Process.StartInfo.Arguments = StartupParameters.GetProcessArguments(); TaskCompletionSource <object> tcs = new TaskCompletionSource <object>(); Process.EnableRaisingEvents = true; Process.Exited += (sender, e) => { tcs.SetResult(Process.ExitCode); }; Process.Start(); await tcs.Task; } finally { Process.Dispose(); Process = null; } }
public MainForm(IpcPipeDuplex <IBrowserWindow, IBrowserHost> duplex, Form splash) { _duplex = duplex; _splash = splash; _transparenter = new Transparenter(this); _painter = new SettingsApplier(this); _startup = _duplex.Client.Order(x => x.GetStartupOptions()); ApplySetttings(_startup.Options); _painter.CenterForm(); _browser = new ChromiumWebBrowser(_startup.Url.AbsoluteUri) { Dock = DockStyle.Fill, }; _browser.LoadingStateChanged += Browser_LoadingStateChanged; Controls.Add(_browser); ResizeBegin += (s, e) => SuspendLayout(); ResizeEnd += (s, e) => ResumeLayout(true); FormClosed += MainForm_FormClosed; _transparenter.MakeTransparent(); _duplex.RunBackground(); }
public static StartupParameters Create(string[] args) { logger.Debug("CommandLine: " + string.Join(" ", args)); StartupParameters startupParams = new StartupParameters(); foreach (var arg in args) { var _arg = arg?.ToLower(); if (_arg == "-norestart") { startupParams.NoRestart = true; } else if (_arg == "-system") { startupParams.RunAsSystem = true; } else { //... } } using (var wi = System.Security.Principal.WindowsIdentity.GetCurrent()) { startupParams.UserName = wi.Name; startupParams.IsElevated = (wi.Owner != wi.User); startupParams.IsSystem = wi.IsSystem; } startupParams.IsRemoteSession = SystemParameters.IsRemoteSession; startupParams.IsRemotelyControlled = SystemParameters.IsRemotelyControlled; startupParams.IsCompositionEnabled = DwmApi.IsCompositionEnabled(); return(startupParams); }
public WebPlatformApiFactory(StartupParameters startupParameters) { _startupParameters = startupParameters; }
internal static void Main(string[] p_arguments) { instance = new Terrascape(); /* Initialize the console, changing its title and encoding mode and preparing it for our use */ ConsoleHelper.Initialize(); List <(string, bool)> early_debug_messages = new List <(string, bool)>(); /* Parse program arguments so we know whether or not to run in debug mode, and what kind of startup options to use */ #region Argument Parsing StartupParameters startup_parameters = new StartupParameters(); foreach (string argument in p_arguments) { /* "Enable Debugging" - whether or not to show the console and log debugging information */ if (argument == startup_parameters.enable_debugging.Item1) { startup_parameters.enable_debugging.Item2 = true; } /* "Verbose Debugging Level" - whether or not to include extra debugging information */ else if (argument == startup_parameters.verbose_debugging.Item1) { startup_parameters.verbose_debugging.Item2 = true; } /* "Hold Console" - whether or not to hold the console open if there are no errors when the game quits */ else if (argument == startup_parameters.hold_console.Item1) { startup_parameters.hold_console.Item2 = true; } /* "Enable Assertions" - whether or not to allow Debug.Assert() to throw exceptions */ else if (argument == startup_parameters.enable_assertions.Item1) { startup_parameters.enable_assertions.Item2 = true; } /* "Enable Profiling" - whether or not to allow Debug profiling to record game performance */ else if (argument == startup_parameters.enable_profiling.Item1) { startup_parameters.enable_profiling.Item2 = true; } /* Unknown */ else { early_debug_messages.Add(($"Unrecognised argument '{argument}'; ignoring", true)); } } /* After parsing arguments, enable the corresponding options */ if (!startup_parameters.enable_debugging.Item2) { Debug.enable_debugging = false; } if (startup_parameters.verbose_debugging.Item2) { if (Debug.enable_debugging) { Debug.debugging_level = Verbose; early_debug_messages.Add(("Debugging level set to verbose", false)); } else { early_debug_messages.Add(($"The argument '{startup_parameters.enable_debugging}' requires '-debug' to also be used; this option will be ignored", true)); } } if (startup_parameters.hold_console.Item2) { if (Debug.enable_debugging) { ConsoleHelper.hold_console_at_end = true; early_debug_messages.Add(("Console will be held at game end", false)); } else { early_debug_messages.Add(($"The argument '{startup_parameters.hold_console}' requires '-debug' to also be used; this option will be ignored", true)); } } if (startup_parameters.enable_assertions.Item2) { if (Debug.enable_debugging) { Debug.enable_assertions = true; early_debug_messages.Add(("Assertions enabled", false)); } else { early_debug_messages.Add(($"The argument '{startup_parameters.enable_assertions.Item1}' requires '-debug' to also be used; this option will be ignored", true)); } } if (startup_parameters.enable_profiling.Item2) { if (Debug.enable_debugging) { Debug.enable_profiling = true; early_debug_messages.Add(("Profiling enabled", false)); } else { early_debug_messages.Add(($"The argument '{startup_parameters.enable_profiling.Item1}' requires '-debug' to also be used; this option will be ignored", true)); } } #endregion /* Now print any messages that were supposed to be printed during argument parsing. This is held * until now because we first need to know whether or not debugging mode is going to be enabled. */ Debug.LogDebug("Parsing arguments", p_post: Indent); #pragma warning disable CS8619 foreach ((string message, bool is_warning) in early_debug_messages) { if (is_warning) { Debug.LogWarning(message); } else { Debug.LogDebug($"{SpecialCharacters.Bullet} {message}"); } } #pragma warning restore CS8619 Debug.LogDebug("Arguments parsed", p_pre: Unindent); early_debug_messages.Clear(); /* Run the game! */ #region Window Setup instance.window.Load += (p_sender, p_args) => { if (!instance.HasCrashed) { try { instance.phase = "INITIALIZATION"; instance.Initialize(); instance.phase = "LOADING"; instance.Load(); instance.phase = "POST-LOAD"; } catch (Exception exception) { HandleCrash(exception); } } }; instance.window.UpdateFrame += (p_sender, p_args) => { if (!instance.HasCrashed) { try { instance.phase = "UPDATE"; instance.Update(p_args.Time); } catch (Exception exception) { HandleCrash(exception); } } }; instance.window.RenderFrame += (p_sender, p_args) => { if (!instance.HasCrashed) { try { instance.phase = "RENDER"; instance.Render(p_args.Time); } catch (Exception exception) { HandleCrash(exception); } } }; instance.window.Resize += (p_sender, p_args) => { if (!instance.HasCrashed) { try { instance.phase = "RESIZE"; instance.Resize(); Width = instance.window.Width; Height = instance.window.Height; HalfWidth = Width / 2D; HalfHeight = Height / 2D; instance.phase = "RENDER-WHILE-RESIZING"; instance.Render(double.Epsilon); } catch (Exception exception) { HandleCrash(exception); } } }; instance.window.Unload += (p_sender, p_args) => { if (instance.has_shut_down) { return; } try { instance.phase = "SHUTDOWN"; instance.Shutdown(); instance.has_shut_down = true; } catch (Exception exception) { HandleCrash(exception); } }; instance.window.Closing += (p_sender, p_args) => { if (instance.has_shut_down) { return; } if (!instance.is_self_shutting_down) { try { instance.phase = "SHUTDOWN-REQUEST"; bool cancel = false; instance.RequestShutdown(ref cancel); if (!cancel) { instance.phase = "SHUTDOWN"; instance.Shutdown(); instance.has_shut_down = true; } } catch (Exception exception) { HandleCrash(exception); } } }; #endregion instance.window.Run(); // Reset the console back to its previous state as it was before the game started, and hold it open if needed ConsoleHelper.Terminate(); }
static void Main(string[] args) { StartupParameters startupParameters; try { startupParameters = new StartupParameters(args); } catch { Console.WriteLine("usage:"); Console.WriteLine("p2v <url> <options>"); Console.WriteLine("Example:"); Console.WriteLine("p2v https://www.blathering.de/feed/mp3"); Console.WriteLine("Go to https://github.com/OleAlbers/Podcast2Video/wiki for a complete list of options"); return; } var config = new Config(); config.OverrideConfig(args); if (startupParameters.Verbose) { Console.WriteLine($"Config: {JsonConvert.SerializeObject(Config.Configuration)}"); } Rss rss; if (startupParameters.Rss != null) { rss = new Rss(new Uri(startupParameters.Rss)); } else { rss = new Rss(startupParameters.LocalXml); } var output = new Image(rss.Podcast, startupParameters.Episode); Video video; if (startupParameters.Chapter != null) { var matchingChapter = output.CurrentEpisode.GetChapterAt(startupParameters.Chapter.Value); if (matchingChapter == null) { throw new Exception($"No chapter at {startupParameters.Chapter}"); } video = new Video(output, output.CurrentEpisode.Chapters.IndexOf(matchingChapter)); } else if (startupParameters.Start == null && startupParameters.Finish == null) { video = new Video(output); } else { if (startupParameters.Start == null) { startupParameters.Start = new TimeSpan(); } if (startupParameters.Finish == null) { startupParameters.Finish = output.CurrentEpisode.Duration; } video = new Video(output, startupParameters.Start.Value, startupParameters.Finish.Value); } video.CreateVideo(startupParameters.StoreImages, startupParameters.OutputFilename, startupParameters.LocalMp3); }
public ApplicationRegistry(StartupParameters parameters) { ConfigureResourceSources(); ConfigureInternalDependencies(parameters); }
public void RefreshInfo() { StartupParameters.Parse(StartupLine ?? StartupParameters.DefaultParams); Refresh(); }
public static int Main(string[] args) { int exitCode = 0; InitLogger(); logger.Info("============================ START ============================"); bool createdNew = false; Mutex mutex = null; try { mutex = new Mutex(true, AppConsts.ApplicationId, out createdNew); if (!createdNew) { logger.Info("Another instance is already running..."); if (!Models.AppModel.AllowMutipleInstance) { var res = Services.WndProcService.ShowAnotherInstance(); return(0); //return -1; //... } } StartupParams = StartupParameters.Create(args); logger.Info(StartupParams.GetSysInfo()); try { MediaToolkitManager.Startup(); Shcore.SetProcessPerMonitorDpiAwareness(); var application = new App(); application.DispatcherUnhandledException += Application_DispatcherUnhandledException; application.InitializeComponent(); logger.Info("============================ RUN ============================"); application.Run(); } finally { MediaToolkitManager.Shutdown(); } } catch (Exception ex) { ProcessError(ex); } finally { if (mutex != null) { if (createdNew) { mutex.ReleaseMutex(); } mutex.Dispose(); } logger.Info("============================ THE END ============================"); } return(exitCode); }
public BoundaryRegistry(StartupParameters parameters) { SetupLocalDependencies(parameters); SetupAwsDependencies(parameters); }
static void Main(string[] args) { InitLogger(); logger.Info("========== START ============"); AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; StartupParams = StartupParameters.Create(args); //if (StartupParams.RunAsSystem) //{ // if (StartupParams.IsElevated) // { // if (RestartAsSystem() > 0) // { // return; // } // logger.Warn("Restart failed..."); // } // else // { // RunAsSystem(); // } //} if (StartupParams.IsElevated) { if (!StartupParams.NoRestart) {//Restart application with system permissions... if (RestartAsSystem() > 0) { return; } logger.Warn("Restart failed..."); // открываем процесс как обычно... //TODO:... } } bool createdNew = false; Mutex mutex = null; try { mutex = new Mutex(true, AppConsts.ApplicationId, out createdNew); if (!createdNew) { logger.Info("Another instance is already running..."); //... } bool tempMode = !createdNew; Config.Initialize(tempMode); MediaToolkitManager.Startup(); //DwmApi.DisableAero(true); Shcore.SetProcessPerMonitorDpiAwareness(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); MainForm form = new MainForm(); logger.Info("========== RUN ============"); Application.Run(form); } finally { Config.Shutdown(); MediaToolkitManager.Shutdown(); if (mutex != null) { if (createdNew) { mutex.ReleaseMutex(); } mutex.Dispose(); } logger.Info("========== THE END ============"); } }
public AutoLoginService(IServiceClient serviceClient, WebPlatformApiFactory webPlatformApi, StartupParameters startupParameters) { _serviceClient = serviceClient; _webPlatformApi = webPlatformApi; _startupParameters = startupParameters; }
public Window(StartupParameters startupParameters) { InitializeComponent(); _startupParameters = startupParameters; }