Struct StatusCodeRange
Represents a range between two HTTP status codes and provides methods for determining whether status codes fall within this range.
Implements
Namespace: ReqRest.Http
Assembly: ReqRest.dll
Syntax
public struct StatusCodeRange : IEquatable<StatusCodeRange>
Constructors
StatusCodeRange(Nullable<Int32>)
Initializes a new StatusCodeRange instance which only spans a single status code.
Declaration
public StatusCodeRange(int? singleStatusCode)
Parameters
| Type | Name | Description |
|---|---|---|
| Nullable<Int32> | singleStatusCode | The single status code that is covered by this range. If null, this range is equal to All and will thus cover every single available status code. |
StatusCodeRange(Nullable<Int32>, Nullable<Int32>)
Initializes a new StatusCodeRange instance which starts at
from and ends at to.
Declaration
public StatusCodeRange(int? from, int? to)
Parameters
| Type | Name | Description |
|---|---|---|
| Nullable<Int32> | from | The status code where the range starts. If null, every single status code before
If |
| Nullable<Int32> | to | The status code where the range ends. If null, every single status code after
If |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException |
|
Fields
All
A StatusCodeRange which covers every single status code that is available.
Declaration
public static readonly StatusCodeRange All
ClientErrors
A StatusCodeRange which covers status codes that indicate client errors, i.e.
status codes from 400 to 499.
Declaration
public static readonly StatusCodeRange ClientErrors
Errors
A StatusCodeRange which covers status codes that indicate either
client or a server errors, i.e. status codes from 400 to 599.
This is basically a unification of ClientErrors and ServerErrors.
Declaration
public static readonly StatusCodeRange Errors
Informational
A StatusCodeRange which covers informational status codes, i.e.
status codes from 100 to 199.
Declaration
public static readonly StatusCodeRange Informational
Redirection
A StatusCodeRange which covers status codes that indicate a redirection, i.e.
status codes from 300 to 399.
Declaration
public static readonly StatusCodeRange Redirection
ServerErrors
A StatusCodeRange which covers status codes that indicate server errors, i.e.
status codes from 500 to 599.
Declaration
public static readonly StatusCodeRange ServerErrors
Success
A StatusCodeRange which covers status codes that indicate success, i.e.
status codes from 200 to 299.
Declaration
public static readonly StatusCodeRange Success
Properties
From
Gets or sets the status code where the range starts.
If null, every single status code before To is covered by this range.
If To is also null, this range covers every available status code.
Declaration
public int? From { get; }
HasWildcardComponent
Declaration
public bool HasWildcardComponent { get; }
IsSingleStatusCode
Gets a value indicating whether this range spans only a single status code, i.e. if From equals To. The only exception to this rule is this range being All. If so, this returns false.
Declaration
public bool IsSingleStatusCode { get; }
To
Gets or sets the status code where the range ends.
If null, every single status code after From is covered by this range.
If From is also null, this range covers every available status code.
Declaration
public int? To { get; }
Methods
Equals(StatusCodeRange)
Returns a value indicating whether this status code range equals the
other one.
Declaration
public bool Equals(StatusCodeRange other)
Parameters
| Type | Name | Description |
|---|---|---|
| StatusCodeRange | other | Another StatusCodeRange instance. |
Returns
| Type | Description |
|---|---|
| Boolean | true the two ranges are considered equal; false if not. |
Equals(Object)
Returns a value indicating whether this status code range equals the specified object.
Declaration
public override bool Equals(object obj)
Parameters
| Type | Name | Description |
|---|---|---|
| Object | obj | An object to be compared with this status code range. |
Returns
| Type | Description |
|---|---|
| Boolean | true the two objects are considered equal; false if not. |
Overrides
GetHashCode()
Returns a unique hash code for this status code range.
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| Int32 | A unique hash code. |
Overrides
IsInRange(StatusCodeRange)
Returns a value indicating whether the other specified status
code range falls within this range.
This will also return true if the ranges have equal values.
For example, this will return true for (200-300), (250-300).
Declaration
public bool IsInRange(StatusCodeRange other)
Parameters
| Type | Name | Description |
|---|---|---|
| StatusCodeRange | other | The other status code range to be checked. |
Returns
| Type | Description |
|---|---|
| Boolean | true if |
ToString()
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| String | A string representing the current status code range. |
Overrides
Operators
Equality(StatusCodeRange, StatusCodeRange)
Declaration
public static bool operator ==(StatusCodeRange left, StatusCodeRange right)
Parameters
| Type | Name | Description |
|---|---|---|
| StatusCodeRange | left | |
| StatusCodeRange | right |
Returns
| Type | Description |
|---|---|
| Boolean |
See Also
Implicit(Nullable<Int32> to StatusCodeRange)
Creates a new StatusCodeRange instance which only spans the
specified singleStatusCode.
Declaration
public static implicit operator StatusCodeRange(int? singleStatusCode)
Parameters
| Type | Name | Description |
|---|---|---|
| Nullable<Int32> | singleStatusCode | The single status code that is covered by this range. If null, this range is equal to All and will thus cover every single available status code. |
Returns
| Type | Description |
|---|---|
| StatusCodeRange |
Implicit((Nullable<Int32> From, Nullable<Int32> To) to StatusCodeRange)
Creates a new StatusCodeRange instance with the range values defined by the specified tuple.
Declaration
public static implicit operator StatusCodeRange((int? From, int? To)range)
Parameters
| Type | Name | Description |
|---|---|---|
| ValueTuple<Nullable<Int32>, Nullable<Int32>> | range | A tuple where the first value corresponds to From and the second value to To. |
Returns
| Type | Description |
|---|---|
| StatusCodeRange |
Inequality(StatusCodeRange, StatusCodeRange)
Declaration
public static bool operator !=(StatusCodeRange left, StatusCodeRange right)
Parameters
| Type | Name | Description |
|---|---|---|
| StatusCodeRange | left | |
| StatusCodeRange | right |
Returns
| Type | Description |
|---|---|
| Boolean |