Sequence-based versioning parsing, managing, and comparing
More...
|
static readonly string | DELIM_STR = DELIM.ToString() |
|
static readonly ushort [] | nullVersion = new ushort[] { 0, 0, 0, 0 } |
|
static readonly ushort [] | maxVersion = new ushort[] { ushort.MaxValue, ushort.MaxValue, ushort.MaxValue, ushort.MaxValue } |
|
Sequence-based versioning parsing, managing, and comparing
Definition at line 10 of file ApplicationVersion.cs.
◆ ApplicationVersion() [1/2]
BGC.Utility.ApplicationVersion.ApplicationVersion |
( |
string |
version | ) |
|
|
inline |
Definition at line 51 of file ApplicationVersion.cs.
53 ushort[] parsedVersion = null;
55 if (
string.IsNullOrEmpty(version))
63 parsedVersion = version.Split(
DELIM).Select(ushort.Parse).ToArray();
67 Debug.LogError($
"Failed to parse version string: {version}");
71 if (parsedVersion == null || parsedVersion.Length == 0)
76 if (parsedVersion.Length <= 4)
82 Debug.LogError($
"ApplicationVersion constructed by string with more than 4 fields: \"{version}\"");
static readonly ushort [] nullVersion
readonly ushort [] versions
◆ ApplicationVersion() [2/2]
BGC.Utility.ApplicationVersion.ApplicationVersion |
( |
params ushort [] |
version | ) |
|
|
inline |
Definition at line 93 of file ApplicationVersion.cs.
95 if (version.Length <= 4)
97 versions = (ushort[])version.Clone();
101 Debug.LogError($
"ApplicationVersion constructed by array with more than 4 fields: {{{string.Join(",
", version.Select(PrintVersionElement))}}}");
readonly ushort [] versions
◆ Between()
Checks if this ApplicationVersion in the range [lowerBound, upperBound)
- Parameters
-
lowerBound | Inclusive lowerBound |
upperBound | Exclusive upperBound |
Definition at line 117 of file ApplicationVersion.cs.
119 if (lowerBound >= upperBound)
121 throw new ArgumentException($
"lowerBound ({lowerBound}) exceeds upperBound ({upperBound})");
124 return (
this < upperBound) && (
this >= lowerBound);
◆ BuildFromWild()
static ApplicationVersion BGC.Utility.ApplicationVersion.BuildFromWild |
( |
string |
version, |
|
|
bool |
upperBound |
|
) |
| |
|
inlinestatic |
Definition at line 170 of file ApplicationVersion.cs.
172 ushort[] parsedVersion = null;
175 string[] splitVersion = version.Split(
DELIM);
176 parsedVersion =
new ushort[4];
178 for (
int i = 0; i < splitVersion.Length; i++)
186 parsedVersion[i] = ushort.Parse(splitVersion[i]);
192 for (
int i = splitVersion.Length; i < parsedVersion.Length; i++)
194 parsedVersion[i] = 0;
200 throw new ArgumentException(
201 message: $
"Bad version parsing: {version}",
202 innerException: excp);
const ushort WILD_CARD_CEIL
ApplicationVersion(string version)
const ushort WILD_CARD_FLOOR
◆ Equals() [1/2]
override bool BGC.Utility.ApplicationVersion.Equals |
( |
object |
obj | ) |
|
|
inline |
Definition at line 212 of file ApplicationVersion.cs.
214 if (ReferenceEquals(null, obj))
219 if (ReferenceEquals(
this, obj))
ApplicationVersion(string version)
override bool Equals(object obj)
◆ Equals() [2/2]
Definition at line 247 of file ApplicationVersion.cs.
249 if (ReferenceEquals(
this, other))
254 for (
int i = 0; i < 4; i++)
258 if (
this[i] != other[i])
◆ GetHashCode()
override int BGC.Utility.ApplicationVersion.GetHashCode |
( |
| ) |
|
|
inline |
◆ IsNull()
bool BGC.Utility.ApplicationVersion.IsNull |
( |
| ) |
|
◆ MatchesPattern()
bool BGC.Utility.ApplicationVersion.MatchesPattern |
( |
string |
pattern | ) |
|
|
inline |
Compares the version number to one that supports asterisk wildcards Unspecified elements are considered wildcards
- Parameters
-
- Returns
Definition at line 135 of file ApplicationVersion.cs.
139 string[] splitVersion = pattern.Split(
DELIM);
141 if (splitVersion.Length > 4)
143 throw new ArgumentException(
144 message: $
"Version pattern had too many version elements: {splitVersion.Length}",
145 paramName: nameof(pattern));
148 for (
int i = 0; i < splitVersion.Length; i++)
152 if (
this[i] != ushort.Parse(splitVersion[i]))
162 throw new ArgumentException(
163 message: $
"Bad version parsing: {pattern}",
164 innerException: excp);
◆ operator ApplicationVersion()
static implicit BGC.Utility.ApplicationVersion.operator ApplicationVersion |
( |
string |
version | ) |
|
|
static |
◆ operator string()
static implicit BGC.Utility.ApplicationVersion.operator string |
( |
in ApplicationVersion |
version | ) |
|
|
static |
◆ operator!=()
◆ operator<()
Definition at line 268 of file ApplicationVersion.cs.
270 for (
int i = 0; i < 4; i++)
274 if (lVersion[i] != rVersion[i])
276 return lVersion[i] < rVersion[i];
◆ operator<=()
Definition at line 300 of file ApplicationVersion.cs.
302 for (
int i = 0; i < 4; i++)
306 if (lVersion[i] != rVersion[i])
308 return lVersion[i] < rVersion[i];
◆ operator==()
Definition at line 332 of file ApplicationVersion.cs.
334 if (ReferenceEquals(lVersion, rVersion))
339 return lVersion.Equals(rVersion);
◆ operator>()
Definition at line 284 of file ApplicationVersion.cs.
286 for (
int i = 0; i < 4; i++)
290 if (lVersion[i] != rVersion[i])
292 return lVersion[i] > rVersion[i];
◆ operator>=()
Definition at line 316 of file ApplicationVersion.cs.
318 for (
int i = 0; i < 4; i++)
322 if (lVersion[i] != rVersion[i])
324 return lVersion[i] > rVersion[i];
◆ PrintVersionElement()
static string BGC.Utility.ApplicationVersion.PrintVersionElement |
( |
ushort |
versionElement | ) |
|
|
inlinestaticprivate |
◆ ToString()
override string BGC.Utility.ApplicationVersion.ToString |
( |
| ) |
|
◆ Build
ushort BGC.Utility.ApplicationVersion.Build => this[2] |
◆ DELIM
const char BGC.Utility.ApplicationVersion.DELIM = '.' |
|
private |
◆ DELIM_STR
readonly string BGC.Utility.ApplicationVersion.DELIM_STR = DELIM.ToString() |
|
staticprivate |
◆ Length
int BGC.Utility.ApplicationVersion.Length => versions.Length |
◆ Major
ushort BGC.Utility.ApplicationVersion.Major => this[0] |
◆ Max
◆ maxVersion
readonly ushort [] BGC.Utility.ApplicationVersion.maxVersion = new ushort[] { ushort.MaxValue, ushort.MaxValue, ushort.MaxValue, ushort.MaxValue } |
|
staticprivate |
◆ Minor
ushort BGC.Utility.ApplicationVersion.Minor => this[1] |
◆ nullVersion
readonly ushort [] BGC.Utility.ApplicationVersion.nullVersion = new ushort[] { 0, 0, 0, 0 } |
|
staticprivate |
◆ NullVersion
◆ Revision
ushort BGC.Utility.ApplicationVersion.Revision => this[3] |
◆ versions
readonly ushort [] BGC.Utility.ApplicationVersion.versions |
|
private |
◆ WILD_CARD
const string BGC.Utility.ApplicationVersion.WILD_CARD = "*" |
|
private |
◆ WILD_CARD_CEIL
const ushort BGC.Utility.ApplicationVersion.WILD_CARD_CEIL = ushort.MaxValue |
|
private |
◆ WILD_CARD_FLOOR
const ushort BGC.Utility.ApplicationVersion.WILD_CARD_FLOOR = ushort.MinValue |
|
private |
◆ this[int i]
ushort BGC.Utility.ApplicationVersion.this[int i] |
|
get |
The documentation for this struct was generated from the following file: