Class MeasureToken
A Token which represents a measurement, which consists of a numeric value and a unit.
Implements
Inherited Members
Namespace: Sdl.LanguagePlatform.Core.Tokenization
Assembly: Sdl.LanguagePlatform.Core.dll
Syntax
public class MeasureToken : NumberToken, ILocalizableToken
Constructors
MeasureToken(MeasureToken)
Initializes a new instance with the values of another instance, creating a deep copy.
Declaration
public MeasureToken(MeasureToken other)
Parameters
Type | Name | Description |
---|---|---|
MeasureToken | other | The instance to create a copy of |
MeasureToken(String, NumberToken, Unit, String, Char, ICultureMetadataManager)
Initializes a new instance with the specified values. This constructor is for internal purposes only and should not be used directly.
Declaration
public MeasureToken(string text, NumberToken numericPart, Unit unit, string unitString, char unitSeparator, ICultureMetadataManager cultureMetadataManager)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | |
NumberToken | numericPart | |
Unit | unit | |
System.String | unitString | |
System.Char | unitSeparator | |
Sdl.Core.Globalization.CultureMetadataManager.ICultureMetadataManager | cultureMetadataManager |
MeasureToken(String, NumberToken, Unit, String, Char, String, ICultureMetadataManager)
Declaration
public MeasureToken(string text, NumberToken numericPart, Unit unit, string unitString, char unitSeparator, string customCategory, ICultureMetadataManager cultureMetadataManager)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | |
NumberToken | numericPart | |
Unit | unit | |
System.String | unitString | |
System.Char | unitSeparator | |
System.String | customCategory | |
Sdl.Core.Globalization.CultureMetadataManager.ICultureMetadataManager | cultureMetadataManager |
Properties
CustomCategory
Gets or sets the CustomCategory for this value, if available (see CustomUnitDefinition)
Declaration
public string CustomCategory { get; set; }
Property Value
Type | Description |
---|---|
System.String |
IsPlaceable
IsPlaceable. Always true
for this class.
Declaration
public override bool IsPlaceable { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Overrides
IsSubstitutable
IsSubstitutable. Always true
for this class.
Declaration
public override bool IsSubstitutable { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Overrides
IsValid
Gets a boolean value which indicates whether this measurement is valid. A measurement is valid if either the unit is not the default unit (Unit.NoUnit) or the UnitString is set. In most cases, both are set by the tokenizer.
Declaration
public bool IsValid { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Unit
Gets or sets the unit.
Declaration
public Unit Unit { get; set; }
Property Value
Type | Description |
---|---|
Unit |
UnitSeparator
Gets or sets the unit separator.
Declaration
public char UnitSeparator { get; set; }
Property Value
Type | Description |
---|---|
System.Char |
UnitString
Gets or sets the unit string, in case the unit is unknown.
Declaration
public string UnitString { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Methods
AcceptSegmentElementVisitor(ISegmentElementVisitor)
Visitor pattern implementation. Calls VisitMeasureToken(MeasureToken).
Declaration
public override void AcceptSegmentElementVisitor(ISegmentElementVisitor visitor)
Parameters
Type | Name | Description |
---|---|---|
ISegmentElementVisitor | visitor | The visitor instance |
Overrides
Duplicate()
See Duplicate()
Declaration
public override SegmentElement Duplicate()
Returns
Type | Description |
---|---|
SegmentElement | A new instance that is a deep copy of this instance. |
Overrides
Equals(Object)
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
System.Object | obj |
Returns
Type | Description |
---|---|
System.Boolean |
Overrides
GetHashCode()
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
System.Int32 |
Overrides
GetSimilarityAsync(SegmentElement, Boolean)
Declaration
public override Task<SegmentElement.Similarity> GetSimilarityAsync(SegmentElement other, bool allowCompatibility)
Parameters
Type | Name | Description |
---|---|---|
SegmentElement | other | |
System.Boolean | allowCompatibility |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<SegmentElement.Similarity> |
Overrides
GetTokenType()
Declaration
protected override TokenType GetTokenType()
Returns
Type | Description |
---|---|
TokenType |
Overrides
LocalizeAsync(CultureInfo, AutoLocalizationSettings, ICultureMetadataManager)
Auto-localizes the token according to the settings of the specified target culture and the provided auto-localization settings. The text of the token will be changed, but not the values.
For some token types, special AutoLocalizationSettings will be used, if provided.
Declaration
public override Task<bool> LocalizeAsync(CultureInfo culture, AutoLocalizationSettings autoLocalizationSettings, ICultureMetadataManager cultureMetadataManager)
Parameters
Type | Name | Description |
---|---|---|
System.Globalization.CultureInfo | culture | The target culture |
AutoLocalizationSettings | autoLocalizationSettings | Contains the AutoLocalizationSettings to use for some token types. May be null, in which case default settings will be used. |
Sdl.Core.Globalization.CultureMetadataManager.ICultureMetadataManager | cultureMetadataManager |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Boolean> |
|
Overrides
LocalizeAsync(CultureInfo, AutoLocalizationSettings, ILocalizableToken, Boolean, ICultureMetadataManager)
Auto-localizes the token according to the settings of the specified target culture and the provided auto-localization settings. The text of the token will be changed, but not the values.
For some token types, special AutoLocalizationSettings will be used, if provided.
Declaration
public override Task<bool> LocalizeAsync(CultureInfo culture, AutoLocalizationSettings autoLocalizationSettings, ILocalizableToken originalMemoryToken, bool adjustCasing, ICultureMetadataManager cultureMetadataManager)
Parameters
Type | Name | Description |
---|---|---|
System.Globalization.CultureInfo | culture | The target culture |
AutoLocalizationSettings | autoLocalizationSettings | Contains the AutoLocalizationSettings to use for some token types. May be null, in which case default settings will be used. |
ILocalizableToken | originalMemoryToken | The original memory token. Some auto-localization settings will be derived from the token, if provided. |
System.Boolean | adjustCasing | If true, it is assumed that the token is in segment-initial position. Then, casing will be adjusted if the original memory token is supplied as well. |
Sdl.Core.Globalization.CultureMetadataManager.ICultureMetadataManager | cultureMetadataManager |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Boolean> |
|
Overrides
SetValue(Token, Boolean)
Overwrites the current token's value with the value from blueprint
, which
also must be a DateTimeToken. Note that only the value and the type are
overwritten, not the textual representation.
Declaration
public override bool SetValue(Token blueprint, bool keepNumericSeparators)
Parameters
Type | Name | Description |
---|---|---|
Token | blueprint | The token to take the value from |
System.Boolean | keepNumericSeparators | Applicable to numeric (number and measurement) tokens only: if true, do not override the original group and decimal separators. |
Returns
Type | Description |
---|---|
System.Boolean | A flag indicating whether the token's value or type were changed. |