Class MeasureToken
A Token which represents a measurement, which consists of a numeric value and a unit.
Implements
Inherited Members
Namespace: SdlSdl.LanguagePlatformCoreTokenization
Assembly: Sdl.LanguagePlatform.Core.dll
Syntax
[DataContract]
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 |
---|---|---|
string | text | |
NumberToken | numericPart | |
Unit | unit | |
string | unitString | |
char | unitSeparator | |
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 |
---|---|---|
string | text | |
NumberToken | numericPart | |
Unit | unit | |
string | unitString | |
char | unitSeparator | |
string | customCategory | |
ICultureMetadataManager | cultureMetadataManager |
Properties
CustomCategory
Gets or sets the CustomCategory for this value, if available (see CustomUnitDefinition)
Declaration
[DataMember]
public string CustomCategory { get; set; }
Property Value
Type | Description |
---|---|
string |
IsPlaceable
IsPlaceable. Always true
for this class.
Declaration
public override bool IsPlaceable { get; }
Property Value
Type | Description |
---|---|
bool |
Overrides
IsSubstitutable
IsSubstitutable. Always true
for this class.
Declaration
public override bool IsSubstitutable { get; }
Property Value
Type | Description |
---|---|
bool |
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 |
---|---|
bool |
Unit
Gets or sets the unit.
Declaration
[DataMember]
public Unit Unit { get; set; }
Property Value
Type | Description |
---|---|
Unit |
UnitSeparator
Gets or sets the unit separator.
Declaration
[DataMember]
public char UnitSeparator { get; set; }
Property Value
Type | Description |
---|---|
char |
UnitString
Gets or sets the unit string, in case the unit is unknown.
Declaration
[DataMember]
public string UnitString { get; set; }
Property Value
Type | Description |
---|---|
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 |
---|---|---|
object | obj |
Returns
Type | Description |
---|---|
bool |
Overrides
GetHashCode()
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
int |
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 |
---|---|---|
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. |
ICultureMetadataManager | cultureMetadataManager |
Returns
Type | Description |
---|---|
Taskbool |
|
Overrides
LocalizeAsync(CultureInfo, AutoLocalizationSettings, ILocalizableToken, bool, 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 |
---|---|---|
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. |
bool | 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. |
ICultureMetadataManager | cultureMetadataManager |
Returns
Type | Description |
---|---|
Taskbool |
|
Overrides
SetValue(Token, bool)
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 |
bool | keepNumericSeparators | Applicable to numeric (number and measurement) tokens only: if true, do not override the original group and decimal separators. |
Returns
Type | Description |
---|---|
bool | A flag indicating whether the token's value or type were changed. |