public void RegisterDelegate() { try { using (FileStream stream = File.OpenRead(filePath)) { using (StdfFileReader reader = new StdfFileReader(stream)) { reader.RegisterDelegate(0, 10, delegate(object o, RecordReadEventArgs e) { Assert.IsInstanceOf(typeof(FarRecord), (e.Record)); }); reader.RegisterDelegate(0, 20, delegate(object o, RecordReadEventArgs e) { Assert.IsInstanceOf(typeof(AtrRecord), e.Record); }); reader.RegisterDelegate(1, 20, delegate(object o, RecordReadEventArgs e) { Assert.IsInstanceOf(typeof(MrrRecord), e.Record); }); reader.Read(); } } } catch (StdfException e) { Assert.Fail(e.ToString()); } }
private void ReadRecords(RecordInfo[] info, Stream stream) { StdfFileReader reader = null; try { reader = new StdfFileReader(stream); foreach (RecordInfo stdfInfo in info) { reader.RegisterDelegate(stdfInfo.Type, stdfInfo.Subtype, delegate(object o, RecordReadEventArgs e) { StdfRecord record = e.Record; Assert.AreEqual(stdfInfo.Type, record.Type); Assert.AreEqual(stdfInfo.Subtype, record.Subtype); }); } reader.Read(); } catch (StdfException e) { Console.WriteLine(e.StackTrace); Assert.Fail(e.Message); } finally { if (reader != null) { reader.Dispose(); } } }
public void SkippingUnknownRecords() { StdfFile file = new StdfFile(filePath); using (StdfFileReader reader = file.OpenForRead()) { reader.RecordRead += new RecordReadEventHandler(delegate(object o, RecordReadEventArgs e) { Assert.IsNotNull(e.Record); }); try { reader.Read(); } catch (Exception e) { Assert.Fail(e.Message); } } }
private static void Start() { Console.WriteLine("Starting to read"); DateTime start = DateTime.Now; int partCount = 0; try { using (FileStream stream = File.OpenRead(filePath)) { using (StdfFileReader reader = new StdfFileReader(stream)) { foreach (Type record in Records) { //reader.RegisterDelegate(record, PtrReadDelegate); reader.RegisterDelegate(record, delegate(object o, RecordReadEventArgs e) { partCount++; //Console.WriteLine(e.Record); //Debug.WriteLine("Read {0} PTR records", partCount); }); } reader.Read(); Finish(); } } } catch (Exception e) { Console.WriteLine("An exception occurred: {0}", e.Message); Console.WriteLine(e.StackTrace); } DateTime end = DateTime.Now; Console.WriteLine("Elapsed time: {0}", end - start); Console.WriteLine("Counted {0} parts", partCount); Console.ReadLine(); }