示例#1
0
文件: Program.cs 项目: gspike/HostR
        private static void Main(string[] args)
        {
            var arguments = WindowsServiceArguments.Create(args);
            var service   = new Service("HostR BasicService", "Really simple windows service.", arguments);

            service.Start();
        }
        public void ParseInstall()
        {
            var expected = new WindowsServiceArguments();

            expected.InstallService = true;

            var actual = WindowsServiceArguments.Create(new[] { "-i" });

            TestHelper.AreEqual(expected, actual);
        }
        public void ParseHelp()
        {
            var expected = new WindowsServiceArguments();

            expected.ShowHelp = true;

            var actual = WindowsServiceArguments.Create(new[] { "-?" });

            TestHelper.AreEqual(expected, actual);
        }
        public void ParseDebugger()
        {
            var expected = new WindowsServiceArguments();

            expected.WaitForDebugger = true;

            var actual = WindowsServiceArguments.Create(new[] { "-d" });

            TestHelper.AreEqual(expected, actual);
        }
        public void ParseDirectoryToUpgrade()
        {
            var expected = new WindowsServiceArguments();

            expected.UpdateService      = true;
            expected.DirectoryToUpgrade = "C:\\Users\\Bobby\\Desktop\\Test";

            var actual = WindowsServiceArguments.Create(new[] { "-r", "C:\\Users\\Bobby\\Desktop\\Test" });

            TestHelper.AreEqual(expected, actual);
        }
        public void ParseCustomArgumentWithoutValueForService()
        {
            var expected = new WindowsServiceArguments();

            expected.OtherValues.Add("-c", "");
            expected.ServiceArguments = "-c";

            var actual = WindowsServiceArguments.Create(new[] { "-c" });

            TestHelper.AreEqual(expected, actual);
        }
        public void ParseVerbose()
        {
            var expected = new WindowsServiceArguments();

            expected.VerboseLogging   = true;
            expected.ServiceArguments = "-v";

            var actual = WindowsServiceArguments.Create(new[] { "-v" });

            TestHelper.AreEqual(expected, actual);
        }
        public void ParseServiceWebApi()
        {
            var expected = new WindowsServiceArguments();

            expected.ServiceWebApi    = "http://localhost";
            expected.ServiceArguments = "-w http://localhost";

            var actual = WindowsServiceArguments.Create(new[] { "-w", "http://localhost" });

            TestHelper.AreEqual(expected, actual);
        }
        public void ParseServiceName()
        {
            var expected = new WindowsServiceArguments();

            expected.ServiceName      = "MyService";
            expected.ServiceArguments = "-n MyService";

            var actual = WindowsServiceArguments.Create(new[] { "-n", "MyService" });

            TestHelper.AreEqual(expected, actual);
        }
        public void ParseServiceWebApiUserNamePassword()
        {
            var expected = new WindowsServiceArguments();

            expected.ServiceWebApi         = "http://localhost";
            expected.ServiceWebApiPassword = "******";
            expected.ServiceWebApiUserName = "******";
            expected.ServiceArguments      = "-w http://localhost -l admin -p P@ssw0rd!";

            var actual = WindowsServiceArguments.Create(new[] { "-w", "http://localhost", "-l", "admin", "-p", "P@ssw0rd!" });

            TestHelper.AreEqual(expected, actual);
        }
示例#11
0
文件: Program.cs 项目: gspike/HostR
        private static void Main(string[] args)
        {
            var     arguments = WindowsServiceArguments.Create(args);
            Service service;

            if (string.IsNullOrEmpty(arguments.ServiceWebApi))
            {
                service = new Service("HostR Agent", "Service agent for HostR.", arguments, null);
                service.Start();
            }
            else
            {
                var credentials = new LoginCredentials {
                    UserName = arguments.ServiceWebApiUserName, Password = arguments.ServiceWebApiPassword
                };
                var client = string.IsNullOrWhiteSpace(credentials.UserName)
                                        ? new WindowsServiceWebClient(arguments.ServiceWebApi)
                                        : new WindowsServiceWebClient(arguments.ServiceWebApi, credentials);

                service = new Service("HostR Agent", "Service agent for HostR.", arguments, client);
                service.Start();
            }
        }
示例#12
0
文件: Program.cs 项目: gspike/HostR
 /// <summary>
 /// Initializes a new instance of the WindowsSerivce class.
 /// </summary>
 public Service(string displayName, string description, WindowsServiceArguments arguments, IWindowsServiceWebService client)
     : base(displayName, description, arguments, client)
 {
 }
示例#13
0
文件: Program.cs 项目: gspike/HostR
 /// <summary>
 /// Initializes a new instance of the WindowsService class.
 /// </summary>
 public Service(string displayName, string description, WindowsServiceArguments arguments)
     : base(displayName, description, arguments)
 {
 }