Пример #1
0
        static void Main(params string[] args)
        {
            try
            {
                Action             commandToExecute   = null;
                CommandLineManager commandLineManager = new CommandLineManager(args, typeof(CommandLineManager).Assembly);
                commandToExecute = commandLineManager.StartTheService;
                if (null != args && args.Length == 1)
                {
                    Regex  regex = new Regex(@"\W*(?i)(\w).*");
                    string arg   = regex.Match(args[0]).Groups[1].Value.ToLower();
                    switch (arg)
                    {
                    case "a": commandToExecute = commandLineManager.ActivateTheService; break;

                    case "i": commandToExecute = commandLineManager.InstallTheService; break;

                    case "u": commandToExecute = commandLineManager.UninstallTheService; break;

                    default:
                        commandToExecute = commandLineManager.StartTheService;
                        break;
                    }
                }
                if (null != commandToExecute)
                {
                    commandToExecute();
                }
            }
            catch (Exception exc)
            {
                CommandLineManager.InternalTrace("failed " + exc.ToString());
            }
        }
Пример #2
0
 protected override void OnStart(string[] args)
 {
     // TODO: Add code here to start your service.
     CommandLineManager.InternalTrace("Started");
 }
Пример #3
0
 protected override void OnStop()
 {
     // TODO: Add code here to perform any tear-down necessary to stop your service.
     CommandLineManager.InternalTrace("Stopped");
 }
Пример #4
0
 static void Main(params string[] args)
 {
     try
     {
         Action commandToExecute = null;
         CommandLineManager commandLineManager = new CommandLineManager(args, typeof(CommandLineManager).Assembly);
         commandToExecute = commandLineManager.StartTheService;
         if (null != args && args.Length == 1)
         {
             Regex regex = new Regex(@"\W*(?i)(\w).*");
             string arg = regex.Match(args[0]).Groups[1].Value.ToLower();
             switch (arg)
             {
                 case "a": commandToExecute = commandLineManager.ActivateTheService; break;
                 case "i": commandToExecute = commandLineManager.InstallTheService; break;
                 case "u": commandToExecute = commandLineManager.UninstallTheService; break;
                 default:
                     commandToExecute = commandLineManager.StartTheService;
                     break;
             }
         }
         if (null != commandToExecute)
             commandToExecute();
     }
     catch (Exception exc)
     {
         CommandLineManager.InternalTrace("failed " + exc.ToString());
     }
 }