public static int Main(string[] args) { bool commandLine = false; TfsClientConfiguration configuration = new TfsClientConfiguration(); string section = null, command = null; string[] commandArgs = null; try { commandLine = ParseCommandLine(args, ref configuration, ref section, ref command, ref commandArgs); } catch (Exception e) { Console.Error.WriteLine("{0}: {1}", ProgramName, e.Message); } if (!commandLine) { Console.Error.WriteLine("usage: {0} <url> <command> [--username=<username> [--password=<password>]] [<argument>...]", ProgramName); return 1; } if (command == null) { Console.Error.WriteLine("{0}: '{1}' is not a {0} command", ProgramName, section); Console.Error.WriteLine("usage: {0} <command> [<argument>...]", ProgramName); return 1; } TfsClient client = new TfsClient(configuration); try { Type sectionType = Type.GetType(String.Format("Infinity.Client.{0}Command", section)); if (sectionType != null) { object commandObj = Activator.CreateInstance(sectionType, client); MethodInfo commandMethod = sectionType.GetMethod(command); if (commandMethod != null) { return (int)commandMethod.Invoke(commandObj, new object[] { commandArgs }); } } Console.Error.WriteLine("{0}: '{1}.{2}' is not a {0} command", ProgramName, section, command); Console.Error.WriteLine("usage: {0} <command> [<argument>...]", ProgramName); } catch(Exception e) { while (e is TargetInvocationException || e is AggregateException) { e = e.InnerException; } Console.Error.WriteLine(e.Message); } return 1; }
public ProjectCommand(TfsClient client) { Assert.NotNull(client, "client"); Client = client; }