コード例 #1
0
 public ElementIndex(ElementIndex?index, BaseSegmentIndex segmentIndex, BaseSpecificElementIndex?fieldIndex = null, BaseSpecificElementIndex?subFieldIndex = null, BaseSpecificElementIndex?componentIndex = null, int?subComponentIndex = null)
 {
     this.SegmentIndex      = segmentIndex;
     this.FieldIndex        = fieldIndex ?? index?.FieldIndex;
     this.SubFieldIndex     = subFieldIndex ?? index?.SubFieldIndex;
     this.ComponentIndex    = componentIndex ?? index?.ComponentIndex;
     this.SubComponentIndex = subComponentIndex ?? index?.SubComponentIndex;
 }
コード例 #2
0
        internal static Result <(BaseSegment?Segment, SegmentCollection SegmentCollection, int index)> TryGetSegmentAndSegmentCollectionAndIndex(Message message, BaseSegmentIndex segmentIndex)
        {
            var segmentCollections = message.GetSegmentCollections();

            if (segmentIndex is BaseSegmentNamedIndex bsni)
            {
                if (!FindSegmentCollection(segmentCollections, bsni).DecomposeResult(out var segCollectionResults, out string?error))
                {
                    return(ErrorReturn <(BaseSegment?, SegmentCollection, int)>(error ?? "Unknown error finding segment collection"));
                }
                if (bsni is SegmentNamedIndex sni)
                {
                    return(new Result <(BaseSegment?, SegmentCollection, int)>((segCollectionResults.collection.Segments?.FirstOrDefault(), segCollectionResults.collection, segCollectionResults.index)));
                }
                if (bsni is SegmentNameAndOrdinalIndex sii && sii.SegmentOrdinal.HasValue)
                {
                    return(new Result <(BaseSegment?, SegmentCollection, int)>((segCollectionResults.collection.Segments?.ElementAtOrDefault(sii.SegmentOrdinal.Value - 1), segCollectionResults.collection, segCollectionResults.index)));
                }
                else if (bsni is SegmentNameAndIdIndex ssi && !string.IsNullOrWhiteSpace(ssi.SegmentId))
                {
                    return(new Result <(BaseSegment?, SegmentCollection, int)>((segCollectionResults.collection.Segments?.FirstOrDefault(s => s.Id == ssi.SegmentId), segCollectionResults.collection, segCollectionResults.index)));
                }
                return(ErrorReturn <(BaseSegment?, SegmentCollection, int)>($"Did not find specified segment {segmentIndex}"));
            }
コード例 #3
0
 public ElementIndex(BaseSegmentIndex segmentIndex, BaseSpecificElementIndex?fieldIndex = null, BaseSpecificElementIndex?subFieldIndex = null, BaseSpecificElementIndex?componentIndex = null, int?subComponentIndex = null)
     : this(null, segmentIndex, fieldIndex, subFieldIndex, componentIndex, subComponentIndex)
 {
 }