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


C# FileHelperEngine.WriteStream方法代码示例

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


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

示例1: ExportStatus

 public void ExportStatus(TextWriter file, IList<StatusReport> reports)
 {
     var engine = new FileHelperEngine<StatusCsvItem>();
     var items = new List<StatusCsvItem>();
     // convert reports to items
     engine.WriteStream(file, items);
 }
开发者ID:dneigler,项目名称:Status-Again,代码行数:7,代码来源:CsvStatusEtl.cs

示例2: WriteStream

		public void WriteStream()
		{
			engine = new FileHelperEngine(typeof (SampleType));

			SampleType[] 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;

			StringBuilder sb = new StringBuilder();
			StringWriter writer = new StringWriter(sb);
			engine.WriteStream(writer, res, 1);

			Assert.AreEqual(14 + 2, sb.ToString().Length);
			Assert.AreEqual(sb.ToString(0, 8), DateTime.Now.AddDays(1).ToString("ddMMyyyy"));

		}
开发者ID:BD-GitHub,项目名称:filehelpers,代码行数:25,代码来源:WritersMaxRecords.cs

示例3: WriteOperationShouldBeQuick

        public void WriteOperationShouldBeQuick()
        {
            var sampleRecords = GetRecords();

            Benchmark.This("FileHelperEngine.WriteStream", () =>
            {
                var engine = new FileHelperEngine<FixedSampleRecord>();
                using (var stream = new MemoryStream())
                using (var streamWriter = new StreamWriter(stream))
                {
                    engine.WriteStream(streamWriter, sampleRecords);
                }
            })
                .Against.This("FlatFileEngine.Write", () =>
                {
                    var layout = new FixedSampleRecordLayout();
                    using (var stream = new MemoryStream())
                    {
                        var factory = new FixedLengthFileEngineFactory();

                        var flatFile = factory.GetEngine(layout);

                        flatFile.Write(stream, sampleRecords);
                    }
                })
                .WithWarmup(1000)
                .For(10000)
                .Iterations()
                .PrintComparison();
        }
开发者ID:mtherien,项目名称:FlatFile,代码行数:30,代码来源:FlatFileVsFileHelpersBenchmark.cs

示例4: ExportAllocations

 public void ExportAllocations(TextWriter file, IList<ResourceAllocation> reports)
 {
     var engine = new FileHelperEngine<ResourceAllocationCsvItem>();
     var items = new List<ResourceAllocationCsvItem>();
     // convert reports to items
     engine.WriteStream(file, items);
 }
开发者ID:dneigler,项目名称:Status-Again,代码行数:7,代码来源:CsvResourceAllocationEtl.cs

示例5: BigDataWriteOperationShouldBeQuick

        public void BigDataWriteOperationShouldBeQuick()
        {
            var genarator = new FakeGenarator();

            var sampleRecords = Enumerable.Range(0, 100000).Select(genarator.Generate).ToArray();

            Benchmark.This("FileHelperEngine.WriteStream", () =>
            {
                var engine = new FileHelperEngine<FixedSampleRecord>();
                using (var stream = new MemoryStream())
                using (var streamWriter = new StreamWriter(stream))
                {
                    engine.WriteStream(streamWriter, sampleRecords);
                }
            })
                .Against.This("FlatFileEngine.Write", () =>
                {
                    var layout = new FixedSampleRecordLayout();
                    using (var stream = new MemoryStream())
                    {
                        var factory = new FixedLengthFileEngineFactory();

                        var flatFile = factory.GetEngine(layout);

                        flatFile.Write(stream, sampleRecords);
                    }
                })
                .WithWarmup(10)
                .For(100)
                .Iterations()
                .PrintComparison();
        }
开发者ID:MedwayCouncil,项目名称:FlatFile,代码行数:32,代码来源:FlatFileVsFileHelpersBenchmark.cs

示例6: OnbtnExportClick

    protected void OnbtnExportClick(object sender, EventArgs e)
    {
        var students = retrieveStudents();
        if (students.Count < 1)
            return;

        List<StudentCSVImportItem> studentRows = students.Select(s => new StudentCSVImportItem()
                {
                    Classroom = s.ClassRoom,
                    FirstName = s.FirstName,
                    LastName = s.LastName
                }).ToList();

        studentRows.Insert(0, new StudentCSVImportItem() { FirstName = "First Name", LastName = "Last Name", Classroom = "Classroom" });
        FileHelperEngine<StudentCSVImportItem> engine = new FileHelperEngine<StudentCSVImportItem>();
        MemoryStream stream = new MemoryStream();
        TextWriter writer = new StreamWriter(stream);
        engine.WriteStream(writer, studentRows);
        writer.Close();

        HttpResponse response = Response;

        //Get data to output here...

        //Turn off Caching and enforce a content type that will prompt to download/save.
        response.AddHeader("Connection", "close");
        response.AddHeader("Cache-Control", "private");
        response.ContentType = "application/octect-stream";

        //Give the browser a hint at the name of the file.
        response.AddHeader("content-disposition", "attachment; filename=export.csv");

        response.BinaryWrite(stream.GetBuffer());

        response.Flush();
        response.Close();
    }
开发者ID:COCAGC,项目名称:CocaChild,代码行数:37,代码来源:CopyExistingSurvey.aspx.cs

示例7: WriteStream

        public void WriteStream()
        {
            var engine = new FileHelperEngine<SampleType>();

            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;

            var sb = new StringBuilder();
            var writer = new StringWriter(sb);
            engine.WriteStream(writer, res);

            Assert.AreEqual(14 + newLineLen + 14 + newLineLen, sb.ToString().Length);
            Assert.AreEqual(sb.ToString(0, 8), DateTime.Now.AddDays(1).ToString("ddMMyyyy"));
        }
开发者ID:calebillman,项目名称:FileHelpers,代码行数:24,代码来源:Writers.cs

示例8: NullRecords

		public void NullRecords()
		{
			engine = new FileHelperEngine(typeof (SampleType));
			engine.WriteStream(new StringWriter(new StringBuilder()), null);
		}
开发者ID:BD-GitHub,项目名称:filehelpers,代码行数:5,代码来源:OtherErrors.cs

示例9: NullWriter

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

示例10: NullWriter

 public void NullWriter()
 {
     engine = new FileHelperEngine(typeof (SampleType));
     Assert.Throws<ArgumentNullException>(()
         => engine.WriteStream(null, null));
 }
开发者ID:hoffmanc,项目名称:FileHelpers,代码行数:6,代码来源:OtherErrors.cs

示例11: NullRecords

 public void NullRecords()
 {
     engine = new FileHelperEngine(typeof (SampleType));
     Assert.Throws<ArgumentNullException>(()
         => engine.WriteStream(new StringWriter(new StringBuilder()), null));
 }
开发者ID:hoffmanc,项目名称:FileHelpers,代码行数:6,代码来源:OtherErrors.cs

示例12: WriteFile

        public bool WriteFile(string fileName, string devarOrgCode, FeederSystemFixedLengthRecord[] transactionsArray)
        {
            var success = false;
            using (var docStream = new MemoryStream())
            {
                using (var flatFileWriter = new StreamWriter(docStream, Encoding.ASCII))
                {
                    var fileWriterEngine = new FileHelperEngine(typeof(FeederSystemFixedLengthRecord));
                    fileWriterEngine.WriteStream(flatFileWriter, transactionsArray);

                    // Flush contents of fileWriterStream to underlying docStream:
                    flatFileWriter.Flush();

                    // Upload to SFTP server:
                    _sftpService.UploadStream(docStream, fileName, devarOrgCode); // Upload file to A&FS server.

                    // Save file to cloud:
                    _blobStorageService.PutBlob(docStream, fileName);
                    success = _blobStorageService.Exists(fileName);
                }

                return success;
            }
        }
开发者ID:ucdavis,项目名称:BenefitsAllocationUpload,代码行数:24,代码来源:FileService.cs

示例13: ReadDiscounts

        /// <summary>
        /// Helper method to read discounts
        /// </summary>
        private static void ReadDiscounts(AuthInfo authInfo, string csvFile)
        {
            List<Discount> discounts = new List<Discount>();
            DiscountsWrapper.ReadDiscounts(authInfo, discounts);

            Console.WriteLine("Writing Discounts to file...");
            using (TextWriter writer = new StreamWriter(csvFile))
            {
                // Write file header
                writer.WriteLine(Discount.CsvFileHeader);

                // Write discounts
                FileHelperEngine fileHelper = new FileHelperEngine(typeof(Discount));
                fileHelper.WriteStream(writer, discounts);
            }
        }
开发者ID:JamieS,项目名称:EzShopifyDiscounts,代码行数:19,代码来源:Program.cs


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