private async void Current_Startup(object sender, StartupEventArgs e) { var startupArguments = new StartupArguments(); startupArguments.Parse(e.Args); if (!string.IsNullOrEmpty(startupArguments.Culture)) { Thread.CurrentThread.CurrentCulture = Thread.CurrentThread.CurrentUICulture = new CultureInfo(startupArguments.Culture); } var splashScreen = new SplashScreen(LocalizationHelper.GetResourceManager().GetString("TXT_SPLASH_SCREEN_PATH")); splashScreen.Show(false); CheckForUpdates(); await AsyncHelper.CallSync(InitialiseApplication); splashScreen.Close(new TimeSpan(0, 0, 0)); var window = new LogInWindow(); if (window.ShowDialog() == true) { ShutdownMode = ShutdownMode.OnMainWindowClose; MainWindow = new MainWindow(); MainWindow.ShowDialog(); } else { Current.Shutdown(); } }
public void should_parse_single_flag(string arg) { var args = new StartupArguments(new[] { arg }); args.Flags.Should().HaveCount(1); args.Flags.Contains("t").Should().BeTrue(); }
public void should_use_path_from_arg_if_provided() { var args = new StartupArguments("-data=\"c:\\users\\test\\\""); Mocker.SetConstant <IStartupArguments>(args); Subject.AppDataFolder.Should().Be("c:\\users\\test\\"); }
public static Task Initialize(IWebHost host) { Host = host; var env = Container.Resolve <IHostingEnvironment>(); if (env.IsDevelopment()) { ONLINE_BASE_ADDRESS = Core.NGROK_SERVER; } else { ONLINE_BASE_ADDRESS = Host.ServerFeatures.Get <IServerAddressesFeature>().Addresses.FirstOrDefault(); } InitializeData().Wait(); if (StartupArguments.Length > 0) { if (StartupArguments.Contains("--seed")) { SeedUsers().Wait(); } else if (StartupArguments.Contains("--transactionFix")) { FixTransactionBugs().Wait(); } } Core.Log.Debug($"{PRODUCT_NAME} has successfully been initialized."); return(Task.CompletedTask); }
public void Initialize() { if (IsInitialized) { throw new ArtemisCoreException("Cannot initialize the core as it is already initialized."); } AssemblyInformationalVersionAttribute?versionAttribute = typeof(CoreService).Assembly.GetCustomAttribute <AssemblyInformationalVersionAttribute>(); _logger.Information("Initializing Artemis Core version {version}", versionAttribute?.InformationalVersion); ApplyLoggingLevel(); DeserializationLogger.Initialize(Kernel); // Initialize the services _pluginService.CopyBuiltInPlugins(); _pluginService.LoadPlugins(StartupArguments.Contains("--ignore-plugin-lock")); ArtemisSurface surfaceConfig = _surfaceService.ActiveSurface; if (surfaceConfig != null) { _logger.Information("Initialized with active surface entity {surfaceConfig}-{guid}", surfaceConfig.Name, surfaceConfig.EntityId); } else { _logger.Information("Initialized without an active surface entity"); } PlayIntroAnimation(); OnInitialized(); }
public void should_parse_args_with_alues(string arg) { var args = new StartupArguments(new[] { arg }); args.Args.Should().HaveCount(1); args.Args["key"].Should().Be("value"); }
private MainAppContainerBuilder(StartupArguments args) : base(args, "NzbDrone.Host", "NzbDrone.Common", "NzbDrone.Core", "NzbDrone.Api", "NzbDrone.SignalR") { AutoRegisterImplementations <NzbDronePersistentConnection>(); Container.Register(typeof(IBasicRepository <RootFolder>), typeof(BasicRepository <RootFolder>)); Container.Register(typeof(IBasicRepository <NamingConfig>), typeof(BasicRepository <NamingConfig>)); Container.Register <INancyBootstrapper, NancyBootstrapper>(); }
public EmulatorForm([NotNull] StartupArguments startupArguments) { this.startupArguments = startupArguments; InitializeComponent(); Text += AssemblyReader.GetInformationalVersion(); sessionManager = new DisposableComponent<CirceMediatorSessionManager>(new CirceMediatorSessionManager(), ref components); }
public void HandleCustomStartup(string tileId, string arguments) { var a = new MyStartupArguments { Id = 2, SomeString = "holla holla", Date = DateTimeOffset.Now }; arguments = StartupArguments.AsString(a); var parsed = StartupArguments.Parse <MyStartupArguments>(arguments); }
public Main() { string[] args = Environment.GetCommandLineArgs(); FormLoadInitialSettings(args, out bool showChangelog, out bool BAKprompt); InitializeComponent(); C_SAV.SetEditEnvironment(new SaveDataEditor <PictureBox>(new FakeSaveFile(), PKME_Tabs)); FormLoadAddEvents(); #if DEBUG // translation updater -- all controls are added at this point -- call translate now if (DevUtil.IsUpdatingTranslations) { WinFormsUtil.TranslateInterface(this, CurrentLanguage); // Translate the UI to language. } #endif FormInitializeSecond(); FormLoadCheckForUpdates(); var startup = new StartupArguments(); startup.ReadArguments(args); startup.ReadSettings(Settings.Startup); startup.ReadTemplateIfNoEntity(TemplatePath); FormLoadInitialFiles(startup); if (Settings.Startup.PluginLoadMethod != PluginLoadSetting.DontLoad) { FormLoadPlugins(); } if (HaX) { PKMConverter.AllowIncompatibleConversion = true; WinFormsUtil.Alert(MsgProgramIllegalModeActive, MsgProgramIllegalModeBehave); } else if (showChangelog) { ShowAboutDialog(AboutPage.Changelog); } if (BAKprompt && !Directory.Exists(BackupPath)) { PromptBackup(); } BringToFront(); WindowState = FormWindowState.Minimized; Show(); WindowState = FormWindowState.Normal; }
public FMain(string[] args) { // // Required for Windows Form Designer support // InitializeComponent(); if (args.Length < 3) { MessageBox.Show("There is not enough arguments."); return; } ProcessName = args[0]; SourceDir = args[1]; TargetDir = args[2]; if (args.Length > 3) { Startup = args[3]; int i = 4; while (args.Length > i) { if (args[i].IndexOf(" ") > -1) { StartupArguments += "\""; } StartupArguments += args[i]; if (args[i].IndexOf(" ") > -1) { StartupArguments += "\""; } StartupArguments += " "; i++; } StartupArguments = StartupArguments.Trim(); } timer1.Enabled = true; }
static void Main(string[] args) { var logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly()); XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config")); log.Info("Start application"); var message = new StringBuilder(); message.AppendLine(""); message.AppendLine("========================"); message.AppendLine("VideoFunk Sync"); message.AppendLine(Assembly.GetExecutingAssembly().GetName().Version.ToString()); message.AppendLine("========================"); log.Info(message); try { var startupArguments = StartupArguments.Parse(args); var fileSystem = new FileSystem(); var names = fileSystem.File.ReadAllLines(".\\data\\names.txt"); var settings = new ConfigSettings { TemplatePath = ".\\Domain\\MovieMaker\\NameCarouselTemplates\\", Names = names, OutputFilePath = "d:\\temp\\myfilename.wlmp" }; INameCarousel nameCarouselModule = new NameCarouselModule(new NameCarouselGenerator(fileSystem)); nameCarouselModule.Init(settings); nameCarouselModule.Generate(); } catch (Exception ex) { log.Error(ex); log.Info(StartupArguments.USAGE); } log.Info("Close application"); }
public static void Main(string[] args) { try { var startupArgs = new StartupArguments(args); LogTargets.Register(startupArgs, false, true); var container = Bootstrap.Start(startupArgs, new MessageBoxUserAlert()); container.Register <ISystemTrayApp, SystemTrayApp>(); container.Resolve <ISystemTrayApp>().Start(); } catch (TerminateApplicationException) { } catch (Exception e) { Logger.FatalException("EPIC FAIL: " + e.Message, e); var message = string.Format("{0}: {1}", e.GetType().Name, e.Message); MessageBox.Show(text: message, buttons: MessageBoxButtons.OK, icon: MessageBoxIcon.Error, caption: "Epic Fail!"); } }
public static void Main(string[] args) { try { var startupArgs = new StartupArguments(args); LogTargets.Register(startupArgs, false, true); Bootstrap.Start(startupArgs, new ConsoleAlerts()); } catch (TerminateApplicationException) { } catch (Exception e) { Logger.FatalException("EPIC FAIL!", e); System.Console.ReadLine(); } while (true) { Thread.Sleep(10 * 60); } }
public static IContainer Start(StartupArguments args, IUserAlert userAlert) { var logger = NzbDroneLogger.GetLogger(); GlobalExceptionHandlers.Register(); IgnoreCertErrorPolicy.Register(); logger.Info("Starting NzbDrone Console. Version {0}", Assembly.GetExecutingAssembly().GetName().Version); if (!PlatformValidation.IsValidate(userAlert)) { throw new TerminateApplicationException(); } var container = MainAppContainerBuilder.BuildContainer(args); DbFactory.RegisterDatabase(container); container.Resolve <Router>().Route(); return(container); }
public static void Main(string[] args) { try { var startupArgument = new StartupArguments(args); LogTargets.Register(startupArgument, true, true); Console.WriteLine("Starting NzbDrone Update Client"); IgnoreCertErrorPolicy.Register(); GlobalExceptionHandlers.Register(); _container = UpdateContainerBuilder.Build(startupArgument); logger.Info("Updating NzbDrone to version {0}", BuildInfo.Version); _container.Resolve <UpdateApp>().Start(args); } catch (Exception e) { logger.FatalException("An error has occurred while applying update package.", e); } }
public void empty_array_should_return_empty_flags() { var args = new StartupArguments(new string[0]); args.Flags.Should().BeEmpty(); }
public void Create(Broker broker, byte[] configuration) { this.configuration = System.Text.Encoding.UTF8.GetString(configuration); Console.WriteLine("I have been created from QiEdge!"); var defaultlocalStorageLocation = Environment.OSVersion.Platform == PlatformID.Unix ? EdgeConstants.LinuxRootInstallFolder : EdgeConstants.WindowsRootInstallFolder; ////if (args.Length > 0) ////{ //// if (args[0] == $"--{Constants.HelpFlag}") //// { //// Console.WriteLine(); //// Console.WriteLine("Optional commandline arguments shown below with their default values."); //// Console.WriteLine(); //// Console.WriteLine("#####################"); //// Console.WriteLine(); //// Console.WriteLine( //// $"--{Constants.DataServerPortKey} {Constants.DataServerDefaultPort} --{Constants.DataServerLocalStorageLocationKey} {defaultlocalStorageLocation}"); //// Console.WriteLine(); //// Console.WriteLine("#####################"); //// return; //// } ////} var dataServerStartupArgs = new StartupArguments(); var dataServerStoreConfig = new LocalStoreConfiguration { StreamStorageLimitMb = -1, }; var config = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) ////.AddCommandLine(args) .AddJsonFile("hosting.json", optional: true) .Build(); ////if (config.GetValue<bool>(Constants.HelpFlag)) ////{ //// Console.WriteLine("Optional commandline arguments shown below with their default values."); //// Console.WriteLine($"--{Constants.DataServerPortKey} {Constants.DataServerDefaultPort} --{Constants.DataServerLocalStorageLocationKey} {defaultlocalStorageLocation}"); //// return; ////} ////var dataServerPort = config.GetValue<int?>(Constants.DataServerPortKey) ?? Convert.ToInt32(Constants.DataServerDefaultPort); var dataServerPort = Convert.ToInt32(Constants.DataServerDefaultPort); ////var localStorageLocation = config.GetValue<string>(Constants.DataServerLocalStorageLocationKey) ?? defaultlocalStorageLocation; var localStorageLocation = defaultlocalStorageLocation; dataServerStartupArgs.ListenerPort = dataServerPort.ToString(); dataServerStartupArgs.LocalStorageLocation = localStorageLocation; dataServerBootstrapper = new DataServerBootstrapper(dataServerStartupArgs, dataServerStoreConfig); var administrationHost = new WebHostBuilder() .CaptureStartupErrors(true) .UseKestrel() .ConfigureServices( services => services.AddSingleton(dataServerBootstrapper)) .UseConfiguration(config) .UseIISIntegration() .UseKestrel() .UseStartup <StartupAdminServer>() .Build(); Task.Run(() => administrationHost.Run()); Task.Delay(6000).Wait(); dataServerBootstrapper.InternalAdminService.GetOrCreateTenantAsync(new OSIsoft.Data.QiTenant("msftiot")).Wait(); dataServerBootstrapper.GetQiAdministrationService("msftiot").GetOrCreateNamespaceAsync(new OSIsoft.Data.QiNamespace("firstns")).Wait(); var iotType = dataServerBootstrapper.GetQiMetadataService("msftiot", "firstns").GetOrCreateTypeAsync(QiTypeBuilder.CreateQiType <MyDataType>()).Result; dataServerBootstrapper.GetQiMetadataService("msftiot", "firstns").GetOrCreateStreamAsync(new OSIsoft.Data.QiStream() { Id = "somestream", TypeId = iotType.Id, }); }
public static string GetStartupArgument(StartupArguments argument) { try { return(STARTUP_ARGUMENTS[(int)argument]); } catch (Exception) { return(""); } }
protected void InitializeApp() { string[] args = Environment.GetCommandLineArgs(); List <string> fileTypes = FileTypes.ToList(); foreach (string arg in args) { if (arg == "-d" || arg == "--debug") { DebugMode = true; StartupArguments.Add(arg); } else if (arg.StartsWith("-") || arg.StartsWith("--")) { StartupArguments.Add(arg); } else { FileInfo file = new FileInfo(arg); if (file.Exists && fileTypes.Contains(file.Extension)) { StartupFileNames.Add(arg); } } } #if DEBUG DebugMode = true; #endif bool newMutex; Mutex mutex = new Mutex(true, AppId, out newMutex); if (!newMutex) { if (SingleInstanceApplication == true) { using (IPCNamedPipeClient client = new IPCNamedPipeClient(AppId)) { IPCMessage message = new IPCMessage(); message.Type = IPCMessageType.BringToFront; client.SendMessage(message); } Current.Shutdown(); return; } else if (OpenDocsInFirstInstance && StartupFileNames.Count > 0) { using (IPCNamedPipeClient client = new IPCNamedPipeClient(AppId)) { IPCMessage message = new IPCMessage(); message.Type = IPCMessageType.OpenDocument; message.Data = StartupFileNames; client.SendMessage(message); } Current.Shutdown(); } GainMutexTask = new Task(() => { try { bool isNewMutex = false; while (isNewMutex == false && !AbortMutex) { Thread.Sleep(100); mutex = new Mutex(true, AppId, out isNewMutex); if (isNewMutex) { s_mutex = mutex; } else { mutex.Close(); mutex.Dispose(); } } } catch (Exception ex) { LogHelper.LogException(ex, ex.Message, false); } HasMutex = true; }); GainMutexTask.Start(); } else { s_mutex = mutex; HasMutex = true; } Dispatcher.UnhandledException += Dispatcher_UnhandledException; if (UseDefaultMessageBox) { LogHelper.OnMessageBox += LogHelper_OnMessageBox; } if (ShutdownOnFatalError) { LogHelper.OnFatalError += LogHelper_OnFatalError; } LogHelper.LogMessage(LogLevel.Info, string.Format("Started Application {0}", Assembly.GetExecutingAssembly().FullName)); Exit += wpfApp_Exit; }
public static IContainer BuildContainer(StartupArguments args) { return(new MainAppContainerBuilder(args).Container); }