Class MetadataIdentifier
An individual metadata identifier for a semantic version.
Inheritance
System.Object
MetadataIdentifier
Implements
System.IEquatable<MetadataIdentifier>
System.IComparable<MetadataIdentifier>
System.IComparable
Namespace: Semver
Assembly: Semver.dll
Syntax
public sealed class MetadataIdentifier : ValueType
Remarks
The metadata for a semantic version is composed of dot ('.') separated identifiers.
A valid identifier is a non-empty string of ASCII alphanumeric and hyphen characters
([0-9A-Za-z-]). Metadata identifiers are compared lexically in ASCII sort order.
Because MetadataIdentifier is a struct, the default value is a MetadataIdentifier with a null value. However, the Semver namespace types do not accept and will not return such a MetadataIdentifier.
Constructors
MetadataIdentifier(String)
Constructs a valid MetadataIdentifier.
Declaration
public MetadataIdentifier(string value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | value |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | The value is null. |
| System.ArgumentException | The value is empty or contains invalid characters
(i.e. characters that are not ASCII alphanumerics or hyphens). |
Properties
Value
The string value of the metadata identifier.
Declaration
public string Value { get; }
Property Value
| Type | Description |
|---|---|
| System.String | The string value of this metadata identifier or null if this is a default MetadataIdentifier. |
Methods
CompareTo(MetadataIdentifier)
Compares two identifiers and indicates whether this instance precedes, follows, or is
equal to the other in sort order.
Declaration
public int CompareTo(MetadataIdentifier value)
Parameters
| Type | Name | Description |
|---|---|---|
| MetadataIdentifier | value |
Returns
| Type | Description | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| System.Int32 |
An integer that indicates whether this instance precedes, follows, or is equal to
value in sort order.
|
Remarks
Identifiers are compared lexically in ASCII sort order. Invalid identifiers are
compared via an ordinal string comparison.
CompareTo(Object)
Compares this identifier to an System.Object and indicates whether this instance
precedes, follows, or is equal to the object in sort order.
Declaration
public int CompareTo(object value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | value |
Returns
| Type | Description | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| System.Int32 |
An integer that indicates whether this instance precedes, follows, or is equal to
value in sort order.
|
Remarks
Identifiers are compared lexically in ASCII sort order. Invalid identifiers are
compared via an ordinal string comparison.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException | value is not a MetadataIdentifier. |
Equals(MetadataIdentifier)
Determines whether two identifiers are equal.
Declaration
public bool Equals(MetadataIdentifier value)
Parameters
| Type | Name | Description |
|---|---|---|
| MetadataIdentifier | value |
Returns
| Type | Description |
|---|---|
| System.Boolean | true if value is equal to this identifier;
otherwise false. |
Equals(Object)
Determines whether the given object is equal to this identifier.
Declaration
public override bool Equals(object value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | value |
Returns
| Type | Description |
|---|---|
| System.Boolean | true if value is equal to this identifier;
otherwise false. |
GetHashCode()
Gets a hash code for this identifier.
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| System.Int32 | A hash code for this identifier. |
ToString()
Converts this identifier into an equivalent string value.
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| System.String | The string value of this identifier or null if this is a default MetadataIdentifier |
Operators
Equality(MetadataIdentifier, MetadataIdentifier)
Determines whether two identifiers are equal.
Declaration
public static bool operator ==(MetadataIdentifier left, MetadataIdentifier right)
Parameters
| Type | Name | Description |
|---|---|---|
| MetadataIdentifier | left | |
| MetadataIdentifier | right |
Returns
| Type | Description |
|---|---|
| System.Boolean | true if the value of left is the same as
the value of right; otherwise false. |
Implicit(MetadataIdentifier to String)
Converts this identifier into an equivalent string value.
Declaration
public static implicit operator string (MetadataIdentifier metadataIdentifier)
Parameters
| Type | Name | Description |
|---|---|---|
| MetadataIdentifier | metadataIdentifier |
Returns
| Type | Description |
|---|---|
| System.String | The string value of this identifier or null if this is a default MetadataIdentifier. |
Inequality(MetadataIdentifier, MetadataIdentifier)
Determines whether two identifiers are not equal.
Declaration
public static bool operator !=(MetadataIdentifier left, MetadataIdentifier right)
Parameters
| Type | Name | Description |
|---|---|---|
| MetadataIdentifier | left | |
| MetadataIdentifier | right |
Returns
| Type | Description |
|---|---|
| System.Boolean | true if the value of left is different
from the value of right; otherwise false. |
Implements
System.IEquatable<>
System.IComparable<>
System.IComparable