Table of Contents

UriStringOptions Class

Definition

Namespace
Cuemon.Text
Assemblies
Cuemon.Kernel.dll
Source
src/Cuemon.Kernel/Text/UriStringOptions.cs

Configuration options for concrete implementations of IConfigurableParser<TOptions> that is related to parsing a Uri from a string.

public class UriStringOptions : IValidatableParameterObject, IParameterObject
Inheritance
UriStringOptions
Implements

Examples

The following example demonstrates how to configure UriStringOptions to validate and inspect URI properties including kind and allowed schemes.

using System;
using System.Collections.Generic;
using System.Linq;
using Cuemon;
using Cuemon.Text;

namespace Contoso.Webhooks;

public sealed class UriStringOptionsExample
{
    public static void Run()
    {
        var options = new UriStringOptions
        {
            Kind = UriKind.Absolute,
            Schemes = new List<UriScheme> { UriScheme.Https, UriScheme.Http }
        };

        options.ValidateOptions();

        bool allowsHttps = options.Schemes.Contains(UriScheme.Https);
        int knownSchemes = UriStringOptions.AllUriSchemes.Count();

        Console.WriteLine($"Kind: {options.Kind}");
        Console.WriteLine($"Allows HTTPS: {allowsHttps}");
        Console.WriteLine($"Known schemes: {knownSchemes}");
    }
}

Constructors

Name Description
UriStringOptions()

Initializes a new instance of the UriStringOptions class.

Properties

Name Description
AllUriSchemes

Gets all supported URI schemes.

Kind

Gets or sets the kind of the URI.

Schemes

Gets or sets a collection of UriScheme values that determines the outcome when parsing a URI.

Methods

Name Description
ValidateOptions()

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

See Also