private static void Parse835Files(string[] args) { var inputPath = @"C:\Users\wilcoxk\Documents\EraSummary\835"; var outputPath = @"C:\Users\wilcoxk\Documents\EraSummary\835_parsed"; Directory.CreateDirectory(outputPath); var start = DateTime.Now; var counter = 0; // The factory caches all the objects it's going to use. // If you pass in the factory it's all cached // If you don't it creates a factory for you, which // rebuilds the cache every time var factory = new X12Factory(typeof(X12)); foreach (var file in Directory.EnumerateFiles(inputPath)) { counter++; var newFile = file.Replace(inputPath, outputPath); newFile = Path.ChangeExtension(newFile, "txt"); var segments = Parser.Parse(file, factory); using (StreamWriter writer = File.CreateText(newFile)) { segments.ForEach(x => x.Dump(writer, $"{Environment.NewLine} *** {x.RecordType} ***")); writer.Flush(); } break; } var end = DateTime.Now; var total = end - start; Console.WriteLine($"*** DONE {counter} files in {total} ***"); }
public ISATests() { // This is only necessary in unit tests because the test runners are typically unmanaged code // which makes the call to GetEntryAssembly return null, this way we are handing // "ourselves" to the factory instead of the factory trying to find us. _factory = new X12Factory(typeof(X12), Assembly.GetExecutingAssembly()); _sut = Parser.ParseText(_isaProperties, _factory); _cache = _factory.GetPropertiesForType("ISA"); }