---
title: IEdiFile
summary: API reference for IEdiFile.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-09-15
library: SAIF.Framework.Common.Files
reference_type: package
---

# IEdiFile

`IEdiFile` is the contract implemented by `EdiFile`; it defines the public surface for reading, inspecting, and appending to an EDI interchange, and is the type returned by `IEdiFileBuilder.Read()` and consumed by `IEdiFileBuilder.Write(file)`.

## Purpose
- Declares the interchange header/trailer accessors, the flat `Segments` collection, the lazily-built `FunctionalGroups` hierarchy, and the mutation operations (`Add`, `RefreshGroupings`) that any conforming implementation must provide.
- Lets code depend on the interchange abstraction rather than the concrete `EdiFile` class, supporting substitution in tests or alternate implementations.*

## Context
- Namespace: `SAIF.Common.Files.Edi`
- Assembly/package: `SAIF.Framework.Common.Files`

## Public members
| Member | Signature | Purpose |
| --- | --- | --- |
| Header | `IsaSegment Header { get; }` | The strongly-typed interchange header parsed from the first ISA segment ([BR-029](../../business-rules.md#br-029-first-isa-and-iea-are-the-interchange-header-and-trailer)). |
| HeaderSegment | `IEdiSegment HeaderSegment { get; }` | The raw ISA segment instance used as the source for `Header`. |
| Trailer | `IeaSegment Trailer { get; }` | The strongly-typed interchange trailer parsed from the first IEA segment ([BR-029](../../business-rules.md#br-029-first-isa-and-iea-are-the-interchange-header-and-trailer)). |
| TrailerSegment | `IEdiSegment TrailerSegment { get; }` | The raw IEA segment instance used as the source for `Trailer`. |
| Segments | `IEnumerable<IEdiSegment> Segments { get; }` | The full flat, ordered collection of every segment in the interchange, including control segments. |
| FunctionalGroups | `IFunctionalGroupContainer FunctionalGroups { get; }` | The GS/GE-delimited functional-group hierarchy for this file, built only when ISA, IEA, GS, and GE are all present ([BR-030](../../business-rules.md#br-030-functional-groups-built-only-when-all-four-control-segments-present)). |
| Add | `void Add(IEdiSegment segment)` | Appends a segment to the interchange, assigning it the next sequential index ([BR-031](../../business-rules.md#br-031-every-added-segment-receives-the-next-sequential-index)) and re-deriving groupings when it is a control segment ([BR-032](../../business-rules.md#br-032-adding-a-control-segment-re-derives-envelope-groupings)). |
| RefreshGroupings | `void RefreshGroupings()` | Re-locates the ISA/IEA header and trailer and rebuilds functional groups when all four control segments are present ([BR-030](../../business-rules.md#br-030-functional-groups-built-only-when-all-four-control-segments-present)). |
| FileName | `string FileName { get; set; }` | The file name associated with this interchange. |
| SegmentCount | `int SegmentCount { get; }` | The total number of segments currently in `Segments`, including control segments. |

> **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\IEdiFile.cs
