Ejemplo n.º 1
0
        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();
            }
        }
Ejemplo n.º 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();
 }
Ejemplo n.º 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);
     }
 }
Ejemplo n.º 4
0
 public WindowsServiceWebClient(HttpClient client, LoginCredentials credentials = null)
 {
     _client = client;
     _credentials = credentials;
 }
Ejemplo n.º 5
0
 public WindowsServiceWebClient(string uri, LoginCredentials credentials = null)
     : this(new HttpClient(uri), credentials)
 {
 }
Ejemplo n.º 6
0
 public WindowsServiceWebClient(HttpClient client, LoginCredentials credentials = null)
 {
     _client      = client;
     _credentials = credentials;
 }
Ejemplo n.º 7
0
 public WindowsServiceWebClient(string uri, LoginCredentials credentials = null)
     : this(new HttpClient(uri), credentials)
 {
 }