本文整理汇总了C#中FileHelperAsyncEngine.WriteNexts方法的典型用法代码示例。如果您正苦于以下问题:C# FileHelperAsyncEngine.WriteNexts方法的具体用法?C# FileHelperAsyncEngine.WriteNexts怎么用?C# FileHelperAsyncEngine.WriteNexts使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileHelperAsyncEngine
的用法示例。
在下文中一共展示了FileHelperAsyncEngine.WriteNexts方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteEvents
public void WriteEvents()
{
before = 0;
after = 0;
engine = new FileHelperAsyncEngine<SampleType>();
engine.BeforeWriteRecord += new BeforeWriteHandler<SampleType>(engine_BeforeWriteRecord);
engine.AfterWriteRecord += new AfterWriteHandler<SampleType>(engine_AfterWriteRecord);
var res = new SampleType[2];
res[0] = new SampleType();
res[1] = new SampleType();
res[0].Field1 = DateTime.Now.AddDays(1);
res[0].Field2 = "je";
res[0].Field3 = 0;
res[1].Field1 = DateTime.Now;
res[1].Field2 = "ho";
res[1].Field3 = 2;
engine.BeginWriteFile("tempEvent.txt");
engine.WriteNexts(res);
engine.Close();
File.Delete("tempEvent.txt");
Assert.AreEqual(2, engine.TotalRecords);
Assert.AreEqual(2, before);
Assert.AreEqual(2, after);
}
示例2: NullRecords2
public void NullRecords2()
{
engine2 = new FileHelperAsyncEngine(typeof (SampleType));
engine2.BeginWriteStream(new StringWriter(new StringBuilder()));
Assert.Throws<ArgumentNullException>(()
=> engine2.WriteNexts(null));
}
示例3: DiscardWriteRead2
public void DiscardWriteRead2()
{
var engine = new FileHelperEngine<DiscardLastType1>();
DiscardLastType1[] res = TestCommon.ReadTest<DiscardLastType1>(engine, "Good", "DiscardLast1.txt");
var asyncEngine = new FileHelperAsyncEngine<DiscardLastType1>();
asyncEngine.FooterText = "This is a new Footer....";
asyncEngine.BeginWriteFile("temp.txt");
asyncEngine.WriteNexts(res);
asyncEngine.Close();
asyncEngine.FooterText = "none none";
asyncEngine.BeginReadFile("temp.txt");
while (asyncEngine.ReadNext() != null) {}
Assert.AreEqual(res.Length, asyncEngine.TotalRecords);
Assert.AreEqual(expectedShortFooterText, asyncEngine.FooterText);
asyncEngine.Close();
Assert.AreEqual(res.Length, asyncEngine.TotalRecords);
Assert.AreEqual(expectedShortFooterText, asyncEngine.FooterText);
if (File.Exists("tempo.txt"))
File.Delete("tempo.txt");
}
示例4: NullRecords2
public void NullRecords2()
{
engine2 = new FileHelperAsyncEngine(typeof (SampleType));
engine2.BeginWriteStream(new StringWriter(new StringBuilder()));
engine2.WriteNexts(null);
}
示例5: DiscardWriteRead2
public void DiscardWriteRead2()
{
engine = new FileHelperEngine(typeof(DiscardType1));
DiscardType1[] res = (DiscardType1[])Common.ReadTest(engine, @"Good\DiscardFirst1.txt");
asyncEngine = new FileHelperAsyncEngine(typeof(DiscardType1));
asyncEngine.HeaderText = "This is a new header....";
asyncEngine.BeginWriteFile("tempo.txt");
asyncEngine.WriteNexts(res);
asyncEngine.Close();
asyncEngine.HeaderText = "none none\r\n";
asyncEngine.BeginReadFile(@"tempo.txt");
while (asyncEngine.ReadNext() != null)
{}
Assert.AreEqual(res.Length, asyncEngine.TotalRecords);
Assert.AreEqual("This is a new header....\r\n", asyncEngine.HeaderText);
asyncEngine.Close();
Assert.AreEqual(res.Length, asyncEngine.TotalRecords);
Assert.AreEqual("This is a new header....\r\n", asyncEngine.HeaderText);
if (File.Exists("tempo.txt")) File.Delete("tempo.txt");
}
示例6: DiscardWriteRead2
public void DiscardWriteRead2()
{
var engine = new FileHelperEngine<DiscardType1>();
DiscardType1[] res = engine.ReadFile(FileTest.Good.DiscardFirst1.Path);
var asyncEngine = new FileHelperAsyncEngine<DiscardType1>();
asyncEngine.HeaderText = "This is a new header....";
asyncEngine.BeginWriteFile("tempo.txt");
asyncEngine.WriteNexts(res);
asyncEngine.Close();
asyncEngine.HeaderText = "none none\r\n";
asyncEngine.BeginReadFile(@"tempo.txt");
while (asyncEngine.ReadNext() != null) {}
Assert.AreEqual(res.Length, asyncEngine.TotalRecords);
Assert.AreEqual(mExpectedShortHeaderText, asyncEngine.HeaderText);
asyncEngine.Close();
Assert.AreEqual(res.Length, asyncEngine.TotalRecords);
Assert.AreEqual(mExpectedShortHeaderText, asyncEngine.HeaderText);
if (File.Exists("tempo.txt"))
File.Delete("tempo.txt");
}