static void Main(string [] args) { var parser = new ArgumentParser(args); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); PreferredSiteList.InitCulture(); IServerConnection conn = null; if (!parser.IsDefined(CommandLineArguments.Provider) || !parser.IsDefined(CommandLineArguments.Session)) { var login = new LoginDialog(); if (login.ShowDialog() == System.Windows.Forms.DialogResult.OK) { conn = login.Connection; } } else { string prov = parser.GetValue(CommandLineArguments.Provider); conn = ConnectionProviderRegistry.CreateConnection(prov, parser.GetAllArgumentsWithValues()); } if (conn == null) return; Application.Run(new MainForm(conn.FeatureService, conn.ResourceService)); }
public void TestArgParser() { string[] args = new string[] { "-foo", "-bar:snafu", "-whatever:" }; var parser = new ArgumentParser(args); Assert.IsFalse(parser.IsDefined("snafu")); Assert.IsTrue(parser.IsDefined("foo")); Assert.IsTrue(parser.IsDefined("bar")); Assert.IsTrue(parser.IsDefined("whatever")); Assert.AreEqual(string.Empty, parser.GetValue("whatever")); Assert.AreEqual(parser.GetValue("bar"), "snafu"); }