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(); } }
/// <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(); }
/// <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); } }
public WindowsServiceWebClient(HttpClient client, LoginCredentials credentials = null) { _client = client; _credentials = credentials; }
public WindowsServiceWebClient(string uri, LoginCredentials credentials = null) : this(new HttpClient(uri), credentials) { }