本文整理汇总了C#中FileHelperAsyncEngine.Close方法的典型用法代码示例。如果您正苦于以下问题:C# FileHelperAsyncEngine.Close方法的具体用法?C# FileHelperAsyncEngine.Close怎么用?C# FileHelperAsyncEngine.Close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileHelperAsyncEngine
的用法示例。
在下文中一共展示了FileHelperAsyncEngine.Close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteNullAsync
public void WriteNullAsync()
{
asyncEngine = new FileHelperAsyncEngine(typeof (SampleType));
asyncEngine.BeginWriteFile("tempNull.txt");
asyncEngine.WriteNext(new SampleType());
asyncEngine.WriteNext(new SampleType());
asyncEngine.WriteNext(new SampleType());
asyncEngine.Close();
asyncEngine.BeginReadFile("tempNull.txt");
SampleType[] res = (SampleType[]) asyncEngine.ReadNexts(5000);
asyncEngine.Close();
Assert.AreEqual(3, res.Length);
Assert.AreEqual(3, asyncEngine.TotalRecords);
Assert.AreEqual(0, asyncEngine.ErrorManager.ErrorCount);
Assert.AreEqual(DateTime.MinValue, res[0].Field1);
Assert.AreEqual("", res[0].Field2);
Assert.AreEqual(0, res[0].Field3);
if (File.Exists("tempNull.txt")) File.Delete("tempNull.txt");
}
示例2: AsyncRead
public void AsyncRead()
{
asyncEngine = new FileHelperAsyncEngine(typeof (SampleType));
SampleType rec1, rec2;
TestCommon.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();
}
示例3: 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();
}
示例4: ImportGeonamesFrom
public void ImportGeonamesFrom(string fileName)
{
var geoNames = new FileHelperAsyncEngine(typeof(Geoname));
geoNames.BeginReadFile(fileName);
_geoDataStore.DeleteAll();
long cnt = 0;
foreach (Geoname geoName in geoNames)
{
//Store the name in a format suitable for case-insensitive searching:
geoName.Name = geoName.Name.ToUpper();
if (geoName.FeatureClass == "P")
{
SaveCity(geoName, cnt);
}
// Parks: http://127.0.0.1:28017/local/geonames/?filter_FeatureClass=L&filter_FeatureCode=PRK
if(geoName.FeatureClass.Equals("L") && geoName.FeatureCode.Equals("PRK"))
{
SavePark(geoName);
}
cnt++;
}
_geoDataStore.DoIndexing();
geoNames.Close();
}
开发者ID:robertreppel,项目名称:Find-A-Park---Geospatial-searching-in-MongoDB,代码行数:31,代码来源:GeoDataImporter.cs
示例5: 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);
}
示例6: 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();
}
示例7: 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);
}
示例8: 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();
}
示例9: 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();
}
示例10: 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();
}
示例11: 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();
}
示例12: cmdRun_Click
/// <summary>
/// Run the Async engine with a vertical bar file
/// </summary>
private void cmdRun_Click(object sender, EventArgs e)
{
txtOut.Text = string.Empty;
var engine = new FileHelperAsyncEngine<CustomersVerticalBar>();
engine.BeginReadString(TestData.mCustomersTest);
// The Async engines are IEnumerable
foreach(CustomersVerticalBar cust in engine)
{
// your code here
txtOut.Text += cust.CustomerID + " - " + cust.ContactTitle + Environment.NewLine;
}
engine.Close();
}
示例13: AsyncFieldIndex1
public void AsyncFieldIndex1()
{
var engine = new FileHelperAsyncEngine(typeof (SampleType));
engine.BeginReadString(data);
foreach (SampleType rec in engine) {
Assert.AreEqual(rec.Field1, engine[0]);
Assert.AreEqual(rec.Field2, engine[1]);
Assert.AreEqual(rec.Field3, engine[2]);
Assert.AreEqual(rec.Field1, engine["Field1"]);
Assert.AreEqual(rec.Field2, engine["Field2"]);
Assert.AreEqual(rec.Field3, engine["Field3"]);
}
engine.Close();
}
示例14: AsyncReadEnumerable
public void AsyncReadEnumerable()
{
var asyncEngine = new FileHelperAsyncEngine<SampleType>();
asyncEngine.BeginReadFile(FileTest.Good.Test1.Path);
int lineAnt = asyncEngine.LineNumber;
foreach (var rec1 in asyncEngine)
{
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: 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();
}