Struct Currency
Provide a structured way to talk about currencies, capturing the symbol, a friendly name, and positioning of the symbol, for use in integrating with existing number formating schemes.
Inherited Members
Namespace: TabularEditor.PropertyGridUI
Assembly: TOMWrapper.dll
Syntax
public readonly struct Currency
Constructors
Currency(string, string, bool)
Create a currency from TomExplorerPreferences settings
Declaration
public Currency(string symbol, string position, bool space)
Parameters
Type | Name | Description |
---|---|---|
string | symbol | A string with a currency symbol |
string | position | A string indicating the symbol comes "before" or "after" the number |
bool | space | Whether to include a space between the number and the symbol |
Remarks
Position is determined with a string match and falls through to coming before the number
Currency(string, string, SymbolPosition)
Create a new Currency
Declaration
public Currency(string label, string symbol, Currency.SymbolPosition position)
Parameters
Type | Name | Description |
---|---|---|
string | label | Friendly label (for UI display), e.g. "US Dollar" |
string | symbol | The currency symbol only (no spaces) |
Currency.SymbolPosition | position | Enum capturing position before or after the number and whether there is a space |
Properties
Label
Friendly label for currency (for UI display), e.g. "US Dollar"
Declaration
public string Label { get; init; }
Property Value
Type | Description |
---|---|
string |
Position
Position and spacing information for the currency symbol
Declaration
public Currency.SymbolPosition Position { get; init; }
Property Value
Type | Description |
---|---|
Currency.SymbolPosition |
Symbol
Symbol of the currency only (no spaces or anything else)
Declaration
public string Symbol { get; init; }
Property Value
Type | Description |
---|---|
string |
Methods
AddToFormat(string)
Put the currency symbol in the correct place relative to an existing number format string
Declaration
public string AddToFormat(string numberFormat)
Parameters
Type | Name | Description |
---|---|---|
string | numberFormat | A number format string that already handles thousands and decimals |
Returns
Type | Description |
---|---|
string | numberFormat with a currency symbol before or after it. |
InFormatString(string)
Test if the format string snippet of the currency is in the format string
Declaration
public bool InFormatString(string format)
Parameters
Type | Name | Description |
---|---|---|
string | format | A format string that may hold the currency snippet |
Returns
Type | Description |
---|---|
bool |
PositionFromPositivePattern(int)
Map CurrencyPositivePattern values to our enum for positions
Declaration
public static Currency.SymbolPosition PositionFromPositivePattern(int numberFormatInfo)
Parameters
Type | Name | Description |
---|---|---|
int | numberFormatInfo | int 1-4 (inclusive) |
Returns
Type | Description |
---|---|
Currency.SymbolPosition |
Remarks
StripFromFormat(string)
Remove the currency format from the string, if it is there
Declaration
public string StripFromFormat(string currencyFormat)
Parameters
Type | Name | Description |
---|---|---|
string | currencyFormat | a format string that may contain the symbol snippet |
Returns
Type | Description |
---|---|
string | a format string that definitely does not contain the symbol snippet |