I’m using the excellent OpenIso8583Net to send/receive ISO messages. However, since every organization has its own definition and customization, I want to be able to customoize the format with as little touch to the projects’ source as possible to be able to upgrade to new versions more easily.
So here are three customizations I am facing right now:
- How can I make
Bitmapto useAsciiFormatterinstead ofBinaryFormatter? since bitmap is a private field ofAMessageclass, I cannot access it even if I directly derive a new custom class fromAMessage. And the constructor usesBinaryFormatterby default. Currently, I have modified Bitmap.cs parameterless constructor to useAsciiFormatter. - Same story goes for variable length formatter. It uses
AsciiFormatterby default. But I’d like it to useBcdFormatter. I have Modified this part to useBcdFormatterby default in VariableLengthFormatter.
I’d appreciate if anyone shows me a better way to handle these customizations by extending, not modifying. - Suppose I want to display fields in a log file. An example would be what I have displayed at Generating MAC by encrypting data in the
Fieldssection. Right now, I have to makeTemplateproperty public and use the following snippet:for (var i = 2; i
How can I access the fields without making the Template public? I want to access the Display method of fields in my main program for logging purposes.
I have just made changes to the project to allow this. As of version 0.5.0 (Update your NuGet package)
Bitmap Formatter
You can set the bitmap formatter in the Template for your message class. Here is some sample code:
Set Length Formatter of a field
In the
static AsciiIso()method, if you modify in this manner, you’ll change field 2 to use a BCD length formatter:Log File
To display the message in the log file, use the
.ToString()method on the message class, e.g.Which gives: