public static bool MoveSegmentByLabel(List<Segment> source, List<Segment> dest, SegmentLabel lbl)
 {
     Segment temp_seg = source.FindSegmentByLabel(lbl);
     if (temp_seg == null) return false;
     dest.Add(temp_seg);
     source.Remove(temp_seg);
     return true;
 }
 public static void ProcessFooter(List<Segment> seg_list, IEdiMessage ediMessage, string ElementDelimiter,
                                  int segmentsProcessed)
 {
     Segment temp_seg = seg_list.FindSegmentByLabel(SegmentLabel.DocumentClose);
     int expected = temp_seg.GetElements(ElementDelimiter)[1].CastToInt();
     if (segmentsProcessed != expected)
         throw new InvalidEDIDocumentException("Segments processed does not match included segment count! Segments processed = " + segmentsProcessed + "; expected " + expected);
     if (ediMessage.ControlNumber != temp_seg.GetElements(ElementDelimiter)[2])
         throw new InvalidEDIDocumentException("Control numbers in _header and _footer do not match!");
     seg_list.Remove(temp_seg);
 }