Exemplo n.º 1
0
        public void TestReading()
        {
            int lineCount = 0;

            var reader = new SettingsFileReader <SymbolSettingsFileLine>();

            reader.SettingsLineHandler =
                line =>
            {
                lineCount++;

                if (lineCount == 1)
                {
                    Assert.AreEqual("Geo:line", line.Key);
                    Assert.AreEqual("6710886", line.Values[0]);
                    Assert.AreEqual("6710886", line.Values[0]);
                    Assert.AreEqual("3.0", line.Values[1]);
                    Assert.AreEqual("0", line.Values[2]);
                    Assert.AreEqual("0", line.Values[3]);
                    Assert.AreEqual("7", line.Values[4]);
                }
                else if (lineCount == 2)
                {
                    Assert.AreEqual("Sector:inactive sector background", line.Key);
                    Assert.AreEqual("8882055", line.Values[0]);
                    Assert.AreEqual("3.5", line.Values[1]);
                    Assert.AreEqual("0", line.Values[2]);
                    Assert.AreEqual("0", line.Values[3]);
                    Assert.AreEqual("7", line.Values[4]);
                }
            };

            reader.Parse("..\\..\\Testdata\\Symbols.txt");
            Assert.AreEqual(2, lineCount);
        }
Exemplo n.º 2
0
        private void ReadSymbolSettingsFile()
        {
            var reader = new SettingsFileReader <SymbolSettingsFileLine>();

            reader.SettingsLineHandler += line => symbolSettings.Add(line.Key, line);
            reader.Parse("..\\..\\..\\UnitTestProject1\\Testdata\\Symbols.txt");
            logger.Debug("Read " + symbolSettings.Count + " symbol lines");
        }
Exemplo n.º 3
0
 private void TryToReadSettingsFile()
 {
     try  // Reading settings file
     {
         using (var reader = new SettingsFileReader(SettingsFileReader.SettingsFilePath))
             reader.ReadSettings();
     }
     catch { }
 }
Exemplo n.º 4
0
        /// <summary>
        /// Der Haupteinstiegspunkt für die Anwendung.
        /// </summary>
        static void Main(String[] args)
        {
            _ = GlobalConfiguration.Configuration
                .UseColouredConsoleLogProvider()
                .UseMemoryStorage();
            MemoryStorageOptions options = new MemoryStorageOptions();

            // options.JobExpirationCheckInterval = TimeSpan.FromSeconds(30);
            // options.FetchNextJobTimeout = TimeSpan.FromSeconds(30);


            JobStorage.Current = new MemoryStorage(options);

            string baseAddress = "http://localhost:9000/";

            WebApp.Start <Startup>(url: baseAddress);

            try
            {
                SettingsFileReader reader = new SettingsFileReader();
                var settingsFile          = reader.ReadSettingsFile();
                Validator.ValidateJsonModel(ref settingsFile);

                var armaServer = ArmaServer.GetInstance();
                armaServer.SetSettingsFile(settingsFile.settings);
                armaServer.SetupServer();


                var rcon = RconConnector.GetRconConnector();
                rcon.SetSettingsFile(settingsFile.settings);
                rcon.OpenConnection();
                rcon.StartQueueWorker();

                TaskCreator.CreateTasks(settingsFile);
                armaServer.StartAll();

                while (true)
                {
                    Console.ReadKey();
                }
            }
            catch (SettingsFileReadException e)
            {
                Console.WriteLine("Error reading the settings file...");
                Console.ReadKey();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                Console.ReadKey();
            }
        }
Exemplo n.º 5
0
 public static void Main(string[] args)
 {
     try {
         string rootDir   = new FileInfo($"{Assembly.GetEntryAssembly().Location}").DirectoryName;
         string pluginDir = $"{rootDir}\\{DLL_DIR}";
         if (!Directory.Exists(pluginDir))
         {
             Directory.CreateDirectory(pluginDir);
         }
         IFinder <ICommand> cmdFinder  = InitializeCommandFinder(pluginDir);
         IFileReader        fileReader = new SettingsFileReader(new IFinder <ICommand>[] { cmdFinder });
         Program            p          = new Program(cmdFinder, args, fileReader);
         p.Run(args);
     }
     catch (Exception err) {
         Console.ForegroundColor = ConsoleColor.Red;
         Console.WriteLine($"{err.GetType().Name} -> {err.Message}");
     }
     finally {
         Console.ForegroundColor = ConsoleColor.White;
     }
     Environment.Exit(0);
 }
Exemplo n.º 6
0
        public void SettingsFileReader_ReadSettings_FromXmlSettingsFile_ReturnsExpectedResult()
        {
            var reader = new SettingsFileReader(Helpers.ResourceHelpers.GetStreamFromResource("Tests.ExampleSettingsFiles.Settings.xml"));

            Assert.AreEqual(6, reader.ReadSettings().Count());
        }
Exemplo n.º 7
0
 SettingsFile(string destFile)
 {
     reader = new SettingsFileReader(destFile);
     writer = new SettingsFileWriter(destFile);
 }
Exemplo n.º 8
0
        static void Main(string[] args)
        {
            if (args.Length < 0)
            {
                Console.WriteLine("No Arguments found! You need to specify a path to your settings.json");
                Environment.Exit(1);
            }

            var settingsFilePath = args.FirstOrDefault(x => x.Contains("-settingsfile=")).Replace("-settingsfile=", "");

            if (settingsFilePath == null)
            {
                Console.WriteLine("You need to specify a path to your settings.json");
                Environment.Exit(1);
            }
            if (!File.Exists(settingsFilePath))
            {
                if (args.FirstOrDefault(x => x.Contains("-generateConfig")) != null)
                {
                    SettingsFileReader reader = new SettingsFileReader();
                    var settingsFile          = reader.ReadSettingsFile(settingsFilePath, true);
                    Console.WriteLine("Config example has been generated to your specified path.\n Terminating...");
                    Environment.Exit(0);
                }
                Console.WriteLine("No settingsfile found please double check your path");
                Environment.Exit(1);
            }

            _ = GlobalConfiguration.Configuration
                .UseColouredConsoleLogProvider()
                .UseMemoryStorage();
            MemoryStorageOptions options = new MemoryStorageOptions();

            // options.JobExpirationCheckInterval = TimeSpan.FromSeconds(30);
            // options.FetchNextJobTimeout = TimeSpan.FromSeconds(30);


            JobStorage.Current = new MemoryStorage(options);

            string baseAddress = "http://localhost:9000/";

            //WebApp.Start<Startup>(url: baseAddress);

            try
            {
                SettingsFileReader reader = new SettingsFileReader();
                var settingsFile          = reader.ReadSettingsFile(settingsFilePath);
                Validator.ValidateJsonModel(ref settingsFile);

                var armaServer = ArmaServer.GetInstance();
                armaServer.SetSettingsFile(settingsFile.settings);
                armaServer.SetupServer();


                var rcon = RconConnector.GetRconConnector();
                rcon.SetSettingsFile(settingsFile.settings);
                rcon.OpenConnection();
                rcon.StartQueueWorker();

                TaskCreator.CreateTasks(settingsFile);
                armaServer.StartAll();

                while (true)
                {
                    Console.ReadKey();
                }
            }
            catch (SettingsFileReadException e)
            {
                Console.WriteLine("Error reading the settings file...");
                Console.ReadKey();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                Console.ReadKey();
            }
        }