示例#1
0
 /// <summary>
 /// The main entry point for the application.
 /// </summary>
 static void Main(string[] args)
 {
     if (args != null && args.Length > 0 && args[0].ToLower().StartsWith("-debug"))
     {
         TestLog();
         TestServiceRunner();
     }
     else if (args != null && args.Length > 0)
     {
         Config config = new Config();
         config.Arguments = new[] { "get", ".", "-recursive" };
         config.BufferSize = 1024;
         config.ImagePath = @"C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\TF.exe";
         config.LogFile = @"D:\foo.txt";
         config.MaxLogSize = 2048;
         config.MaxNumberOfLogBackups = 1;
         config.WorkingDirectory = @"D:\_tfs";
         try
         {
             config.WriteTo(args[0]);
             Console.Out.WriteLine("Wrote a sample config file to " + args[0] + ".  The full path to this file should be placed in the config file's <appSettings> section with the key 'ServiceDefinition'.");
         }
         catch (Exception ex)
         {
             Console.Error.WriteLine(ex.ToString());
             Console.Error.WriteLine();
             Console.Error.WriteLine();
             Console.Error.WriteLine("usage: service-runner [path-to-write-config-file]");
         }
     }
     else
     {
         ServiceBase[] ServicesToRun;
         ServicesToRun = new ServiceBase[]
         {
             new Service1()
         };
         ServiceBase.Run(ServicesToRun);
     }
 }