Class NumberToken
A Token which represents a numeric value.
Implements
Inherited Members
Namespace: SdlSdl.LanguagePlatformCoreTokenization
Assembly: Sdl.LanguagePlatform.Core.dll
Syntax
[DataContract]
[KnownType(typeof(MeasureToken))]
public class NumberToken : Token, ILocalizableToken
Constructors
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
[DataMember]
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
[DataMember]
public char AlternateGroupSeparator { get; set; }
Property Value
Type | Description |
---|---|
char |
DecimalSeparator
Gets or sets the decimal separator
Declaration
[DataMember]
public NumericSeparator DecimalSeparator { get; set; }
Property Value
Type | Description |
---|---|
NumericSeparator |
GroupSeparator
Gets or sets the group separator
Declaration
[DataMember]
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 |
---|---|
bool |
Overrides
IsSubstitutable
IsSubstitutable. Always true
for this class.
Declaration
public override bool IsSubstitutable { get; }
Property Value
Type | Description |
---|---|
bool |
Overrides
RawDecimalDigits
Gets or sets the raw decimal digits, which are a sequence of digits without separators or signs.
Declaration
[DataMember]
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
[DataMember]
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
[DataMember]
public string RawSign { get; set; }
Property Value
Type | Description |
---|---|
string |
Sign
Gets or sets the sign.
Declaration
[DataMember]
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
[DataMember]
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
[DataMember]
public bool ValueValid { get; set; }
Property Value
Type | Description |
---|---|
bool |
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)
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
object | obj | The object to compare with the current object. |
Returns
Type | Description |
---|---|
bool | 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()
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
int |
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 |
---|---|
bool |
Localize(CultureInfo, AutoLocalizationSettings, ILocalizableToken, bool)
Declaration
public bool Localize(CultureInfo culture, AutoLocalizationSettings autoLocalizationSettings, ILocalizableToken originalMemoryToken, bool adjustCasing)
Parameters
Type | Name | Description |
---|---|---|
CultureInfo | culture | |
AutoLocalizationSettings | autoLocalizationSettings | |
ILocalizableToken | originalMemoryToken | |
bool | adjustCasing |
Returns
Type | Description |
---|---|
bool |
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 |
---|---|
Taskbool |
|
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 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. |
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 |
|
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 virtual 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. |
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 |