Class ApiVersion
Used to specify ASP.NET API versions.
Namespace: Neon.ModelGen
Assembly: Neon.Common.dll
Syntax
public class ApiVersion
Remarks
API versions are formatted like:
[VERSIONGROUP.]MAJOR.MINOR[-STATUS]
or:
VERSIONGROUP[MAJOR[.MINOR]][-STATUS]
where VERSIONGROUP is a date formatted like YYYY-MM-DD, MAJOR and MINOR are non-negative integers, and STATUS is an alphanumberic string starting with a letter. Here are some valid version strings:
1.0 | major and minor version numbers |
1.0-alpha | major and minor version numbers with status |
2023-04-09 | Version group date |
2023-04-09-alpha | Version group date with status |
2023-04-09.1.0 | Version group with major and minor versions |
2023-04-09.1.0-alpha | Version group with major and minor versions plus status |
2023-04.091 |
Version group with only major version (1) noteThis format is a bit odd and may be confusing. We recommend that you avoid using this. |
2023-04.091-alpha |
Version group with only major version (1) and status noteThis format is a bit odd and may be confusing. We recommend that you avoid using this. |
2023-04.091.0 |
Version group with major and minor versions noteThis format is a bit odd and may be confusing. We recommend that you avoid using this. |
2023-04.091.0-alpha |
Version group with major and minor versions with status noteThis format is a bit odd and may be confusing. We recommend that you avoid using this. |
Properties
Major
Returns the major version number.
note
This returns as -1 when the parsed version string didn't include a major version.
Declaration
public int Major { get; }
Property Value
Type | Description |
---|---|
int |
Minor
Returns the minor version number.
note
This returns as -1 when the parsed version string didn't include a minor version.
Declaration
public int Minor { get; }
Property Value
Type | Description |
---|---|
int |
Status
Returns the status part.
Declaration
public string Status { get; }
Property Value
Type | Description |
---|---|
string |
VersionGroup
Returns the version group date.
note
This returns as 0001-01-01 when the parsed version string didn't include a version group.
Declaration
public DateTime VersionGroup { get; }
Property Value
Type | Description |
---|---|
DateTime |
Methods
CompareTo(ApiVersion)
Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.
Declaration
public int CompareTo(ApiVersion other)
Parameters
Type | Name | Description |
---|---|---|
ApiVersion | other | An object to compare with this instance. |
Returns
Type | Description | ||||||||
---|---|---|---|---|---|---|---|---|---|
int | A value that indicates the relative order of the objects being compared. The return value has these meanings:
|
Parse(string)
Parses a ApiVersion, formatted like:
API versions are formatted like:
[VERSIONGROUP.]MAJOR.MINOR[-STATUS]
or:
VERSIONGROUP[MAJOR[.MINOR]][-STATUS]
where VERSIONGROUP is a date formatted like YYYY-MM-DD, MAJOR and MINOR are non-negative integers, and STATUS is an alphanumberic string starting with a letter.
Declaration
public static ApiVersion Parse(string version)
Parameters
Type | Name | Description |
---|---|---|
string | version | The version string, |
Returns
Type | Description |
---|---|
ApiVersion | The parsed ApiVersion. |
Exceptions
Type | Condition |
---|---|
FormatException | Thrown for an invalid version string. |
ToString()
Returns a string that represents the current object.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string | A string that represents the current object. |