Beispiel #1
0
        public T AddSegment <T>(T segment, bool forceAdd) where T : TypedSegment
        {
            segment.Initialize(this, _delimiters);
            SegmentSpecification spec = AllowedChildSegments.FirstOrDefault(acs => acs.SegmentId == segment._segment.SegmentId);

            if (spec != null || forceAdd)
            {
                _segments.Add(segment._segment);
                return(segment);
            }
            else
            {
                return(null);
            }
        }
Beispiel #2
0
        public Segment AddSegment(string segmentString, bool forceAdd)
        {
            Segment segment           = new Segment(this, _delimiters, segmentString);
            SegmentSpecification spec = AllowedChildSegments.FirstOrDefault(acs => acs.SegmentId == segment.SegmentId);

            if (spec != null || segmentString.StartsWith("TA1") || forceAdd)
            {
                _segments.Add(segment);
                return(segment);
            }
            else if ((this.SegmentId == "NM1") &&
                     (new string[] { "N3", "N4", "PER", "REF" }.Contains(segment.SegmentId)))
            {
                _segments.Add(segment);
                return(segment);
            }
            else
            {
                return(null);
            }
        }