Exemplo n.º 1
0
        /// <summary>
        /// Creates an IsoValue with the given values and stores it in the specified index.
        /// </summary>
        /// <param name="index">The field index (2 to 128)</param>
        /// <param name="value">An object value to store inside an IsoValue.</param>
        /// <param name="t">The ISO8583 for this value.</param>
        /// <param name="length">The length of the value (useful only for NUMERIC and ALPHA types).</param>
        public void SetValue(int index, object value, IsoType t, int length)
        {
            if (index < 2 || index > 128)
            {
                throw new ArgumentOutOfRangeException(nameof(index), "Index must be between 2 and 128");
            }

            if (value == null)
            {
                _fields.Remove(index);
            }
            else
            {
                IsoValue v = null;
                v = IsoTypeHelper.NeedsLength(t) ? new IsoValue(t, value, length) : new IsoValue(t, value);
                _fields[index] = v;
            }
        }
Exemplo n.º 2
0
 /// <summary> Creates a new instance to store a value of a fixed-length type. Fixed-length types are DATE4, DATE_EXP, DATE10, TIME, AMOUNT. </summary>
 /// <param name="t">The <see cref="IsoType"/> (8583) type of the value that is going to be stored.</param>
 /// <param name="value">The value to store.s</param>
 public IsoValue(IsoType t, object value)
 {
     if (value == null)
     {
         throw new ArgumentException("Value cannot be null");
     }
     if (IsoTypeHelper.NeedsLength(t))
     {
         throw new ArgumentException("Use IsoValue constructor for Fixed-value types");
     }
     _type = t;
     _fval = value;
     if (t == IsoType.LLVAR || _type == IsoType.LLLVAR || t == IsoType.LLVARnp || _type == IsoType.LLLVARnp)
     {
         _length = value.ToString().Length;
     }
     else
     {
         _length = IsoTypeHelper.GetLength(t);
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Creates a new instance to store a value of a given type. This constructor
 /// is used for variable-length types (LLVAR, LLLVAR, ALPHA, NUMERIC) -
 /// variable in the sense that that length of the value does not depend
 /// solely on the ISO type.
 /// </summary>
 /// <param name="t">the <see cref="IsoType"/> ISO8583 type of the value to be stored.</param>
 /// <param name="val">The value to be stored.</param>
 /// <param name="len">The length of the field.</param>
 public IsoValue(IsoType t, object val, int len)
 {
     if (val == null)
     {
         throw new ArgumentException("Value cannot be null");
     }
     _type   = t;
     _fval   = val;
     _length = len;
     if (_length < 0 && IsoTypeHelper.NeedsLength(t))
     {
         throw new ArgumentException("Length must be greater than zero");
     }
     else if (t == IsoType.LLVAR || t == IsoType.LLLVAR)
     {
         _length = val.ToString().Length;
         //@@@ TAM
     }
     else if (t == IsoType.LLVARnp || t == IsoType.LLLVARnp)
     {
         _length = val.ToString().Length * 2;
     }
 }