예제 #1
0
        /// <summary>
        /// Given a byte array representing this record in an X9 file, read its contents and fill in each field in this record with
        /// its value from the binary representation.
        /// </summary>
        /// <param name="record"></param>
        public void ReadRecord(byte[] record)
        {
            List <RecordByteSegment> segments = this.GetSegments();
            int offset = 0;

            foreach (RecordByteSegment segment in segments)
            {
                if (segment.Length.HasValue)
                {
                    foreach (X9Field f in segment.Fields)
                    {
                        X9TextField field    = (X9TextField)f;
                        int         len      = field.FieldType.Length.Value;
                        string      fieldStr = Edcbic.GetString(record.Skip(offset).Take(len).ToArray());
                        // Do any de-padding we might need
                        field.Deserialize(fieldStr);
                        offset += len;
                    }
                }
                else
                {
                    (this as X9DynamicLengthRecord)?.ReadDynamicField(record, offset);
                }
            }
        }
예제 #2
0
 public bool Equals(X9TextField that)
 {
     return(this.SerializedValue == that.SerializedValue);
 }