protected virtual void WriteEntity(EdiBaseEntity ent, ref StringBuilder sb, IValidatedEntity validationScope = null) { if (ent is EdiLoop) { foreach (var child in ((EdiLoop)ent).Content) { WriteEntity(child, ref sb); } } else if (ent is EdiSegment) { var seg = (EdiSegment)ent; _currentTranSegCount++; sb.Append(ent.Name); foreach (var el in ((EdiSegment)ent).Content) { sb.Append($"{CurrentElementSeparator}{el.Val}"); } sb.Append(CurrentSegmentSeparator); if (validationScope != null) { SegmentValidator.ValidateSegment(seg, _currentTranSegCount, validationScope); } } }
private void GetTranSegCount(EdiBaseEntity ent, ref int segCount) { if (ent is EdiLoop) { foreach (var child in ((EdiLoop)ent).Content) { GetTranSegCount(child, ref segCount); } } else if (ent is EdiSegment) { segCount++; } }