GithubHelp home page GithubHelp logo

wj.datatypes's People

Contributors

webjose avatar

Watchers

 avatar

wj.datatypes's Issues

Money Struct Design


Developer: webJose ([email protected])
Development Start Date: 2018-06-25
Development End Date: 2018-07-04


Money Struct

Binds a decimal value with a string value to fully describe a monetary value.

Interface Implementations

  • IEquatable
  • IComparable
  • IFormattable
  • IConvertible

Format Strings

  • G or C: General. General currency format that uses the thread's current culture (or the provided IFormatProvider object) except for the currency symbol. Admits precision values.
  • I: ISO. Displays the quantity followed by the 3-letter ISO currency code, using the thred's current culture (or the provided IFormatProvider object). Admits precision values.
  • GO or CO: General Original. Displays the monetary value using the culture for the currency as opposed to either the thread's current culture or the provided IFormatProvider object.
  • IO: ISO Original. The same as ISO but using the culture for the currency as opposed to either the thread's current culture or the provided IFormatProvider object.

Operators

  • ==: Both operands must be of the same currency or the comparison fails, unless the amount is zero, in which case currency is unimportant.
  • !=: Defined as the opposite of ==.
  • >: Both operands must be of the same currency.
  • <: Both operands must be of the same currency.
  • >=: Both operands must be of the same currency.
  • <=: Both operands must be of the same currency.
  • decimal: Implicit conversion operator.
  • Money: Implicit conversion operator from decimal and current culture's currency.
  • +: Both operands must be of the same currency.
  • -: Both operands must be of the same currency.
  • x: One operand of type Money, and the other of type double, decimal, int, uint, float, long or ulong.
  • /: Numerator is Money and denominator is of type double, decimal, int, uint, float, long, ulong or Money. Return type is Money unless the denominator is also Money, in which case the result is of type double.

CultureInfo and RegionInfo

For each CultureInfo there are 0 or 1 RegionInfo objects. The latter defines the 3-letter ISO currency code. There is a one-to-many relationship between the ISO currency code and cultures. The culture has the information to format the currency, so the consumer of the class will be given an opportunity to select it from the different possibilities. The consumer will be informed of the pre-selection, which is the current culture if possible.

Automatic Culture Selection

The first choice would be the current culture if it is part of the possible selections for the specified currency. If not a possibility, then the first region-specific culture is selected. If there are no region-specific cultures, then the first available culture is selected.

A static event will allow consumers to override the selection.

No Currency Specification

Constructors that do not take a culture or a currency code default to the currency for the current culture. If so happens that the current culture does not have an associated RegionInfo object, then the constructor cannot be used and another that takes a culture or a currency code must be used.

RowVersion Testing


Developer: webJose
Development Start Date: 2018-06-20
Development End Date: 2018-06-23


Testing of Feature / Pruebas de Funcionalidad

Add any general description, if applicable. / Agregue cualquier descripción general, si aplica.

Unit Tests / Pruebas Unitarias

Class / Clase Coverage (%) Comments
RowVersion 56.28% No testing for IConvertible.

*Ideal minimum coverage: 80%

Money Struct Tests


Developer: webJose
Development Start Date: (start date in ISO8601)
Development End Date: (end date in ISO8601)


Money Struct Unit Testing

Unit Tests / Pruebas Unitarias

Class / Clase Coverage (%) Comments
Money

*Ideal minimum coverage: 80%

Feature Request: Memory struct to represent memory quantities

Describe the solution you'd like / Describa la solución que le gustaría

Create a Memory struct whose value is always stored in bytes in a long field member and whose ToString() can represent the value in various formats. For example, the value 1024 (bytes) could be shown as 1 KB, 1 KiB or 1024 B.

Ideally, it would also have a type converter for use of the value in PropertyGrid.

Add Parse and TryParse to Money

Describe the solution you'd like / Describa la solución que le gustaría
Money.Parse() and Money.TryParse() should work basically the same as Decimal.Parse() and Decimal.TryParse().

It should be able to parse any and all ToString() outputs for all string formats defined, namely G, I, GO and IO with any number of decimals (precision).

Examples:

The following were generated using es-CR as the thread's current culture.

Description G Format I Format GO Format IO Format Value
Korean Won -₩16 161,00 -16 161,00 KRW -₩16,161 16,161 KRW Sixteen thousand one hundred sixty one wons
US Dollar -$77 991,00 -77 991,00 USD ($77,991.00) (77,991.00) USD Seventy seven thousand nine hundred ninety one US dollars

Additional context / Contexto adicional
Since Money is a union of a string and a decimal value, the heavy work can be delegated to the Decimal.Parse() and Decimal.TryParse() "standard" methods.

RowVersion Development


Developer: webJose
Development Start Date: 2018-06-20
Development End Date: 2018-06-20


RowVersion

Interface Implementations

  • IEquatable
  • IComparable
  • IFormattable
  • IConvertible

Format Strings

  • G or g: General. Default format. Same as how SSMS shows binary data: 0x<HEX values, little endian>.
  • S or s: Same as G.
  • O or o: Oracle representation. The value is converted to a ulong and represented as such.
  • M or m: MySql representation. The value is a date and time value represented in ISO 8601.
  • H or h: Hex Viewer-like string (hex values separated by one space).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.