Class NumberToken
A Token which represents a numeric value.
Implements
Inherited Members
Namespace: Sdl.LanguagePlatform.Core.Tokenization
Assembly: Sdl.LanguagePlatform.Core.dll
Syntax
public class NumberToken : Token, ILocalizableTokenConstructors
NumberToken(NumberToken)
Initializes a new instance with the values of another instance, creating a deep copy.
Declaration
public NumberToken(NumberToken other)Parameters
| Type | Name | Description | 
|---|---|---|
| NumberToken | other | The instance to copy | 
NumberToken(String, NumericSeparator, NumericSeparator, Char, Char, Sign, String, String, String)
Initializes a new instance with the specified values.
Declaration
public NumberToken(string text, NumericSeparator groupSeparator, NumericSeparator decimalSeparator, char alternateGroupSeparator, char alternateDecimalSeparator, Sign sign, string rawSign, string rawDecimalDigits, string rawFractionalDigits)Parameters
| Type | Name | Description | 
|---|---|---|
| String | text | The text of the token, as it appeared in the input | 
| NumericSeparator | groupSeparator | The type of group separator used | 
| NumericSeparator | decimalSeparator | The type of decimal separator used | 
| Char | alternateGroupSeparator | The character of an alternative group separator, if used | 
| Char | alternateDecimalSeparator | The character of an alternative decimal separator, if used | 
| Sign | sign | The type of sign used | 
| String | rawSign | The "raw text" of the sign | 
| String | rawDecimalDigits | The "raw decimal digits", without separators, between 0-9 | 
| String | rawFractionalDigits | The "raw fractional digits", without separators, between 0-9 | 
NumberToken(String, String, String, String, NumberFormatInfo)
Initializes a new instance with the specified values.
Declaration
public NumberToken(string text, string sign, string decimalPart, string fractionalPart, NumberFormatInfo format)Parameters
| Type | Name | Description | 
|---|---|---|
| String | text | The token text | 
| String | sign | The sign of the numeric value | 
| String | decimalPart | The decimal part of the numeric value | 
| String | fractionalPart | The fractional part of the numeric value | 
| NumberFormatInfo | format | The number format of the token's culture, used to determine whether default or alternate separators were used | 
Properties
AlternateDecimalSeparator
Gets or sets an alternate decimal separator, which is a single char if an alternate separator is used, or the null character if no alternate separator is used.
Declaration
public char AlternateDecimalSeparator { get; set; }Property Value
| Type | Description | 
|---|---|
| Char | 
AlternateGroupSeparator
Gets or sets an alternate group separator, which is a single char if an alternate separator is used, or the null character if no alternate separator is used.
Declaration
public char AlternateGroupSeparator { get; set; }Property Value
| Type | Description | 
|---|---|
| Char | 
DecimalSeparator
Gets or sets the decimal separator
Declaration
public NumericSeparator DecimalSeparator { get; set; }Property Value
| Type | Description | 
|---|---|
| NumericSeparator | 
GroupSeparator
Gets or sets the group separator
Declaration
public NumericSeparator GroupSeparator { get; set; }Property Value
| Type | Description | 
|---|---|
| NumericSeparator | 
IsPlaceable
IsPlaceable. Always true for this class.
Declaration
public override bool IsPlaceable { get; }Property Value
| Type | Description | 
|---|---|
| Boolean | 
Overrides
IsSubstitutable
IsSubstitutable. Always true for this class.
Declaration
public override bool IsSubstitutable { get; }Property Value
| Type | Description | 
|---|---|
| Boolean | 
Overrides
RawDecimalDigits
Gets or sets the raw decimal digits, which are a sequence of digits without separators or signs.
Declaration
public string RawDecimalDigits { get; set; }Property Value
| Type | Description | 
|---|---|
| String | 
RawFractionalDigits
Gets or sets the raw fractional digits, which are a sequence of digits without separators or signs.
Declaration
public string RawFractionalDigits { get; set; }Property Value
| Type | Description | 
|---|---|
| String | 
RawSign
Gets or sets the "raw" sign, i.e. the textual representation of the sign
Declaration
public string RawSign { get; set; }Property Value
| Type | Description | 
|---|---|
| String | 
Sign
Gets or sets the sign.
Declaration
public Sign Sign { get; set; }Property Value
| Type | Description | 
|---|---|
| Sign | 
Value
Gets or sets the numeric value. Do not use the setter, it is for internal purposes only.
Declaration
public double Value { get; set; }Property Value
| Type | Description | 
|---|---|
| Double | 
ValueValid
Gets or sets the flag whether the numeric value is valid or not. Do not use the setter, it is for internal purposes only.
Declaration
public bool ValueValid { get; set; }Property Value
| Type | Description | 
|---|---|
| Boolean | 
Methods
AcceptSegmentElementVisitor(ISegmentElementVisitor)
Visitor pattern implementation. Calls VisitNumberToken(NumberToken).
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)
System.Object.Equals(object)
Declaration
public override bool Equals(object obj)Parameters
| Type | Name | Description | 
|---|---|---|
| Object | obj | The object to compare with the current object. | 
Returns
| Type | Description | 
|---|---|
| Boolean | true if the specified object is equal to the current object; otherwise, false. | 
Overrides
FormatNumber(CultureInfo)
Format the number according to the provided culture, applying overrides for separators as appropriate. This method uses a proprietary implementation for the formatting and does not use the default .Net formatting methods.
Declaration
public string FormatNumber(CultureInfo culture)Parameters
| Type | Name | Description | 
|---|---|---|
| CultureInfo | culture | 
Returns
| Type | Description | 
|---|---|
| String | 
FormatNumber(NumberFormatInfo)
Format the number according to the provided number format information, applying overrides for separators as appropriate. This method uses a proprietary implementation for the formatting and does not use the default .Net formatting methods.
Declaration
public string FormatNumber(NumberFormatInfo nfi)Parameters
| Type | Name | Description | 
|---|---|---|
| NumberFormatInfo | nfi | 
Returns
| Type | Description | 
|---|---|
| String | 
GetHashCode()
System.Object.GetHashCode(object)
Declaration
public override int GetHashCode()Returns
| Type | Description | 
|---|---|
| Int32 | 
Overrides
GetTokenType()
Declaration
protected override TokenType GetTokenType()Returns
| Type | Description | 
|---|---|
| TokenType | 
Overrides
Localize(CultureInfo, AutoLocalizationSettings)
Declaration
public bool Localize(CultureInfo culture, AutoLocalizationSettings autoLocalizationSettings)Parameters
| Type | Name | Description | 
|---|---|---|
| CultureInfo | culture | |
| AutoLocalizationSettings | autoLocalizationSettings | 
Returns
| Type | Description | 
|---|---|
| Boolean | 
Localize(CultureInfo, AutoLocalizationSettings, ILocalizableToken, Boolean)
Declaration
public bool Localize(CultureInfo culture, AutoLocalizationSettings autoLocalizationSettings, ILocalizableToken originalMemoryToken, bool adjustCasing)Parameters
| Type | Name | Description | 
|---|---|---|
| CultureInfo | culture | |
| AutoLocalizationSettings | autoLocalizationSettings | |
| ILocalizableToken | originalMemoryToken | |
| Boolean | adjustCasing | 
Returns
| Type | Description | 
|---|---|
| Boolean | 
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 virtual 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 | 
|---|---|
| Task<Boolean> | 
 | 
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 virtual 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. | 
| 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. | 
| ICultureMetadataManager | cultureMetadataManager | 
Returns
| Type | Description | 
|---|---|
| Task<Boolean> | 
 | 
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 virtual bool SetValue(Token blueprint, bool keepNumericSeparators)Parameters
| Type | Name | Description | 
|---|---|---|
| Token | blueprint | The token to take the value from | 
| Boolean | keepNumericSeparators | Applicable to numeric (number and measurement) tokens only: if true, do not override the original group and decimal separators. | 
Returns
| Type | Description | 
|---|---|
| Boolean | A flag indicating whether the token's value or type were changed. | 
SetValue(String, String, String, NumberFormatInfo)
Overwrites the current token values with the specified values.
Declaration
public virtual void SetValue(string sign, string decimalPart, string fractionalPart, NumberFormatInfo format)Parameters
| Type | Name | Description | 
|---|---|---|
| String | sign | The sign of the numeric value | 
| String | decimalPart | The decimal part of the numeric value | 
| String | fractionalPart | The fractional part of the numeric value | 
| NumberFormatInfo | format | The number format of the token's culture, used to determine whether default or alternate separators were used |