/// <summary>
        /// The main entry point for the application.
        /// </summary>
        static void Main(string[] args)
        {
            Configuration.Load();
            //
            String path = Configuration.Settings["Log"];

            if (!String.IsNullOrEmpty(path))
            {
                if (!path.Contains(@"\"))
                {
                    String folder = Path.GetDirectoryName(typeof(ServiceEngine).Assembly.Location);
                    path = String.Format(@"{0}\{1}", folder, path);
                }
                Log.Activate(path);
            }
            Log.Create(Program.Name);

#if DEBUG
            args = new String[] { "d" };
#endif
            if (args.Length == 0)
            {
                ServiceBase[] services = new ServiceBase[] { new HostService() };
                ServiceBase.Run(services);
            }
            else if (args.Length == 1)
            {
                String argument = args[0];
                if (argument.Length > 1)
                {
                    argument = argument.Substring(1);
                }
                //
                if (argument.Equals("d"))
                {
                    _daemon = true;
                    //
                    ServiceEngine engine = new ServiceEngine();
                    engine.Start();
                }
                else if (argument.StartsWith("i"))
                {
                    Program.Install();
                }
                else if (argument.StartsWith("u"))
                {
                    Program.Uninstall();
                }
                else
                {
                    Console.WriteLine("Unrecognized command line parameter.");
                }
            }
            else
            {
                Console.WriteLine("Invalid number of command line parameters.");
            }
        }
示例#2
0
 public HostService()
 {
     InitializeComponent();
     //
     _engine = new ServiceEngine();
 }