It is hard to believe the last release was on September. That only means one thing: I was about time!
There are quite a few changes in the release, so I will get straight to the point(s)
2.2 should be a happy release. Why? Well, besides the fact it is the first release in more than 6 months it is the first one that contains code contributed by someone else but me.
Thank you, Berryl, for the feature, let’s hope it’s useful to many.
The problem that we try to solve is a simple one: we have a certain amount of money and we want to allocate it amongst several recipients. If we are lucky (and so are the receivers) the amount can be distributed evenly and so every recipient will receive the same amount of money. But most of the time that is not the case and we since money cannot be subdivided forever (there are no coins for one thousandth of a euro, for instance) we need to find away to distribute the money as fair (or unfair) as possible.
How to allocate a monetary quantity? Invoke
.Allocate() on the quantity. How is the remainder distributed? An implementation of
IRemainderAllocator will decide. There a some ready to use implementations, accessible using the static factory
Random. The significant decimals of the currency of the monetary quantity are used to determine the minimal amount of money that can be allocated.
Of course, no one prevents passing a custom
IRemainderAllocator as long as the allocator distributes all the money.
ISO is as ISO does
NMoneys claims to implement the ISO4217 standard for the .NET platform. That was accurate to a certain extent. It is true all currencies defined in the standard were present. But not all the information they contained was as the standard defines, because the baseline of the information was not the standard, was the information contained in the .NET culture tables.
But from this version on, all currencies will have the name as defined in the standard list (except some Bond Market units that lost their prefix).
But most importantly, currencies will have as many significant decimal digits as the specification says.
As a result, a bunch of currencies have changed name and precision. For a complete list, head to the Changelog.
Get it while it’s hot
Oh, and if you like what you see. Spread the word, contribute or, simply, use it.