コード例 #1
0
ファイル: Program.cs プロジェクト: BobbyCannon/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();
            }
        }
コード例 #2
0
 /// <summary>
 /// Allows the client to log in to the service. This only has to be implemented by services that require
 /// authentication. If you service does not require authentication then just leave this method not implemented.
 /// </summary>
 /// <param name="credentials">The credentials to use for authentication.</param>
 public void Login(LoginCredentials credentials)
 {
     throw new NotImplementedException();
 }
コード例 #3
0
 /// <summary>
 /// Allows the client to log in to the service. This only has to be implemented by services that require
 /// authentication. If you service does not require authentication then just leave this method not implemented.
 /// </summary>
 /// <param name="credentials">The credentials to use for authentication.</param>
 public void Login(LoginCredentials credentials)
 {
     using (var response = _client.Post("Login", credentials))
     {
         CheckResponse(response);
     }
 }
コード例 #4
0
 public WindowsServiceWebClient(HttpClient client, LoginCredentials credentials = null)
 {
     _client = client;
     _credentials = credentials;
 }
コード例 #5
0
 public WindowsServiceWebClient(string uri, LoginCredentials credentials = null)
     : this(new HttpClient(uri), credentials)
 {
 }
コード例 #6
0
 public WindowsServiceWebClient(HttpClient client, LoginCredentials credentials = null)
 {
     _client      = client;
     _credentials = credentials;
 }
コード例 #7
0
 public WindowsServiceWebClient(string uri, LoginCredentials credentials = null)
     : this(new HttpClient(uri), credentials)
 {
 }