From 719251cc14e996b628a44e9c5a57f7917e76717e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20Keresztury?= Date: Sat, 25 May 2019 18:31:14 +0200 Subject: [PATCH 1/6] Added AssemblyInfo.cs --- BankAccount/Properties/AssemblyInfo.cs | 33 ++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 BankAccount/Properties/AssemblyInfo.cs diff --git a/BankAccount/Properties/AssemblyInfo.cs b/BankAccount/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..347a312 --- /dev/null +++ b/BankAccount/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("MagyarNemzetiBank.Properties")] +[assembly: AssemblyDescription("This library written in pure C# checks the validity of Hungarian bank account numbers and determines which bank they belong to.")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Balázs Keresztury")] +[assembly: AssemblyProduct("MagyarNemzetiBank.Properties")] +[assembly: AssemblyCopyright("Copyright (c) 2019 Balázs Keresztury")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("46844df6-193c-425b-b616-7e659dee4fb0")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] From bb8ce0191cbee69ffc4e6d27720c1fa60a2f3eed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20Keresztury?= Date: Sat, 25 May 2019 20:40:42 +0200 Subject: [PATCH 2/6] Added examples --- BankAccountExample/App.config | 6 ++ BankAccountExample/BankAccountExample.csproj | 58 +++++++++++++++++++ BankAccountExample/Program.cs | 44 ++++++++++++++ BankAccountExample/Properties/AssemblyInfo.cs | 36 ++++++++++++ MagyarNemzetiBank.BankAccount.sln | 6 ++ 5 files changed, 150 insertions(+) create mode 100644 BankAccountExample/App.config create mode 100644 BankAccountExample/BankAccountExample.csproj create mode 100644 BankAccountExample/Program.cs create mode 100644 BankAccountExample/Properties/AssemblyInfo.cs diff --git a/BankAccountExample/App.config b/BankAccountExample/App.config new file mode 100644 index 0000000..7eb8d24 --- /dev/null +++ b/BankAccountExample/App.config @@ -0,0 +1,6 @@ + + + + + + diff --git a/BankAccountExample/BankAccountExample.csproj b/BankAccountExample/BankAccountExample.csproj new file mode 100644 index 0000000..4c4b647 --- /dev/null +++ b/BankAccountExample/BankAccountExample.csproj @@ -0,0 +1,58 @@ + + + + + Debug + AnyCPU + {1A4ACA5A-7461-4A21-AC51-E3F784E3CC38} + Exe + MagyarNemzetiBank + MagyarNemzetiBank.BankAccountExample + v4.6.1 + 512 + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + {F868E5A1-F07A-4A11-A399-065DA1E192A8} + BankAccount + + + + \ No newline at end of file diff --git a/BankAccountExample/Program.cs b/BankAccountExample/Program.cs new file mode 100644 index 0000000..e019dc8 --- /dev/null +++ b/BankAccountExample/Program.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using MagyarNemzetiBank; + +namespace MagyarNemzetiBank.BankAccountExample +{ + class Program + { + static void Main(string[] args) + { + string validAccountNumber = "10032000-01076349"; + var accountValid = new BankAccount(validAccountNumber); + System.Console.WriteLine($"{accountValid.AccountNumber}: IsValid = {accountValid.IsValid}, Bank = {accountValid.Bank}"); + + var accountInvalidNumber = new BankAccount("00000000-00000000-00000001"); + System.Console.WriteLine($"{accountInvalidNumber.AccountNumber}: IsValid = {accountInvalidNumber.IsValid}"); + try + { + System.Console.WriteLine($"Checking bank details for {accountInvalidNumber.AccountNumber}"); + System.Console.WriteLine(accountInvalidNumber.Bank); + } + catch (FormatException) + { + System.Console.WriteLine($"{typeof(FormatException)} was thrown because account number was not valid"); + } + + var accountInvalidBank = new BankAccount("00000000-00000000"); + System.Console.WriteLine($"{accountInvalidBank.AccountNumber}: IsValid = {accountInvalidBank.IsValid} (it's technically valid)"); + try + { + System.Console.WriteLine($"Checking bank details for {accountInvalidBank.AccountNumber}"); + System.Console.WriteLine(accountInvalidBank.Bank); + } + catch (KeyNotFoundException) + { + System.Console.WriteLine($"{typeof(KeyNotFoundException)} was thrown, because the bank account number doesn't belong to any known bank."); + } + System.Console.ReadKey(); + } + } +} diff --git a/BankAccountExample/Properties/AssemblyInfo.cs b/BankAccountExample/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..ea90229 --- /dev/null +++ b/BankAccountExample/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("ConsoleApp1")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("ConsoleApp1")] +[assembly: AssemblyCopyright("Copyright © 2019")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("1a4aca5a-7461-4a21-ac51-e3f784e3cc38")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/MagyarNemzetiBank.BankAccount.sln b/MagyarNemzetiBank.BankAccount.sln index 2e2d3a5..01d4fef 100644 --- a/MagyarNemzetiBank.BankAccount.sln +++ b/MagyarNemzetiBank.BankAccount.sln @@ -7,6 +7,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BankAccount", "BankAccount\ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BankAccountTests", "BankAccountTests\BankAccountTests.csproj", "{8EDF4429-251A-416D-BB68-93F227191BCF}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BankAccountExample", "ConsoleApp1\BankAccountExample.csproj", "{1A4ACA5A-7461-4A21-AC51-E3F784E3CC38}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -21,6 +23,10 @@ Global {8EDF4429-251A-416D-BB68-93F227191BCF}.Debug|Any CPU.Build.0 = Debug|Any CPU {8EDF4429-251A-416D-BB68-93F227191BCF}.Release|Any CPU.ActiveCfg = Release|Any CPU {8EDF4429-251A-416D-BB68-93F227191BCF}.Release|Any CPU.Build.0 = Release|Any CPU + {1A4ACA5A-7461-4A21-AC51-E3F784E3CC38}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1A4ACA5A-7461-4A21-AC51-E3F784E3CC38}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1A4ACA5A-7461-4A21-AC51-E3F784E3CC38}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1A4ACA5A-7461-4A21-AC51-E3F784E3CC38}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE From 5a7fa1aebc10e6d0f31e19b515595cdde0b507d9 Mon Sep 17 00:00:00 2001 From: Balazs Keresztury Date: Sat, 25 May 2019 20:47:44 +0200 Subject: [PATCH 3/6] Created README --- README.md | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..f6b536a --- /dev/null +++ b/README.md @@ -0,0 +1,47 @@ +# MagyarNemzetiBank.BankAccount +This library written in pure C# checks the validity of a Hungarian bank account number and determines which bank is belongs to. + +## Usage +Let's check a valid bank account: + +```csharp +string validAccountNumber = "10032000-01076349"; +var accountValid = new BankAccount(validAccountNumber); +System.Console.WriteLine($"{accountValid.AccountNumber}: IsValid = {accountValid.IsValid}, Bank = {accountValid.Bank}"); +``` + +An invalid bank account will return `IsValid = false` and throws `FormatException` when `Bank` property is read: + +```csharp +var accountInvalidNumber = new BankAccount("00000000-00000000-00000001"); +System.Console.WriteLine($"{accountInvalidNumber.AccountNumber}: IsValid = {accountInvalidNumber.IsValid}"); +try +{ + System.Console.WriteLine($"Checking bank details for {accountInvalidNumber.AccountNumber}"); + System.Console.WriteLine(accountInvalidNumber.Bank); +} +catch (FormatException) +{ + System.Console.WriteLine($"{typeof(FormatException)} was thrown because account number was not valid"); +} +``` + +When the syntax of the bank account number is correct, but it doesn't belong to any known bank `KeyNotFoundException` is thrown: + +```csharp +var accountInvalidBank = new BankAccount("00000000-00000000"); +System.Console.WriteLine($"{accountInvalidBank.AccountNumber}: IsValid = {accountInvalidBank.IsValid} (it's technically valid)"); +try +{ + System.Console.WriteLine($"Checking bank details for {accountInvalidBank.AccountNumber}"); + System.Console.WriteLine(accountInvalidBank.Bank); +} +catch (KeyNotFoundException) +{ + System.Console.WriteLine($"{typeof(KeyNotFoundException)} was thrown, because the bank account number doesn't belong to any known bank."); +} +``` + +Alternatively you can use the static `BankAccount.Validate(string accountNumber)` method to check if the number is syntactically correct. + + From 553dc9e3fcbadecb46e5d5ec762d52e1ab3786bd Mon Sep 17 00:00:00 2001 From: Balazs Keresztury Date: Sat, 25 May 2019 20:56:17 +0200 Subject: [PATCH 4/6] Added link to Nuget --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f6b536a..7d0c5b4 100644 --- a/README.md +++ b/README.md @@ -44,4 +44,5 @@ catch (KeyNotFoundException) Alternatively you can use the static `BankAccount.Validate(string accountNumber)` method to check if the number is syntactically correct. - +## Download from Nuget +[!['nuget badge'](https://img.shields.io/nuget/v/MagyarNemzetiBank.BankAccount.svg)](https://www.nuget.org/packages/MagyarNemzetiBank.BankAccount/) From 62feeadba6cfc71be0a65db090b24cf8f99022ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20Keresztury?= Date: Sat, 25 May 2019 21:03:11 +0200 Subject: [PATCH 5/6] Fixed AssemblyProduct and VS solution --- BankAccount/Properties/AssemblyInfo.cs | 2 +- MagyarNemzetiBank.BankAccount.sln | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/BankAccount/Properties/AssemblyInfo.cs b/BankAccount/Properties/AssemblyInfo.cs index 347a312..11f83c9 100644 --- a/BankAccount/Properties/AssemblyInfo.cs +++ b/BankAccount/Properties/AssemblyInfo.cs @@ -9,7 +9,7 @@ [assembly: AssemblyDescription("This library written in pure C# checks the validity of Hungarian bank account numbers and determines which bank they belong to.")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Balázs Keresztury")] -[assembly: AssemblyProduct("MagyarNemzetiBank.Properties")] +[assembly: AssemblyProduct("MagyarNemzetiBank.BankAccount")] [assembly: AssemblyCopyright("Copyright (c) 2019 Balázs Keresztury")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/MagyarNemzetiBank.BankAccount.sln b/MagyarNemzetiBank.BankAccount.sln index 01d4fef..2e2d3a5 100644 --- a/MagyarNemzetiBank.BankAccount.sln +++ b/MagyarNemzetiBank.BankAccount.sln @@ -7,8 +7,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BankAccount", "BankAccount\ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BankAccountTests", "BankAccountTests\BankAccountTests.csproj", "{8EDF4429-251A-416D-BB68-93F227191BCF}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BankAccountExample", "ConsoleApp1\BankAccountExample.csproj", "{1A4ACA5A-7461-4A21-AC51-E3F784E3CC38}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -23,10 +21,6 @@ Global {8EDF4429-251A-416D-BB68-93F227191BCF}.Debug|Any CPU.Build.0 = Debug|Any CPU {8EDF4429-251A-416D-BB68-93F227191BCF}.Release|Any CPU.ActiveCfg = Release|Any CPU {8EDF4429-251A-416D-BB68-93F227191BCF}.Release|Any CPU.Build.0 = Release|Any CPU - {1A4ACA5A-7461-4A21-AC51-E3F784E3CC38}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1A4ACA5A-7461-4A21-AC51-E3F784E3CC38}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1A4ACA5A-7461-4A21-AC51-E3F784E3CC38}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1A4ACA5A-7461-4A21-AC51-E3F784E3CC38}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE From eef3f06fb2dcc25b62596bf77132ff1b0d979ca6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20Keresztury?= Date: Sat, 25 May 2019 21:03:55 +0200 Subject: [PATCH 6/6] Bumped version --- BankAccount/BankAccount.nuspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BankAccount/BankAccount.nuspec b/BankAccount/BankAccount.nuspec index b13b1f3..1b78c74 100644 --- a/BankAccount/BankAccount.nuspec +++ b/BankAccount/BankAccount.nuspec @@ -2,7 +2,7 @@ $id$ - $version$-alpha0 + $version$-alpha1 $title$ $author$ belidzs @@ -10,7 +10,7 @@ https://github.com/belidzs/MagyarNemzetiBank.BankAccount false $description$ - First alpha release + Second alpha release $copyright$ mnb bank banking bank-account bankaccount giro central-bank hungarian