这个库几年前就被移走了,我找到的维基链接已经过时了。
我想将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。
发布于 2020-03-24 23:13:25
这段代码可以工作。实际上可能没有必要添加CreateField覆盖。
https://stackoverflow.com/questions/60820917
复制相似问题