Class SemanticBrowserVersion
- Namespace
- CSF.Extensions.WebDriver.Identification
- Assembly
- CSF.Extensions.WebDriver.dll
Implementation of BrowserVersion which represents a semantic version.
public sealed class SemanticBrowserVersion : BrowserVersion, IEquatable<BrowserVersion>, IComparable<BrowserVersion>
- Inheritance
-
SemanticBrowserVersion
- Implements
- Inherited Members
Remarks
This is a version which complies with the specification at https://semver.org
Actually, this class permits version strings which are somewhat less strict than the standards set-out at the
semantic versioning website. The TryParse(string, out SemanticBrowserVersion, bool) method makes
use of the parsing functionality within TryParse(string, SemVersionStyles, out SemVersion, int)
to permit some common improper representations of a semantic version. The TryParse function in this class
uses Semver.SemVersionStyles.Any to enable very generous parsing.
The implementations of CompareTo(BrowserVersion) and Equals(BrowserVersion) include special-case logic for comparing/equating semantic versions with DottedNumericBrowserVersion instances. If these methods (from this type) are used with a dotted numeric version then the current instance is converted into a dotted numeric version first, using ToDottedNumericBrowserVersion(). The equality/comparison methods then make use of CompareTo(BrowserVersion) and Equals(BrowserVersion) accordingly, performing using the comparison functions from the converted version instead.
Constructors
SemanticBrowserVersion(SemVersion, bool)
Initialises a new instance of SemanticBrowserVersion
public SemanticBrowserVersion(SemVersion version, bool isPresumed = false)
Parameters
versionSemVersionThe semantic version.
isPresumedboolWhether or not this is a presumed version; see IsPresumedVersion.
Exceptions
- ArgumentNullException
If
versionis null.
Properties
Version
Gets the semantic version represented by the current instance.
public SemVersion Version { get; }
Property Value
- SemVersion
Methods
CompareTo(BrowserVersion)
public override int CompareTo(BrowserVersion other)
Parameters
otherBrowserVersion
Returns
Equals(BrowserVersion)
public override bool Equals(BrowserVersion other)
Parameters
otherBrowserVersion
Returns
Equals(object)
public override bool Equals(object obj)
Parameters
objobject
Returns
GetHashCode()
public override int GetHashCode()
Returns
Parse(string, bool)
Creates a SemanticBrowserVersion from a string, raising an exception if the string is not a valid version.
public static SemanticBrowserVersion Parse(string version, bool isPresumed = false)
Parameters
versionstringThe version string
isPresumedboolWhether or not this is a presumed version; see IsPresumedVersion
Returns
- SemanticBrowserVersion
A semantic browser version.
Remarks
Consider using TryParse(string, out SemanticBrowserVersion, bool) if you are not certain that the version string is valid.
Exceptions
- FormatException
If the
versionis not a valid semantic version.
ToDottedNumericBrowserVersion()
Converts the current SemanticBrowserVersion into an instance of DottedNumericBrowserVersion.
public DottedNumericBrowserVersion ToDottedNumericBrowserVersion()
Returns
- DottedNumericBrowserVersion
A dotted numeric browser version, created from the major, minor and patch components of this semantic version.
Remarks
This is useful in situations where the current version must be compared with a dotted numeric version. Note that only the Major, Minor and Patch version components are converted. Any prerelease information or build metadata are omitted from this conversion process.
ToString()
public override string ToString()
Returns
TryParse(string, out SemanticBrowserVersion, bool)
Attempts to parse the specified version string as a SemanticBrowserVersion.
public static bool TryParse(string version, out SemanticBrowserVersion result, bool isPresumed = false)
Parameters
versionstringThe version string
resultSemanticBrowserVersionExposes the result when this method returns true
isPresumedboolWhether or not this is a presumed version; see IsPresumedVersion