当前位置: 首页>>代码示例>>C#>>正文


C# FileHelperAsyncEngine.BeginReadString方法代码示例

本文整理汇总了C#中FileHelperAsyncEngine.BeginReadString方法的典型用法代码示例。如果您正苦于以下问题:C# FileHelperAsyncEngine.BeginReadString方法的具体用法?C# FileHelperAsyncEngine.BeginReadString怎么用?C# FileHelperAsyncEngine.BeginReadString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FileHelperAsyncEngine的用法示例。


在下文中一共展示了FileHelperAsyncEngine.BeginReadString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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);
        }
开发者ID:abombss,项目名称:FileHelpers,代码行数:31,代码来源:WritersFieldIndexers.cs

示例2: BeginWriteWhileReading

        public void BeginWriteWhileReading()
        {
            FileHelperAsyncEngine eng = new FileHelperAsyncEngine(typeof(SampleType));
            eng.BeginReadString("jejjeje");

            var filename = TestCommon.GetTempFile("TempWrite.txt");
            Assert.Throws<BadUsageException>(()
                => eng.BeginWriteFile(filename));
        }
开发者ID:TheJeremyGray,项目名称:FileWatcherService,代码行数:9,代码来源:ErrorModeValidatorAsync.cs

示例3: 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) {}
            }
        }
开发者ID:mgmccarthy,项目名称:FileHelpers,代码行数:11,代码来源:DynamicClassFiles.cs

示例4: AsyncFieldIndexBad1

        public void AsyncFieldIndexBad1()
        {
            var engine = new FileHelperAsyncEngine(typeof (SampleType));
            engine.BeginReadString(data);

            while (engine.ReadNext() != null) {
                Assert.Throws<IndexOutOfRangeException>(()
                    => { object val = engine[10]; });
            }

            engine.Close();
        }
开发者ID:mgmccarthy,项目名称:FileHelpers,代码行数:12,代码来源:ReadersFieldIndexers.cs

示例5: 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();
        }
开发者ID:mgmccarthy,项目名称:FileHelpers,代码行数:13,代码来源:ReadersFieldIndexers.cs

示例6: MoreCallsToMoveNext1

 public void MoreCallsToMoveNext1()
 {
     var engine = new FileHelperAsyncEngine<Record>();
     string src = "first,line\nabc,JohnDoe";
     using (engine.BeginReadString(src))
     {
         var enumerator = (engine as IEnumerable<Record>).GetEnumerator();
         enumerator.MoveNext();
         enumerator.MoveNext();
         enumerator.MoveNext();
         enumerator.MoveNext();
     }
 }
开发者ID:mgmccarthy,项目名称:FileHelpers,代码行数:13,代码来源:AsyncEnumerator.cs

示例7: 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();
        }
开发者ID:mgmccarthy,项目名称:FileHelpers,代码行数:14,代码来源:ReadersFieldIndexers.cs

示例8: 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();
        }
开发者ID:mgmccarthy,项目名称:FileHelpers,代码行数:17,代码来源:ReadersFieldIndexers.cs

示例9: 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();
        }
开发者ID:rohancragg,项目名称:FileHelpers,代码行数:20,代码来源:frmEasySampleAsync.cs

示例10: ChangeLineInEvent

        public void ChangeLineInEvent()
        {
            string input = "\n\n\n";
            engine = new FileHelperAsyncEngine<SampleType>();
            engine.BeforeReadRecord += new BeforeReadHandler<SampleType>(BeforeEventChange);

            engine.BeginReadString(input);
            SampleType[] res = (SampleType[]) engine.ReadNexts(3);

            Assert.AreEqual(3, res.Length);
            Assert.AreEqual(new DateTime(1314, 12, 11), res[0].Field1);
            Assert.AreEqual("901", res[0].Field2);
            Assert.AreEqual(234, res[0].Field3);

            Assert.AreEqual(new DateTime(1314, 12, 11), res[1].Field1);
            Assert.AreEqual("901", res[2].Field2);
            Assert.AreEqual(234, res[2].Field3);
        }
开发者ID:TheJeremyGray,项目名称:FileWatcherService,代码行数:18,代码来源:EventsAsync.cs

示例11: BeginReadWhileWriting

        public void BeginReadWhileWriting()
        {
            FileHelperAsyncEngine eng = new FileHelperAsyncEngine(typeof(SampleType));

            var filename = TestCommon.GetTempFile("TempWrite.txt");

            Assert.Throws<BadUsageException>(()
                                             =>
                                                 {
                                                     try
                                                     {
                                                         eng.BeginWriteFile(filename);
                                                         eng.BeginReadString("jejjeje");
                                                     }
                                                     finally
                                                     {
                                                         eng.Close();
                                                         if (File.Exists(filename))
                                                             File.Delete(filename);
                                                     }
                                                 });
        }
开发者ID:TheJeremyGray,项目名称:FileWatcherService,代码行数:22,代码来源:ErrorModeValidatorAsync.cs

示例12: RunTestAsync

        private void RunTestAsync()
        {
            long start = DateTime.Now.Ticks;

            FileHelperAsyncEngine engine = new FileHelperAsyncEngine(typeof (OrdersVerticalBar));

            engine.BeginReadString(mSourceString);

            while (engine.ReadNext() != null)
            {
            }

            long end = DateTime.Now.Ticks;

            TimeSpan span = new TimeSpan(end - start);
            lblTimeAsync.Text = Math.Round(span.TotalSeconds, 4).ToString() + " sec.";
            Application.DoEvents();
        }
开发者ID:hoffmanc,项目名称:FileHelpers,代码行数:18,代码来源:frmTiming.cs

示例13: ReadAsyncFieldIndex

        public void ReadAsyncFieldIndex()
        {
            string data = "11121314901234" + Environment.NewLine +
                          "10111314012345" + Environment.NewLine +
                          "11101314123456" + Environment.NewLine +
                          "10101314234567" + Environment.NewLine;

            var asyncEngine = new FileHelperAsyncEngine<SampleType>();
            asyncEngine.BeginReadString(data);

            foreach (var rec in asyncEngine) {
                Assert.AreEqual(rec.Field1, asyncEngine[0]);
                Assert.AreEqual(rec.Field2, asyncEngine[1]);
                Assert.AreEqual(rec.Field3, asyncEngine[2]);

                Assert.AreEqual(rec.Field1, asyncEngine["Field1"]);
                Assert.AreEqual(rec.Field2, asyncEngine["Field2"]);
                Assert.AreEqual(rec.Field3, asyncEngine["Field3"]);
            }

            asyncEngine.Close();
        }
开发者ID:calebillman,项目名称:FileHelpers,代码行数:22,代码来源:Readers.cs

示例14: ReadAsyncFieldIndex

        public void ReadAsyncFieldIndex()
        {
            string data = "11121314901234\n" +
                "10111314012345\n" +
                "11101314123456\n" +
                "10101314234567\n" ;

            asyncEngine = new FileHelperAsyncEngine(typeof(SampleType));
            asyncEngine.BeginReadString(data);

            foreach (SampleType rec in asyncEngine)
            {
                Assert.AreEqual(rec.Field1, asyncEngine[0]);
                Assert.AreEqual(rec.Field2, asyncEngine[1]);
                Assert.AreEqual(rec.Field3, asyncEngine[2]);

                Assert.AreEqual(rec.Field1, asyncEngine["Field1"]);
                Assert.AreEqual(rec.Field2, asyncEngine["Field2"]);
                Assert.AreEqual(rec.Field3, asyncEngine["Field3"]);

            }

            asyncEngine.Close();
        }
开发者ID:TheJeremyGray,项目名称:FileWatcherService,代码行数:24,代码来源:Readers.cs

示例15: NullString2

		public void NullString2()
		{
			engine2 = new FileHelperAsyncEngine(typeof (SampleType));
			engine2.BeginReadString(null);
		}
开发者ID:BD-GitHub,项目名称:filehelpers,代码行数:5,代码来源:OtherErrors.cs


注:本文中的FileHelperAsyncEngine.BeginReadString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。