-
Notifications
You must be signed in to change notification settings - Fork 1
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
6 changed files
with
1,080 additions
and
1,013 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System; | ||
using static Redskap.FormattingHelpers; | ||
|
||
namespace Redskap; | ||
|
||
public readonly partial struct BankAccountNumber | ||
{ | ||
/// <inheritdoc /> | ||
public override string ToString() | ||
{ | ||
const int length = Length + 2; | ||
|
||
#if NETSTANDARD | ||
var buffer = new char[length]; | ||
|
||
Format(this, buffer); | ||
|
||
return new string(buffer); | ||
#else | ||
return string.Create(length, this, (span, number) => | ||
{ | ||
Format(number, span); | ||
}); | ||
#endif | ||
} | ||
|
||
private static void Format(BankAccountNumber number, Span<char> buffer) | ||
{ | ||
WriteDigit((uint) number.CheckDigit, buffer, 12); | ||
WriteFourDecimalDigits((uint) number.CustomerNumber, buffer, 8); | ||
buffer[7] = ' '; | ||
WriteTwoDecimalDigits((uint) number.AccountGroup, buffer, 5); | ||
buffer[4] = ' '; | ||
WriteFourDecimalDigits((uint) number.RegisterNumber, buffer, 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
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
Oops, something went wrong.