本文整理汇总了C#中FileHelperAsyncEngine.ReadNext方法的典型用法代码示例。如果您正苦于以下问题:C# FileHelperAsyncEngine.ReadNext方法的具体用法?C# FileHelperAsyncEngine.ReadNext怎么用?C# FileHelperAsyncEngine.ReadNext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileHelperAsyncEngine
的用法示例。
在下文中一共展示了FileHelperAsyncEngine.ReadNext方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AsyncRead
public void AsyncRead()
{
asyncEngine = new FileHelperAsyncEngine(typeof (SampleType));
SampleType rec1, rec2;
Assert.AreEqual(0, asyncEngine.LineNumber);
TestCommon.BeginReadTest(asyncEngine, "Good", "Test1.txt");
rec1 = (SampleType) asyncEngine.ReadNext();
Assert.IsNotNull(rec1);
Assert.AreEqual(1, asyncEngine.LineNumber);
rec2 = (SampleType) asyncEngine.ReadNext();
Assert.IsNotNull(rec1);
Assert.AreEqual(2, asyncEngine.LineNumber);
Assert.IsTrue(rec1 != rec2);
rec1 = (SampleType) asyncEngine.ReadNext();
Assert.IsNotNull(rec2);
Assert.AreEqual(3, asyncEngine.LineNumber);
rec1 = (SampleType) asyncEngine.ReadNext();
Assert.IsNotNull(rec2);
Assert.AreEqual(4, asyncEngine.LineNumber);
Assert.IsTrue(rec1 != rec2);
Assert.AreEqual(4, asyncEngine.TotalRecords);
Assert.AreEqual(0, asyncEngine.ErrorManager.ErrorCount);
}
示例2: AsyncRead
public void AsyncRead()
{
var asyncEngine = new FileHelperAsyncEngine<SampleType>();
SampleType rec1, rec2;
asyncEngine.BeginReadFile(FileTest.Good.Test1.Path);
rec1 = asyncEngine.ReadNext();
Assert.IsNotNull(rec1);
rec2 = asyncEngine.ReadNext();
Assert.IsNotNull(rec1);
Assert.IsTrue(rec1 != rec2);
rec1 = asyncEngine.ReadNext();
Assert.IsNotNull(rec2);
rec1 = asyncEngine.ReadNext();
Assert.IsNotNull(rec2);
Assert.IsTrue(rec1 != rec2);
Assert.AreEqual(0, asyncEngine.ErrorManager.ErrorCount);
asyncEngine.Close();
}
示例3: AsyncRead
public void AsyncRead()
{
FileHelperAsyncEngine<SampleType> asyncEngine = new FileHelperAsyncEngine<SampleType>();
SampleType rec1, rec2;
asyncEngine.BeginReadFile(Common.TestPath(@"Good\test1.txt"));
rec1 = asyncEngine.ReadNext();
Assert.IsNotNull(rec1);
rec2 = asyncEngine.ReadNext();
Assert.IsNotNull(rec1);
Assert.IsTrue(rec1 != rec2);
rec1 = asyncEngine.ReadNext();
Assert.IsNotNull(rec2);
rec1 = asyncEngine.ReadNext();
Assert.IsNotNull(rec2);
Assert.IsTrue(rec1 != rec2);
Assert.AreEqual(0, asyncEngine.ErrorManager.ErrorCount);
asyncEngine.Close();
}
示例4: AsyncRead
public void AsyncRead()
{
asyncEngine = new FileHelperAsyncEngine(typeof (SampleType));
SampleType rec1, rec2;
Common.BeginReadTest(asyncEngine, @"Good\test1.txt");
rec1 = (SampleType) asyncEngine.ReadNext();
Assert.IsNotNull(rec1);
rec2 = (SampleType) asyncEngine.ReadNext();
Assert.IsNotNull(rec1);
Assert.IsTrue(rec1 != rec2);
rec1 = (SampleType) asyncEngine.ReadNext();
Assert.IsNotNull(rec2);
rec1 = (SampleType) asyncEngine.ReadNext();
Assert.IsNotNull(rec2);
Assert.IsTrue(rec1 != rec2);
Assert.AreEqual(0, asyncEngine.ErrorManager.ErrorCount);
asyncEngine.Close();
}
示例5: AsyncFieldIndex1
public void AsyncFieldIndex1()
{
var engine = new FileHelperAsyncEngine(typeof (SampleType));
var sw = new StringWriter();
engine.BeginWriteStream(sw);
engine[0] = new DateTime(2003, 2, 1);
engine[1] = "B";
engine[2] = 18;
engine.WriteNextValues();
engine.Close();
engine.BeginReadString(sw.GetStringBuilder().ToString());
engine.ReadNext();
Assert.AreEqual(new DateTime(2003, 2, 1), engine[0]);
Assert.AreEqual("B", engine[1]);
Assert.AreEqual(18, engine[2]);
Assert.AreEqual(new DateTime(2003, 2, 1), engine.LastRecordValues[0]);
Assert.AreEqual("B", engine.LastRecordValues[1]);
Assert.AreEqual(18, engine.LastRecordValues[2]);
engine.ReadNext();
Assert.IsNull(engine.LastRecord);
Assert.IsNull(engine.LastRecordValues);
}
示例6: ReadWrite
/// <summary>
/// Process the delimited file twice,
/// once with the simple engine, once with Async
/// </summary>
/// <remarks>
/// This is a simple sample of using the Normal engine and the Async engine
/// </remarks>
public void ReadWrite()
{
var engine = new FileHelperEngine<Orders>();
// to Read use:
Orders[] res = engine.ReadFile(@"C:\TestIn.txt");
// to Write use:
engine.WriteFile(@"C:\TestOut.txt", res);
foreach (Orders order in res) {
Console.WriteLine("Order Info:");
Console.WriteLine(order.CustomerID + " - " +
order.OrderDate.ToString("dd/MM/yy"));
}
var asyncEngine = new FileHelperAsyncEngine<Orders>();
asyncEngine.BeginReadFile(@"C:\TestIn.txt");
Orders ord;
while (asyncEngine.ReadNext() != null) {
ord = asyncEngine.LastRecord;
// your code here
Console.WriteLine(ord.CustomerID);
}
}
示例7: ReadAllAsync
public static object[] ReadAllAsync(FileHelperAsyncEngine engine, string fileName)
{
ArrayList arr = new ArrayList();
engine.BeginReadFile(@"..\..\data\" + fileName);
while(engine.ReadNext() != null)
arr.Add(engine.LastRecord);
engine.Close();
return arr.ToArray();
}
示例8: LoadFromXML
public void LoadFromXML()
{
ClassBuilder cb = ClassBuilder.LoadFromXml(TestCommon.GetPath("Dynamic", "VendorImport.xml"));
Type t = cb.CreateRecordClass(); // this line generates an error in the FH library
using (var engine = new FileHelperAsyncEngine(t)) {
engine.BeginReadString("");
while (engine.ReadNext() != null) {}
}
}
示例9: DiscardFirst6
public void DiscardFirst6()
{
asyncEngine = new FileHelperAsyncEngine(typeof (DiscardType2));
Common.BeginReadTest(asyncEngine, @"Good\DiscardFirst2.txt");
Assert.AreEqual("you can get this lines\r\nwith the FileHelperEngine.HeaderText property\r\n", asyncEngine.HeaderText);
DiscardType2 res = (DiscardType2) asyncEngine.ReadNext();
Assert.AreEqual(new DateTime(1314, 12, 11), res.Field1);
}
示例10: ReadAllAsync
public static object[] ReadAllAsync(FileHelperAsyncEngine engine, params string[] pathElements)
{
ArrayList arr = new ArrayList();
using (engine.BeginReadFile(GetPath(pathElements)))
{
while (engine.ReadNext() != null)
arr.Add(engine.LastRecord);
}
return arr.ToArray();
}
示例11: AsyncFieldIndex3
public void AsyncFieldIndex3()
{
var engine = new FileHelperAsyncEngine(typeof (SampleType));
engine.BeginReadString(data);
while (engine.ReadNext() != null) {
Assert.AreEqual(engine["Field1"], engine.LastRecordValues[0]);
Assert.AreEqual(engine["Field2"], engine.LastRecordValues[1]);
Assert.AreEqual(engine["Field3"], engine.LastRecordValues[2]);
}
engine.Close();
}
示例12: AsyncFieldIndex4
public void AsyncFieldIndex4()
{
var engine = new FileHelperAsyncEngine(typeof (SampleType));
engine.BeginReadString(data);
Assert.AreEqual(3, engine.Options.FieldCount);
while (engine.ReadNext() != null) {
for (int i = 0; i < engine.Options.FieldCount; i++)
Assert.IsNotNull(engine[i]);
}
engine.Close();
}
示例13: Main
static void Main(string[] args)
{
FileHelperAsyncEngine engine = new FileHelperAsyncEngine (typeof(TestRecord));
engine.BeginReadFile(@"E:\_SVN\FileHelpers\test2.csv");
//string s;
while(engine.ReadNext() != null)
{
}
engine.Close();
}
示例14: AsyncRead2
public void AsyncRead2()
{
SampleType rec1;
var asyncEngine = new FileHelperAsyncEngine<SampleType>();
asyncEngine.BeginReadFile(FileTest.Good.Test1.Path);
int lineAnt = asyncEngine.LineNumber;
while (asyncEngine.ReadNext() != null)
{
rec1 = asyncEngine.LastRecord;
Assert.IsNotNull(rec1);
Assert.AreEqual(lineAnt + 1, asyncEngine.LineNumber);
lineAnt = asyncEngine.LineNumber;
}
Assert.AreEqual(4, asyncEngine.TotalRecords);
Assert.AreEqual(0, asyncEngine.ErrorManager.ErrorCount);
asyncEngine.Close();
}
示例15: Main
static void Main(string[] args)
{
long start = DateTime.Now.Ticks;
FileHelperAsyncEngine engine = new FileHelperAsyncEngine (typeof(TestRecord));
engine.BeginReadFile(@"E:\_SVN\FileHelpers\test2.csv");
//string s;
while(engine.ReadNext() != null)
{
}
engine.Close();
TimeSpan ts = new TimeSpan(DateTime.Now.Ticks - start);
Console.WriteLine("Total Time: " + Math.Round(ts.TotalSeconds, 2));
Console.ReadLine();
}