Class HttpWatcher
Provides a watcher implementation designed to monitor and signal changes applied to an URI resource by raising the Changed event.
public class HttpWatcher : Watcher, IWatcher, IDisposable
- Inheritance
-
HttpWatcher
- Implements
- Inherited Members
Examples
The following example demonstrates how to configure an
using System;
using Cuemon.Net.Http;
namespace MyApp.Examples;
public static class HttpWatcherExample
{
public static void Demonstrate()
{
var watcher = new HttpWatcher(new Uri("https://example.com/feed"), options =>
{
options.ReadResponseBody = true;
options.Period = TimeSpan.FromSeconds(10);
});
Console.WriteLine(watcher.Location);
Console.WriteLine(watcher.ReadResponseBody);
Console.WriteLine(watcher.HashFactory != null);
}
}
Constructors
HttpWatcher(Uri, Action<HttpWatcherOptions>)
Initializes a new instance of the HttpWatcher class.
public HttpWatcher(Uri location, Action<HttpWatcherOptions> setup = null)
Parameters
locationUriThe URI to monitor.
setupAction<HttpWatcherOptions>The HttpWatcherOptions which may be configured.
Properties
Checksum
Gets the checksum that is associated with the URI specified in Location.
public string Checksum { get; }
Property Value
Remarks
If ReadResponseBody is false this property will remain null.
ClientFactory
Gets the function delegate that will resolve an instance of HttpClient.
public Func<HttpClient> ClientFactory { get; }
Property Value
- Func<HttpClient>
The function delegate that will resolve an instance of HttpClient.
HashFactory
Gets the function delegate that will resolve an implementation of Hash.
public Func<Hash> HashFactory { get; }
Property Value
Location
Gets the URI of the resource to watch.
public Uri Location { get; }
Property Value
- Uri
The URI to monitor.
ReadResponseBody
Gets a value indicating whether to compute a hash from the response body.
public bool ReadResponseBody { get; }
Property Value
- bool
trueto compute a hash from the response body; otherwise,false.
Methods
HandleSignalingAsync()
Handles the signaling of this HttpWatcher.
protected override Task HandleSignalingAsync()
Returns
- Task
The task object representing the asynchronous operation.