Class PhysicalUnit
Encapsulates information about the available physical units and their interrelationships.
Inheritance
Inherited Members
Namespace: Sdl.LanguagePlatform.Core.Tokenization
Assembly: Sdl.LanguagePlatform.Core.dll
Syntax
public static class PhysicalUnit
Methods
AreUnitKeysSameClass(CultureInfo, String, String)
Declaration
public static bool AreUnitKeysSameClass(CultureInfo ci, string key1, string key2)
Parameters
Type | Name | Description |
---|---|---|
System.Globalization.CultureInfo | ci | |
System.String | key1 | |
System.String | key2 |
Returns
Type | Description |
---|---|
System.Boolean |
AreUnitsSameCategory(String, String)
Declaration
[Obsolete]
public static bool AreUnitsSameCategory(string unitA, string unitB)
Parameters
Type | Name | Description |
---|---|---|
System.String | unitA | |
System.String | unitB |
Returns
Type | Description |
---|---|
System.Boolean |
AreUnitsSameClass(CultureInfo, Unit, Unit)
Declaration
public static bool AreUnitsSameClass(CultureInfo ci, Unit u1, Unit u2)
Parameters
Type | Name | Description |
---|---|---|
System.Globalization.CultureInfo | ci | |
Unit | u1 | |
Unit | u2 |
Returns
Type | Description |
---|---|
System.Boolean |
AreUnitsSameClass(CultureInfo, String, String)
Determine whether one unit can autosubstitute for another, based on whether they measure the same time of thing (length, area, volume ...)
Declaration
public static bool AreUnitsSameClass(CultureInfo ci, string unitA, string unitB)
Parameters
Type | Name | Description |
---|---|---|
System.Globalization.CultureInfo | ci | |
System.String | unitA | |
System.String | unitB |
Returns
Type | Description |
---|---|
System.Boolean |
AreUnitTypesCompatible(Unit, Unit)
Determines whether the unit types of the specified units are compatible. Two unit types are compatible if both their types are well-defined (not "other" or "no type") and are identical.
Declaration
[Obsolete]
public static bool AreUnitTypesCompatible(Unit a, Unit b)
Parameters
Type | Name | Description |
---|---|---|
Unit | a | The first unit |
Unit | b | The second unit |
Returns
Type | Description |
---|---|
System.Boolean | A flag indicating whether the units' types are compatible or not. |
Find(String, UnitSystem, CultureInfo)
Looks up and returns the unit associated with the specified unit abbreviation.
Declaration
public static Unit Find(string abbreviation, UnitSystem preferredSystem, CultureInfo culture)
Parameters
Type | Name | Description |
---|---|---|
System.String | abbreviation | The unit abbreviation |
UnitSystem | preferredSystem | The preferred system, in case the abbreviation is known in multiple systems. |
System.Globalization.CultureInfo | culture | The optional culture to use during lookup, in case the abbreviation is culture-specific or the preferred system needs to be determined from the culture |
Returns
Type | Description |
---|---|
Unit | The unit which most closely matches the search criteria |
Find(String, CultureInfo)
Looks up and returns the unit associated with the specified unit abbreviation. The default unit system for the abbreviation is determined by looking up the default system for capacity in the specified culture.
Declaration
public static Unit Find(string abbreviation, CultureInfo culture)
Parameters
Type | Name | Description |
---|---|---|
System.String | abbreviation | The unit abbreviation |
System.Globalization.CultureInfo | culture | The optional culture to use during lookup, in case the abbreviation is culture-specific or the preferred system needs to be determined from the culture |
Returns
Type | Description |
---|---|
Unit | The unit which most closely matches the search criteria |
GetAbbreviations(Unit)
Gets the known abbreviations for the specified unit. The return value may indicate vertical bars to indicate multiple alternative abbreviations.
Declaration
public static string GetAbbreviations(Unit unit)
Parameters
Type | Name | Description |
---|---|---|
Unit | unit | The unit to look up |
Returns
Type | Description |
---|---|
System.String | The known abbreviations for the unit, or |
GetDefaultSystem(UnitType, CultureInfo)
Determines the default UnitSystem for the specified unit type in the specified culture.
Declaration
public static UnitSystem GetDefaultSystem(UnitType type, CultureInfo culture)
Parameters
Type | Name | Description |
---|---|---|
UnitType | type | The type of the unit |
System.Globalization.CultureInfo | culture | The culture to determine the default system for |
Returns
Type | Description |
---|---|
UnitSystem | The default unit system for the specified combination of unit type and culture, or Metric if no information about the default system is available. |
GetName(Unit)
Gets the name for the specified unit.
Declaration
public static string GetName(Unit unit)
Parameters
Type | Name | Description |
---|---|---|
Unit | unit | The unit |
Returns
Type | Description |
---|---|
System.String | The name of the unit, or |
GetPreferredAbbreviation(Unit, CultureInfo)
Gets the preferred abbreviation for the specified unit. The preferred abbreviation is used for auto-localization.
Declaration
public static string GetPreferredAbbreviation(Unit unit, CultureInfo culture)
Parameters
Type | Name | Description |
---|---|---|
Unit | unit | The unit to look up |
System.Globalization.CultureInfo | culture | An optional culture, in which case the method will return the preferred abbreviation for the target culture (currently ignored) |
Returns
Type | Description |
---|---|
System.String | The preferred abbreviation for the unit, or |
GetSystem(Unit)
Obtains the UnitSystem of the specified unit.
Declaration
public static UnitSystem GetSystem(Unit unit)
Parameters
Type | Name | Description |
---|---|---|
Unit | unit | The unit to look up |
Returns
Type | Description |
---|---|
UnitSystem | The unit system of the unit, or NoSystem if the unit is unknown. |
GetUnits(CultureInfo, Boolean)
Returns a word list which contains all units known for the provided culture.
Declaration
public static Wordlist GetUnits(CultureInfo culture, bool includeDefaultAbbreviationsWithCultureAbbreviations)
Parameters
Type | Name | Description |
---|---|---|
System.Globalization.CultureInfo | culture | The culture (may be null) |
System.Boolean | includeDefaultAbbreviationsWithCultureAbbreviations | If true, the default units are included with the culture-specifc units. |
Returns
Type | Description |
---|---|
Wordlist | A word list which includes the relevant units. |
GetUnitsRX(CultureInfo, Boolean)
Returns a regular expression which matches all units known for the provided culture.
Declaration
public static string GetUnitsRX(CultureInfo culture, bool includeDefaultAbbreviationsWithCultureAbbreviations)
Parameters
Type | Name | Description |
---|---|---|
System.Globalization.CultureInfo | culture | The culture (may be null) |
System.Boolean | includeDefaultAbbreviationsWithCultureAbbreviations | If true, the default units are included with the culture-specifc units. |
Returns
Type | Description |
---|---|
System.String | A string representing a regular expression. |
GetUnitType(Unit)
Obtains the UnitType of the specified unit.
Declaration
public static UnitType GetUnitType(Unit unit)
Parameters
Type | Name | Description |
---|---|---|
Unit | unit | The unit to look up |
Returns
Type | Description |
---|---|
UnitType | The unit type of the unit, or NoType if the unit is unknown. |
IsMetric(Unit)
Determines whether the specified unit belongs to the metric system.
Declaration
public static bool IsMetric(Unit unit)
Parameters
Type | Name | Description |
---|---|---|
Unit | unit | The unit |
Returns
Type | Description |
---|---|
System.Boolean |
|