public void ParseLine(Prism820Context context, string line) { if (string.IsNullOrWhiteSpace(line)) { return; } if (line.Length < 2) { return; } var indicator = line.Substring(0, 2); var marketFields = line.Split('|'); switch (indicator) { case "SH": context.ResolveToHeader(); context.Initialize(); context.TransactionActualCount++; break; case "01": ParseHeader(context, marketFields); break; case "20": ParseDetail(context, marketFields); break; case "TL": context.ResolveToHeader(); marketFields.TryAtIndexInt(1, x => context.TransactionAuditCount = x); break; } }
public IMarketFileParseResult Parse(Stream stream) { var context = new Prism820Context(); using (var reader = new StreamReader(stream)) { string marketFileLine; while ((marketFileLine = reader.ReadLine()) != null) { ParseLine(context, marketFileLine); } } if (context.ShouldResolve) { logger.Warn("Unresolved data identified after parsing 820. Transactions may not be completed."); context.ResolveToHeader(); } return(context.Results); }