Table of Contents

Class HttpWatcherOptions

Namespace
Cuemon.Net.Http
Assembly
Cuemon.Net.dll

Configuration options for HttpWatcher.

public class HttpWatcherOptions : WatcherOptions, IValidatableParameterObject, IParameterObject
Inheritance
HttpWatcherOptions
Implements
Inherited Members

Examples

The following example demonstrates how to configure before creating an .

using System;
using System.Net.Http;
using Cuemon.Net.Http;
using Cuemon.Security;

namespace MyApp.Examples;

public static class HttpWatcherOptionsExample
{
    public static void Demonstrate()
    {
        var options = new HttpWatcherOptions
        {
            ClientFactory = () => new HttpClient(new HttpClientHandler(), false),
            HashFactory = () => new CyclicRedundancyCheck64(),
            ReadResponseBody = true,
            Period = TimeSpan.FromSeconds(5)
        };

        options.ValidateOptions();

        Console.WriteLine(options.ReadResponseBody);
        Console.WriteLine(options.Period.TotalSeconds);
        Console.WriteLine(options.ClientFactory().GetType().Name);
    }
}

Constructors

HttpWatcherOptions()

Initializes a new instance of the HttpWatcherOptions class.

public HttpWatcherOptions()

Remarks

The following table shows the initial property values for an instance of <xref href="Cuemon.Net.Http.HttpWatcherOptions" data-throw-if-not-resolved="false"></xref>.

<table><thead><tr><th class="term">Property</th><th class="description">Initial Value</th></tr></thead><tbody><tr><td class="term"><xref href="Cuemon.Net.Http.HttpWatcherOptions.ClientFactory" data-throw-if-not-resolved="false"></xref></td><td class="description"><pre><code class="lang-csharp">() => new HttpClient(new HttpClientHandler()

{ AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate, MaxAutomaticRedirections = 10 }, false)HashFactory() => new CyclicRedundancyCheck64()ReadResponseBodyfalse

Properties

ClientFactory

Gets or sets the function delegate that will resolve an instance of HttpClient.

public Func<HttpClient> ClientFactory { get; set; }

Property Value

Func<HttpClient>

The function delegate that will resolve an instance of HttpClient.

HashFactory

Gets or sets the function delegate that will resolve an implementation of Hash.

public Func<Hash> HashFactory { get; set; }

Property Value

Func<Hash>

The function delegate that will resolve an implementation of Hash.

ReadResponseBody

Gets or sets a value indicating whether to compute a hash from the response data of the HttpWatcher.

public bool ReadResponseBody { get; set; }

Property Value

bool

true to compute a hash from the response data of the HttpWatcher; otherwise, false.

Methods

ValidateOptions()

Determines whether the public read-write properties of this instance are in a valid state.

public void ValidateOptions()

Remarks

This method is expected to throw exceptions when one or more conditions fails to be in a valid state.

Exceptions

InvalidOperationException

ClientFactory cannot be null - or - HashFactory cannot be null.