public void ParseTest() { var parser = new ArgumentsParser(new[] { "-Arg1", "Value1", "-Arg2", "/Arg3", "Value2" }); Assert.IsTrue(parser.GetValue<bool>("Arg2")); Assert.AreEqual(parser.GetValue<string>("Arg1"), "Value1"); Assert.AreEqual(parser.GetValue<string>("Arg3"), "Value2"); }
/// <summary> /// The main entry point for the application. /// </summary> static void Main(string[] args) { var pargs = new ArgumentsParser(args); var runServer = pargs.GetValue<bool>("Server"); var runClient = pargs.GetValue<bool>("Client"); var serverService = new FlexibleProxyServerService(); var clientService = new FlexibleProxyClientService(); if (Environment.UserInteractive) { Console.WriteLine("Starting SERVER Service..."); serverService.OnServiceStart(args); Console.WriteLine("SERVER is started in console."); Console.WriteLine("Starting CLIENT Service..."); clientService.OnServiceStart(args); Console.WriteLine("CLIENT is started in console."); Console.WriteLine("Press ENTER to stop services and exit."); Console.ReadLine(); serverService.OnServiceStop(); clientService.OnServiceStop(); Console.WriteLine("Both services are stopped."); } else { var servicesToRun = new List<ServiceBase>(); if (runServer) servicesToRun.Add(serverService); if (runClient) servicesToRun.Add(clientService); ServiceBase.Run(servicesToRun.ToArray()); } }
public void ParseTest() { var parser = new ArgumentsParser(new[] { "-Arg1", "Value1", "-Arg2", "/Arg3", "Value2" }); Assert.IsTrue(parser.GetValue <bool>("Arg2")); Assert.AreEqual(parser.GetValue <string>("Arg1"), "Value1"); Assert.AreEqual(parser.GetValue <string>("Arg3"), "Value2"); }
/// <summary> /// The main entry point for the application. /// </summary> static void Main(string[] args) { var pargs = new ArgumentsParser(args); var runServer = pargs.GetValue <bool>("Server"); var runClient = pargs.GetValue <bool>("Client"); var serverService = new FlexibleProxyServerService(); var clientService = new FlexibleProxyClientService(); if (Environment.UserInteractive) { Console.WriteLine("Starting SERVER Service..."); serverService.OnServiceStart(args); Console.WriteLine("SERVER is started in console."); Console.WriteLine("Starting CLIENT Service..."); clientService.OnServiceStart(args); Console.WriteLine("CLIENT is started in console."); Console.WriteLine("Press ENTER to stop services and exit."); Console.ReadLine(); serverService.OnServiceStop(); clientService.OnServiceStop(); Console.WriteLine("Both services are stopped."); } else { var servicesToRun = new List <ServiceBase>(); if (runServer) { servicesToRun.Add(serverService); } if (runClient) { servicesToRun.Add(clientService); } ServiceBase.Run(servicesToRun.ToArray()); } }