Table of Contents

Struct Currency

Inherited Members
Namespace
TabularEditor.PropertyGridUI.Converters
Assembly
TOMWrapper.dll

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.

public readonly struct Currency

Constructors

Currency(string, string, SymbolPosition)

Create a new Currency

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

Currency(string, CurrencySymbolPosition, bool)

Create a currency from TomExplorerPreferences settings

public Currency(string symbol, CurrencySymbolPosition symbolPosition, bool space)

Parameters

Type Name Description
string symbol

A string with a currency symbol

CurrencySymbolPosition symbolPosition

A flag indicating the symbol comes "after" the number rather than "before" 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

Properties

Label

Friendly label for currency (for UI display), e.g. "US Dollar"

public string Label { get; init; }

Property Value

Type Description
string

Position

Position and spacing information for the currency symbol

public Currency.SymbolPosition Position { get; init; }

Property Value

Type Description
Currency.SymbolPosition

Symbol

Symbol of the currency only (no spaces or anything else)

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

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

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

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

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