The library was moved some years ago and the link I found for a wiki is stale.
I would like to add bit 127 to the Iso8583 class. I am using the below code but the program dies in the Pack() method, called from ToMsg(). I don't know what value to put in the length field. The field is a LLLVAR with a max length of 5, so is the length 5, or 8, or 999? All three values throw an exception in Pack().
What do I need to add to get bit 127 working?
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);
}
}
}
EDIT 3/24/20: I added an override to Bit and CreateField. I want the new bit 127 to act like a default LLLVAR of length 5.
This code works. It may not actually be necessary to add the CreateField override.