图书馆几年前被移动了,我找到的 wiki 链接已经过时了。
我想将第 127 位添加到 Iso8583 类中。我正在使用下面的代码,但程序在从 ToMsg() 调用的 Pack() 方法中死掉了。我不知道在长度字段中输入什么值。该字段是最大长度为 5 的 LLLVAR,那么长度是 5、8 还是 999?所有三个值都会在 Pack() 中引发异常。
我需要添加什么才能使第 127 位工作?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using OpenIso8583Net;
using OpenIso8583Net.FieldValidator;
using OpenIso8583Net.Formatter;
using OpenIso8583Net.LengthFormatters;
namespace MyLink
{
public class MyIso8583 : Iso8583
{
public new class Bit : Iso8583.Bit
{
public const int _127_DISCOVER_VERSION = 127;
}
// First you need to customise the template
// The message
private static readonly Template template;
static MyIso8583()
{
// Get the default template for the Iso8583 class
template = GetDefaultIso8583Template();
// change template to add bit 127 LLLVAR(5)
template.Add(Bit._127_DISCOVER_VERSION, FieldDescriptor.AsciiVar(3, 5, FieldValidators.AlphaNumericSpecial));
}
// override the base class using the template
public MyIso8583() : base(template)
{
}
protected override IField CreateField(int field)
{
return base.CreateField(field);
}
}
}
编辑 3/24/20:我添加了对 Bit 和 CreateField 的覆盖。我希望新的位 127 的作用类似于长度为 5 的默认 LLLVAR。