PeanutButter
Loading...
Searching...
No Matches
PeanutButter.Utils.DecimalDecorator Class Reference

Provides a relatively "safe" interchange between decimal and string notations for numbers, inspecting the input string to try to make the best decision based on the contents of the string instead of just relying on the current thread culture (which causes issues when communicating between machines with different ideas of what constitutes "correct" decimal notation a prime example being transport of decimals from Javascript into a ZA .net culture – but there are others) More...

Public Member Functions

 DecimalDecorator (decimal value, string format=null)
 Constructs a new DecimalDecorator with the provided decimal value an an optional string format.
 DecimalDecorator (string value)
 Constructs a new DecimalDecorator with the provided string value to parse as a decimal.
override string ToString ()
decimal ToDecimal ()
 Returns the decimal version of the underlying data.

Static Public Member Functions

static decimal Parse (string value)
 Attempts to do a direct parse on a string value.

Properties

bool IsValidDecimal [get]
 Flag: is the underlying value a valid decimal value.

Detailed Description

Provides a relatively "safe" interchange between decimal and string notations for numbers, inspecting the input string to try to make the best decision based on the contents of the string instead of just relying on the current thread culture (which causes issues when communicating between machines with different ideas of what constitutes "correct" decimal notation a prime example being transport of decimals from Javascript into a ZA .net culture – but there are others)

Constructor & Destructor Documentation

◆ DecimalDecorator() [1/2]

PeanutButter.Utils.DecimalDecorator.DecimalDecorator ( decimal value,
string format = null )

Constructs a new DecimalDecorator with the provided decimal value an an optional string format.

Parameters
valueDecimal value to decorate
formatOptional string format to use

◆ DecimalDecorator() [2/2]

PeanutButter.Utils.DecimalDecorator.DecimalDecorator ( string value)

Constructs a new DecimalDecorator with the provided string value to parse as a decimal.

Parameters
valueString value to parse as Decimal

Member Function Documentation

◆ Parse()

decimal PeanutButter.Utils.DecimalDecorator.Parse ( string value)
static

Attempts to do a direct parse on a string value.

  • will break if the input value is clearly not a decimal, eg "aaa"
Parameters
value
Returns

◆ ToDecimal()

decimal PeanutButter.Utils.DecimalDecorator.ToDecimal ( )

Returns the decimal version of the underlying data.

Returns
The decimal version of the underlying data

The documentation for this class was generated from the following file:
  • source/Utils/PeanutButter.Utils/DecimalDecorator.cs