Пример #1
0
        public void TestDefaults()
        {
            var options = ArgsOptions.Parse(new string[0]);

            Assert.IsTrue(options.ServerPort > 0);
            Assert.IsFalse(string.IsNullOrEmpty(options.GameInfoJsonPath));
        }
Пример #2
0
        static void Main(string[] args)
        {
            XmlConfigurator.Configure();
            var         pn            = ConfigurationSettings.AppSettings["proccessName"];
            var         console       = new ConsoleWriter();
            var         cmdLineParser = new CommandLineParser.CommandLineParser();
            ArgsOptions p             = new ArgsOptions();

            cmdLineParser.ExtractArgumentAttributes(p);
            cmdLineParser.ParseCommandLine(args);

            if (string.IsNullOrEmpty(p.ProcessName))
            {
                p.ProcessName = pn;
            }

            var process = Process.GetProcessesByName(p.ProcessName);

            console.WriteLine($"Press any key to quit...", ConsoleColor.Yellow);

            if (process == null || process.Length == 0)
            {
                console.WriteLine($"ERROR: There is no process with name: {p.ProcessName}", ConsoleColor.Red);
                Console.ReadKey();
                return;
            }
            else if (process.Length > 1)
            {
                console.WriteLine($"ERROR: There are no processes with name: {p.ProcessName}", ConsoleColor.Red);
                Console.ReadKey();
            }

            var perfCounters = GetCounters(p.ProcessName);

            var subject = Observable.Interval(TimeSpan.FromMilliseconds(1000))
                          .ObserveOn(System.Reactive.Concurrency.Scheduler.Default)
                          .Subscribe(x =>
            {
                var messageBuilder = new StringBuilder();
                foreach (var counterKey in perfCounters.Keys)
                {
                    var counter = perfCounters[counterKey];
                    var value   = counterKey == "Working Set" ? counter.NextValue() / 1024 / 1024 : counter.NextValue();
                    messageBuilder.AppendFormat("{0}: {1};", counterKey, value);
                }
                _logger.Info(messageBuilder.ToString());
            }, () => console.WriteLine("Done", ConsoleColor.DarkCyan));


            Console.ReadKey();
            subject.Dispose();
        }
Пример #3
0
        public void TestConfigAndPort()
        {
            var port   = 5839;
            var config = "/some/config/path.json";
            var args   = new[]
            {
                "--port", port.ToString(),
                "--config", config
            };
            var options = ArgsOptions.Parse(args);

            Assert.AreEqual(port, options.ServerPort);
            Assert.AreEqual(config, options.GameInfoJsonPath);
        }