EdiFile¶
EdiFile is the root domain object for a parsed or constructed EDI interchange; it owns the flat Segments list produced by parsing (or built up via Add) and lazily derives the functional-group envelope hierarchy (FunctionalGroups) on first access. It is the primary object handed back by IEdiFileBuilder.Read() and passed into IEdiFileBuilder.Write(file).
Purpose¶
- Stores every segment of an interchange in insertion order and exposes the ISA header / IEA trailer as both raw
IEdiSegmentand strongly-typed (IsaSegment/IeaSegment) forms. Add(IEdiSegment)assigns the next sequential index to the segment viaIndexingSequence(BR-031) and, when the added segment is one of ISA/IEA/GS/GE, re-derives the envelope groupings by callingRefreshGroupings()(BR-032).RefreshGroupings()locates the first ISA and IEA segments and parses them as the interchange header/trailer (BR-029), and only triggers functional-group construction when ISA, IEA, GS, and GE are all present inSegments(BR-030).FunctionalGroupsis the one place the model layer calls back into the parser layer (EdiGroupParser.CreateFunctionalGroups), caching the result after first access — a lazy-initialization crossover point between the model and parser layers.*
Context¶
- Namespace:
SAIF.Common.Files.Edi - Assembly/package:
SAIF.Framework.Common.Files - Base class:
EdiRecordBase - Implements:
IEdiFile
Public members¶
| Member | Signature | Purpose |
|---|---|---|
| Header | public IsaSegment Header { get; internal set; } |
The strongly-typed interchange header parsed from the first ISA segment found by RefreshGroupings(). |
| HeaderSegment | public IEdiSegment HeaderSegment { get; internal set; } |
The raw ISA segment instance used as the source for Header. |
| Trailer | public IeaSegment Trailer { get; internal set; } |
The strongly-typed interchange trailer parsed from the first IEA segment found by RefreshGroupings(). |
| TrailerSegment | public IEdiSegment TrailerSegment { get; internal set; } |
The raw IEA segment instance used as the source for Trailer. |
| Segments | public IEnumerable<IEdiSegment> Segments { get; } |
The full flat, ordered collection of every segment in the interchange, including control segments. |
| FunctionalGroups | public IFunctionalGroupContainer FunctionalGroups { get; } |
Lazily builds (via EdiGroupParser.CreateFunctionalGroups) and caches the GS/GE-delimited functional-group hierarchy for this file. |
| Add | public void Add(IEdiSegment segment) |
Assigns the next sequential index to segment (BR-031), appends it to Segments, and re-derives groupings when the segment is ISA, IEA, GS, or GE (BR-032). |
| RefreshGroupings | public void RefreshGroupings() |
Re-locates the ISA/IEA header and trailer segments (BR-029) and rebuilds FunctionalGroups only when ISA, IEA, GS, and GE are all present (BR-030). |
| FileName | public string FileName { get; set; } |
The file name associated with this interchange, used by the writer when persisting the file. |
| SegmentCount | public int SegmentCount { get; } |
The total number of segments currently in Segments, including control segments. |
| SetSegments | protected internal void SetSegments(IEnumerable<IEdiSegment> segmentList) |
Replaces the entire segment list in bulk (used by the file reader/parser) and immediately calls RefreshGroupings() to rebuild the header/trailer/functional-group state. |
Inherited public members¶
Members in this section are inherited from EdiRecordBase in SAIF.Framework.Common.Files. They are available on this type through inheritance.
| Member | Signature | Purpose | Origin |
|---|---|---|---|
| SegmentDelimiter | protected char[] SegmentDelimiter |
The single-character tilde (~) delimiter used to split/join segments. |
SAIF.Framework.Common.Files — EdiRecordBase |
| DataElementDelimiter | protected char[] DataElementDelimiter |
The single-character asterisk (*) delimiter used to split/join data elements within a segment. |
SAIF.Framework.Common.Files — EdiRecordBase |
| SubElementDelimiter | protected char[] SubElementDelimiter |
The single-character colon (:) delimiter used to split/join sub-elements within a composite data element. |
SAIF.Framework.Common.Files — EdiRecordBase |
| IndexingSequence | protected Sequence IndexingSequence |
Generates the next sequential segment index consumed by Add(IEdiSegment). |
SAIF.Framework.Common.Files — EdiRecordBase |
Behavioral notes¶
FunctionalGroupscaches its result in a private field after the first access; subsequent reads do not re-parse unlessRefreshGroupings()explicitly triggersEdiGroupParser.CreateFunctionalGroupsagain.RefreshGroupings()silently leavesHeader/Trailerunset if no ISA/IEA segment is present, rather than throwing.
Note: Statements marked with
*were inferred from code structure, naming conventions, or contextual evidence where direct confirmation was not available in source artifacts.
Sources¶
- Common\SAIF.Common.Files\Edi\EdiFile.cs
- Common\SAIF.Common.Files\Edi\IEdiFile.cs