static void QuickDynamicTest() { ChoKVPRecordConfiguration config = new ChoKVPRecordConfiguration(); ChoKVPRecordFieldConfiguration idConfig = new ChoKVPRecordFieldConfiguration("UID"); config.KVPRecordFieldConfigurations.Add(idConfig); config.KVPRecordFieldConfigurations.Add(new ChoKVPRecordFieldConfiguration("DTSTAMP")); //config.KVPRecordFieldConfigurations.Add(new ChoKVPRecordFieldConfiguration("DTSTART")); //config.KVPRecordFieldConfigurations.Add(new ChoKVPRecordFieldConfiguration("DTENDX")); //config.KVPRecordFieldConfigurations.Add(new ChoKVPRecordFieldConfiguration("DTEND")); using (var stream = new MemoryStream()) using (var reader = new StreamReader(stream)) using (var writer = new StreamWriter(stream)) using (var parser = new ChoKVPReader(reader, config).ColumnCountStrict().ColumnOrderStrict()) { writer.WriteLine("BEGIN:VCALENDAR"); writer.WriteLine("VERSION:2.0"); writer.WriteLine("PRODID:-//hacksw/handcal//NONSGML v1.0//EN"); writer.WriteLine("[BEGIN:VEVENT"); writer.WriteLine("UID:[email protected]"); writer.WriteLine(" [email protected]"); writer.WriteLine("DTSTAMP:19970714T170000Z"); //writer.WriteLine("ORGANIZER;CN=John Doe:MAILTO:[email protected]"); //writer.WriteLine("DTSTART:19970714T170000Z"); //writer.WriteLine("DTEND:19970715T035959Z"); //writer.WriteLine("SUMMARY:Bastille Day Party"); //writer.WriteLine("END:VEVENT]"); //writer.WriteLine("[BEGIN:VEVENT"); //writer.WriteLine("UID:[email protected]"); //writer.WriteLine("DTSTAMP:19970714T170000Z"); //writer.WriteLine("ORGANIZER;CN=John Doe:MAILTO:[email protected]"); //writer.WriteLine("DTSTART:19970714T170000Z"); //writer.WriteLine("DTEND:19970715T035959Z"); //writer.WriteLine("SUMMARY:Bastille Day Party"); writer.WriteLine("END:VEVENT]"); writer.WriteLine("END:VCALENDAR"); writer.Flush(); stream.Position = 0; //parser.Configuration.RecordStart = "BEGIN:VCALENDAR"; //parser.Configuration.RecordEnd = "END:VEVENT"; //parser.Configuration.RecordStart = "[BEGIN:VEVENT"; //parser.Configuration.RecordEnd = "END:VEVENT"; parser.Configuration.RecordStart = "[BEGIN:VEVENT"; parser.Configuration.RecordEnd = "END:VEVENT]"; object rec; while ((rec = parser.Read()) != null) { Console.WriteLine(rec.ToStringEx()); } } }
public static void QuickTest() { using (var r = new ChoKVPReader(FileNameSampleICS)) { r.Configuration.RecordStart = "BEGIN:VEVENT"; r.Configuration.RecordEnd = "END:VEVENT"; r.Configuration.IgnoreEmptyLine = true; r.Configuration.Comment = ";"; //foreach (dynamic item in r) //{ // Console.WriteLine(item.SUMMARY); //} Assert.Throws <ChoETL.ChoRecordConfigurationException>(() => r.Read()); } }
static void QuickTest() { using (var r = new ChoKVPReader(@"sample.ics")) { r.Configuration.RecordStart = "BEGIN:VEVENT"; r.Configuration.RecordEnd = "END:VEVENT"; r.Configuration.IgnoreEmptyLine = true; r.Configuration.Comment = ";"; //foreach (dynamic item in r) //{ // Console.WriteLine(item.SUMMARY); //} dynamic rec; while ((rec = r.Read()) != null) { Console.WriteLine(rec.DESCRIPTION); } } }