Class UriStringOptions
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
UriStringOptions()
Initializes a new instance of the UriStringOptions class.
public UriStringOptions()
Remarks
The following table shows the initial property values for an instance of UriStringOptions.
| Property | Initial Value |
|---|---|
| Kind | Absolute |
| Schemes | AllUriSchemes |
Properties
AllUriSchemes
Gets all supported URI schemes.
public static IEnumerable<UriScheme> AllUriSchemes { get; }
Property Value
- IEnumerable<UriScheme>
A sequence of all supported URI schemes.
Kind
Gets or sets the kind of the URI.
public UriKind Kind { get; set; }
Property Value
- UriKind
The kind of the URI.
Schemes
Gets or sets a collection of UriScheme values that determines the outcome when parsing a URI.
public IList<UriScheme> Schemes { get; set; }
Property Value
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
Schemes cannot be null.