public object Clone() { ISOBitmap b = new ISOBitmap((int)Key); b.Value = Value; return b; }
public object Clone() { ISOBitmap b = new ISOBitmap((int)Key); b.Value = Value; return(b); }
public int Decode(ISOComponent component, byte[] data) { int offset = 0; #region - HEADER - if (component is ISOMessage && HeaderLength > 0) { byte[] header = new byte[HeaderLength]; Array.Copy(data, 0, header, 0, HeaderLength); ((ISOMessage)component).Header = new ISOHeader(header); ((ISOMessage)component).Header.ASCIIEncoding = this.HeaderASCII; offset += HeaderLength; } #endregion #region - MTI - if (!(_fields[0] is ISOBitmapEncoder)) { ISOComponent mti = ((ISOFieldEncoder)_fields[0]).CreateComponent(0); offset += ((ISOFieldEncoder)_fields[0]).Decode(mti, data, offset); component.Add(mti); } #endregion #region - BITMAP - BitArray bitArray = null; int totalFields = _fields.Count; if (HasBitmap) { ISOBitmap bitmap = new ISOBitmap(-1); offset += GetBitmapEncoder().Decode(bitmap, data, offset); bitArray = (BitArray)bitmap.Value; component.Add(bitmap); totalFields = Math.Min(totalFields, bitArray.Length); } #endregion #region - FIELDS - for (int i = FirstField; i < totalFields; i++) { if (bitArray[i]) { // bit array starts at 0 if (_fields[i] == null) throw new ISOException(string.Format("Field encoder not defined for {0}", i)); try { ISOComponent c = ((ISOFieldEncoder)_fields[i]).CreateComponent(i); offset += ((ISOFieldEncoder)_fields[i]).Decode(c, data, offset); component.Add(c); } catch (ISOException e) { e = new ISOException(string.Format("Error decoding field {0}: {1} ({2}). Bytes consumed: {3} ", i, e.Message, e.InnerException.Message, offset)); throw; } } } #endregion // TODO: Do something if still there're bytes to process...? return offset; }
public int Decode(ISOComponent component, byte[] data) { int offset = 0; #region - HEADER - if (component is ISOMessage && HeaderLength > 0) { byte[] header = new byte[HeaderLength]; Array.Copy(data, 0, header, 0, HeaderLength); ((ISOMessage)component).Header = new ISOHeader(header); ((ISOMessage)component).Header.ASCIIEncoding = this.HeaderASCII; offset += HeaderLength; } #endregion #region - MTI - if (!(_fields[0] is ISOBitmapEncoder)) { ISOComponent mti = ((ISOFieldEncoder)_fields[0]).CreateComponent(0); offset += ((ISOFieldEncoder)_fields[0]).Decode(mti, data, offset); component.Add(mti); } #endregion #region - BITMAP - BitArray bitArray = null; int totalFields = _fields.Count; if (HasBitmap) { ISOBitmap bitmap = new ISOBitmap(-1); offset += GetBitmapEncoder().Decode(bitmap, data, offset); bitArray = (BitArray)bitmap.Value; component.Add(bitmap); totalFields = Math.Min(totalFields, bitArray.Length); } #endregion #region - FIELDS - for (int i = FirstField; i < totalFields; i++) { if (bitArray[i]) // bit array starts at 0 { if (_fields[i] == null) { throw new ISOException(string.Format("Field encoder not defined for {0}", i)); } try { ISOComponent c = ((ISOFieldEncoder)_fields[i]).CreateComponent(i); offset += ((ISOFieldEncoder)_fields[i]).Decode(c, data, offset); component.Add(c); } catch (ISOException e) { e = new ISOException(string.Format("Error decoding field {0}: {1} ({2}). Bytes consumed: {3} ", i, e.Message, e.InnerException.Message, offset)); throw; } } } #endregion // TODO: Do something if still there're bytes to process...? return(offset); }