Class ServerLocationInfo
Represents a server location: a country, a region in it, and tags, written as US/California [#premium].
public class ServerLocationInfo : IComparable<ServerLocationInfo>
- Inheritance
-
ServerLocationInfo
- Implements
- Inherited Members
Remarks
Two locations are equal when their countries and regions are, whatever their tags.
Fields
AutoCountryCode
The country code of the automatic location: *.
public const string AutoCountryCode = "*"
Field Value
AutoRegionName
The region name of the automatic location, or of any region: *.
public const string AutoRegionName = "*"
Field Value
Properties
CountryCode
Gets the country's two-letter code, or AutoCountryCode.
public required string CountryCode { get; init; }
Property Value
CountryName
Gets the country's English name; * for the automatic location, and the code in upper case where .NET
knows no country of it.
public string CountryName { get; }
Property Value
HasRegion
Gets a value indicating whether the location names a region.
public bool HasRegion { get; }
Property Value
IsAuto
Gets a value indicating whether this is the automatic location, /.
public bool IsAuto { get; }
Property Value
RegionName
Gets the region's name, or AutoRegionName.
public required string RegionName { get; init; }
Property Value
ServerLocation
Gets the location without its tags, as US/California.
public string ServerLocation { get; }
Property Value
Tags
Gets or sets the location's tags, such as those of ServerRegisteredTags, or null.
public string[]? Tags { get; set; }
Property Value
- string[]
Methods
CompareTo(ServerLocationInfo?)
Compares the location with another, by country name, then region name, ignoring case.
public int CompareTo(ServerLocationInfo? other)
Parameters
otherServerLocationInfoThe other location, or null, which sorts first.
Returns
- int
Less than 0 if this location sorts first, 0 if they sort together, more than 0 if it sorts after.
Equals(object?)
Determines whether an object is a location of the same country and region.
public override bool Equals(object? obj)
Parameters
objobjectThe object.
Returns
Remarks
The codes and names are compared as written, case included.
GetHashCode()
Gets a hash of the location's country and region.
public override int GetHashCode()
Returns
- int
The hash.
IsAutoLocation(string?)
Determines whether a written location is the automatic one.
public static bool IsAutoLocation(string? serverLocation)
Parameters
serverLocationstringThe written location.
Returns
IsMatch(ServerLocationInfo)
Determines whether this location, a server's, matches a location asked for, whose * parts match any.
public bool IsMatch(ServerLocationInfo serverLocationInfo)
Parameters
serverLocationInfoServerLocationInfoThe location asked for.
Returns
LocationEquals(string?)
Determines whether a written location is this one, as Equals(object?) compares them.
public bool LocationEquals(string? serverLocation)
Parameters
Returns
Parse(string)
Reads a location written as CountryCode/RegionName [#tag1 #tag2].
public static ServerLocationInfo Parse(string value)
Parameters
valuestringThe text. A missing or blank country or region reads as
*; the country code is made upper case; the tags, in brackets, are split at spaces.
Returns
- ServerLocationInfo
The location.
ToString()
Writes the location as Parse(string) reads it, with its tags in brackets when it has any.
public override string ToString()
Returns
- string
The text, such as
US/California [#premium].
TryParse(string)
Reads a location as Parse(string) does, or gives null where that throws.
public static ServerLocationInfo? TryParse(string value)
Parameters
valuestringThe text.
Returns
- ServerLocationInfo
The location, or null.