-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
1,073 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,182 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 42, | ||
"metadata": { | ||
"dotnet_interactive": { | ||
"language": "csharp" | ||
}, | ||
"polyglot_notebook": { | ||
"kernelName": "csharp" | ||
}, | ||
"vscode": { | ||
"languageId": "polyglot-notebook" | ||
} | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"#r \"../src/NMoneys/bin/Debug/net6.0/NMoneys.dll\"\n", | ||
"\n", | ||
"using NMoneys;\n", | ||
"using NMoneys.Support;\n", | ||
"using System.Numerics;\n", | ||
"using System.Reflection;\n", | ||
"using System.Globalization;\n", | ||
"\n", | ||
"record Diff(string Name, string FromCurrency, string FromGlobalization)\n", | ||
"{\n", | ||
"\tprivate static string str<T>(T i) where T : IBinaryInteger<T> \n", | ||
"\t{\n", | ||
"\t\treturn i.ToString(\"D\", CultureInfo.InvariantCulture);\n", | ||
"\t}\n", | ||
"\tprivate static string str<T>(T[] i) where T : IBinaryInteger<T> \n", | ||
"\t{\n", | ||
"\t\treturn string.Join('|', i);\n", | ||
"\t}\n", | ||
"\n", | ||
"\tpublic static Diff[] Build(Currency currency)\n", | ||
"\t{\n", | ||
"\t\tCanonicalCultureAttribute attr = currency.GetCanonicalCulture();\n", | ||
"\t\tif (attr is null) return Array.Empty<Diff>();\n", | ||
"\n", | ||
"\t\tCultureInfo ci = attr.Culture();\n", | ||
"\t\tNumberFormatInfo nfi = ci.NumberFormat;\n", | ||
"\t\tvar ri = new RegionInfo(ci.Name);\n", | ||
"\t\tStringComparer ordinal = StringComparer.Ordinal;\n", | ||
"\t\tStringComparer native = StringComparer.Create(ci, false);\n", | ||
"\n", | ||
"\t\tList<Diff> diffs = new List<Diff>(10);\n", | ||
"\t\tif (currency.IsoCode != Currency.Code.Parse(ri.ISOCurrencySymbol))\n", | ||
"\t\t{\n", | ||
"\t\t\tdiffs.Add(new Diff(\"ri.ISOCurrencySymbol\", currency.AlphabeticCode, ri.ISOCurrencySymbol));\n", | ||
"\t\t}\n", | ||
"\t\tif (!ordinal.Equals(currency.EnglishName, ri.CurrencyEnglishName))\n", | ||
"\t\t{\n", | ||
"\t\t\tdiffs.Add(new Diff(\"ri.CurrencyEnglishName\", currency.EnglishName, ri.CurrencyEnglishName));\n", | ||
"\t\t}\n", | ||
"\t\tif (!native.Equals(currency.NativeName, ri.CurrencyNativeName))\n", | ||
"\t\t{\n", | ||
"\t\t\tdiffs.Add(new Diff(\"ri.CurrencyNativeName\", currency.NativeName, ri.CurrencyNativeName));\n", | ||
"\t\t}\n", | ||
"\t\tif (!native.Equals(currency.Symbol, ri.CurrencySymbol))\n", | ||
"\t\t{\n", | ||
"\t\t\tdiffs.Add(new Diff(\"ri.CurrencySymbol\", currency.Symbol, ri.CurrencySymbol));\n", | ||
"\t\t}\n", | ||
"\t\tif (currency.SignificantDecimalDigits != nfi.CurrencyDecimalDigits)\n", | ||
"\t\t{\n", | ||
"\t\t\tdiffs.Add(new Diff(\"nfi.CurrencyDecimalDigits\", str(currency.SignificantDecimalDigits), str(nfi.CurrencyDecimalDigits)));\n", | ||
"\t\t}\n", | ||
"\t\tif (!ordinal.Equals(currency.DecimalSeparator, nfi.CurrencyDecimalSeparator))\n", | ||
"\t\t{\n", | ||
"\t\t\tdiffs.Add(new Diff(\"nfi.CurrencyDecimalSeparator\", currency.DecimalSeparator, nfi.CurrencyDecimalSeparator));\n", | ||
"\t\t}\n", | ||
"\t\tif (!ordinal.Equals(currency.GroupSeparator, nfi.CurrencyGroupSeparator))\n", | ||
"\t\t{\n", | ||
"\t\t\tdiffs.Add(new Diff(\"nfi.CurrencyGroupSeparator\", currency.GroupSeparator, nfi.CurrencyGroupSeparator));\n", | ||
"\t\t}\n", | ||
"\t\tif (!currency.GroupSizes.SequenceEqual(nfi.CurrencyGroupSizes.Select(s => (byte)s)))\n", | ||
"\t\t{\n", | ||
"\t\t\tdiffs.Add(new Diff(\"nfi.CurrencyGroupSizes\", str(currency.GroupSizes), str(nfi.CurrencyGroupSizes)));\n", | ||
"\t\t}\n", | ||
"\t\tif (currency.PositivePattern != nfi.CurrencyPositivePattern)\n", | ||
"\t\t{\n", | ||
"\t\t\tdiffs.Add(new Diff(\"nfi.CurrencyPositivePattern\", str(currency.PositivePattern), str(nfi.CurrencyPositivePattern)));\n", | ||
"\t\t}\n", | ||
"\t\tif (currency.NegativePattern != nfi.CurrencyNegativePattern)\n", | ||
"\t\t{\n", | ||
"\t\t\tdiffs.Add(new Diff(\"nfi.CurrencyNegativePattern\", str(currency.NegativePattern), str(nfi.CurrencyNegativePattern)));\n", | ||
"\t\t}\n", | ||
"\n", | ||
"\t\treturn diffs.ToArray();\n", | ||
"\t}\n", | ||
"};" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 43, | ||
"metadata": { | ||
"dotnet_interactive": { | ||
"language": "csharp" | ||
}, | ||
"polyglot_notebook": { | ||
"kernelName": "csharp" | ||
}, | ||
"vscode": { | ||
"languageId": "polyglot-notebook" | ||
} | ||
}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/html": [ | ||
"<div class=\"dni-plaintext\"><pre>[ 4, 4, 3, 5, 4, 3, 2, 1, 1, 5, 3, 1, 1, 5, 3, 1, 2, 2, 2, 4 ... (more) ]</pre></div><style>\r\n", | ||
".dni-code-hint {\r\n", | ||
" font-style: italic;\r\n", | ||
" overflow: hidden;\r\n", | ||
" white-space: nowrap;\r\n", | ||
"}\r\n", | ||
".dni-treeview {\r\n", | ||
" white-space: nowrap;\r\n", | ||
"}\r\n", | ||
".dni-treeview td {\r\n", | ||
" vertical-align: top;\r\n", | ||
" text-align: start;\r\n", | ||
"}\r\n", | ||
"details.dni-treeview {\r\n", | ||
" padding-left: 1em;\r\n", | ||
"}\r\n", | ||
"table td {\r\n", | ||
" text-align: start;\r\n", | ||
"}\r\n", | ||
"table tr { \r\n", | ||
" vertical-align: top; \r\n", | ||
" margin: 0em 0px;\r\n", | ||
"}\r\n", | ||
"table tr td pre \r\n", | ||
"{ \r\n", | ||
" vertical-align: top !important; \r\n", | ||
" margin: 0em 0px !important;\r\n", | ||
"} \r\n", | ||
"table th {\r\n", | ||
" text-align: start;\r\n", | ||
"}\r\n", | ||
"</style>" | ||
] | ||
}, | ||
"metadata": {}, | ||
"output_type": "display_data" | ||
} | ||
], | ||
"source": [ | ||
"Currency.FindAll()\n", | ||
"\t.Select(c => new { Currency = c, Diffs = Diff.Build(c) })\n", | ||
"\t.Where(a => a.Diffs.Length > 0)\n" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": ".NET (C#)", | ||
"language": "C#", | ||
"name": ".net-csharp" | ||
}, | ||
"language_info": { | ||
"name": "csharp" | ||
}, | ||
"polyglot_notebook": { | ||
"kernelInfo": { | ||
"defaultKernelName": "csharp", | ||
"items": [ | ||
{ | ||
"aliases": [], | ||
"name": "csharp" | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
Oops, something went wrong.