-
Notifications
You must be signed in to change notification settings - Fork 0
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
7 changed files
with
227 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.BankAccount")] | ||
[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")] |
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,6 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" /> | ||
</startup> | ||
</configuration> |
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,58 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{1A4ACA5A-7461-4A21-AC51-E3F784E3CC38}</ProjectGuid> | ||
<OutputType>Exe</OutputType> | ||
<RootNamespace>MagyarNemzetiBank</RootNamespace> | ||
<AssemblyName>MagyarNemzetiBank.BankAccountExample</AssemblyName> | ||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Net.Http" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Program.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="App.config" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\BankAccount\BankAccount.csproj"> | ||
<Project>{F868E5A1-F07A-4A11-A399-065DA1E192A8}</Project> | ||
<Name>BankAccount</Name> | ||
</ProjectReference> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
</Project> |
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,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(); | ||
} | ||
} | ||
} |
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,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")] |
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,48 @@ | ||
# 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. | ||
|
||
## Download from Nuget | ||
[!['nuget badge'](https://img.shields.io/nuget/v/MagyarNemzetiBank.BankAccount.svg)](https://www.nuget.org/packages/MagyarNemzetiBank.BankAccount/) |