扩展/修改 OpenIso8583.Net
我正在使用出色的 OpenIso8583Net 来发送/接收 ISO 消息。但是,由于每个组织都有自己的定义和自定义,因此我希望能够在尽可能少地接触项目源的情况下自定义格式,以便能够更轻松地升级到新版本。
因此,这是我现在面临的三个自定义:
- 如何使
Bitmap
使用AsciiFormatter
而不是BinaryFormatter
?由于位图是AMessage
类的私有字段,即使我直接从AMessage
派生一个新的自定义类,我也无法访问它。构造函数默认使用BinaryFormatter
。目前,我已修改 Bitmap.cs 无参数构造函数以使用AsciiFormatter
。 - 同样的情况也适用于可变长度格式化程序。它默认使用
AsciiFormatter
。但我希望它使用BcdFormatter
。我已修改此部分以在 VariableLengthFormatter 中默认使用BcdFormatter
。
如果有人向我展示一种通过扩展而不是修改来处理这些自定义的更好方法,我将不胜感激。 - 假设我想显示日志文件中的字段。一个例子是我在
Fields
部分中的通过加密数据生成 MAC 中显示的内容。现在,我必须将Template
属性公开并使用以下代码片段: for (var i = 2; i
如何在不公开 Template
的情况下访问字段?我想访问主程序中字段的 Display
方法以进行日志记录。
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
Bitmap
to useAsciiFormatter
instead ofBinaryFormatter
? since bitmap is a private field ofAMessage
class, I cannot access it even if I directly derive a new custom class fromAMessage
. And the constructor usesBinaryFormatter
by default. Currently, I have modified Bitmap.cs parameterless constructor to useAsciiFormatter
. - Same story goes for variable length formatter. It uses
AsciiFormatter
by default. But I'd like it to useBcdFormatter
. I have Modified this part to useBcdFormatter
by 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
Fields
section. Right now, I have to makeTemplate
property 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我刚刚对项目进行了更改以允许这样做。从版本 0.5.0 开始(更新您的 NuGet 包)
位图格式化程序
您可以在消息类的模板中设置位图格式化程序。以下是一些示例代码:
设置字段的长度格式化程序
在
static AsciiIso()
方法中,如果以这种方式修改,您将更改字段 2 以使用 BCD 长度格式化程序:日志文件
到在日志文件中显示消息,使用消息类上的
.ToString()
方法,例如给出:
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: