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


C# StringWriter.WriteLineAsync方法代码示例

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


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

示例1: WriteAsync

        private static async Task WriteAsync(AdminProject project, Stream stream, CancellationToken cancellationToken)
        {
            var stringWriter = new StringWriter();
            await stringWriter.WriteLineAsync(string.Format("{0},{1},{2},{3},{4},{5},{6}",
                project.Id.ToCsvValue(),
                project.Name.ToCsvValue(),
                project.Created.ToCsvValue(),
                project.UserId.ToCsvValue(),
                project.UserName.ToCsvValue(),
                project.ProductType.ToCsvValue(),
                project.Product.ToCsvValue()));

            byte[] bytes = Encoding.UTF8.GetBytes(stringWriter.ToString());

            await stream.WriteAsync(bytes, 0, bytes.Length, cancellationToken);
            await stream.FlushAsync(cancellationToken);
        }
开发者ID:GusLab,项目名称:video-portal,代码行数:17,代码来源:ProjectForAdminCsvFormatter.cs

示例2: TestWriteLineAsyncCharArray

        public static void TestWriteLineAsyncCharArray()
        {
            StringWriter sw = new StringWriter();
            sw.WriteLineAsync(new char[] { 'H', 'e', 'l', 'l', 'o' });

            Assert.Equal("Hello" + Environment.NewLine, sw.ToString());
        }
开发者ID:Corillian,项目名称:corefx,代码行数:7,代码来源:StringWriterTests.cs

示例3: MiscWriteLineAsync

        public static async Task MiscWriteLineAsync()
        {
            var sw = new StringWriter();
            await sw.WriteLineAsync('H');
            await sw.WriteLineAsync(new char[] { 'e', 'l', 'l', 'o' });
            await sw.WriteLineAsync("World!");

            Assert.Equal(
                string.Format("H{0}ello{0}World!{0}", Environment.NewLine), 
                sw.ToString());
        }
开发者ID:Corillian,项目名称:corefx,代码行数:11,代码来源:StringWriterTests.cs

示例4: WriteAsync

        private static async Task WriteAsync(AdminClient client, Stream stream, CancellationToken cancellationToken)
        {
            var stringWriter = new StringWriter();
            await stringWriter.WriteLineAsync(string.Format("{0},{1},{2},{3},{4},{5}",
                client.Id.ToCsvValue(),
                client.Email.ToCsvValue(),
                client.Name.ToCsvValue(),
                client.Created.ToCsvValue(),
                (client.Balance/100).ToCsvValue(),
                client.State.ToCsvValue()));

            byte[] bytes = Encoding.UTF8.GetBytes(stringWriter.ToString());

            await stream.WriteAsync(bytes, 0, bytes.Length, cancellationToken);
            await stream.FlushAsync(cancellationToken);
        }
开发者ID:GusLab,项目名称:video-portal,代码行数:16,代码来源:ClientForAdminCsvFormatter.cs

示例5: PublishFileToDestinationAsync

        protected override async Task PublishFileToDestinationAsync(FileInfo sourceFile, DirectoryInfo destinationRoot, DocFile page)
        {
            this.LogMessage(new ValidationMessage(sourceFile.Name, "Publishing file to HTML"));

            var destinationPath = this.GetPublishedFilePath(sourceFile, destinationRoot, HtmlOutputExtension);

            StringWriter writer = new StringWriter();
            StreamReader reader = new StreamReader(sourceFile.OpenRead());

            long lineNumber = 0;
            string nextLine;
            while ((nextLine = await reader.ReadLineAsync()) != null)
            {
                lineNumber++;
                if (this.IsDoubleBlockQuote(nextLine))
                {
                    this.LogMessage(new ValidationMessage(string.Concat(sourceFile.Name, ":", lineNumber), "Removing DoubleBlockQuote"));
                    continue;
                }
                await writer.WriteLineAsync(nextLine);
            }

            var converter = this.GetMarkdownConverter();
            var html = converter.Transform(writer.ToString());

            var pageData = page.Annotation ?? new PageAnnotation();
            if (string.IsNullOrEmpty(pageData.Title))
            {
               pageData.Title = (from b in converter.Blocks
                             where b.BlockType == BlockType.h1
                             select b.Content).FirstOrDefault();
            }
            page.Annotation = pageData;
            await this.WriteHtmlDocumentAsync(html, page, destinationPath, destinationRoot.FullName);
        }
开发者ID:ahaadi,项目名称:markdown-scanner,代码行数:35,代码来源:DocumentPublisherHtml.cs

示例6: WriteAsync

        private static async Task WriteAsync(AdminUser user, Stream stream, CancellationToken cancellationToken)
        {
            var stringWriter = new StringWriter();

            // Memberships
            var membershipsBuilder = new StringBuilder();
            var memberships = user.Memberships;
            if (!string.IsNullOrEmpty(user.Email))
            {
                memberships.Insert(0, new DomainUserMembershipForAdmin { Identity = user.Email, Provider = ProviderType.Email.ToString() });
            }
            foreach (DomainUserMembershipForAdmin membership in memberships)
            {
                membershipsBuilder.AppendFormat("{0}: {1};", membership.Provider, membership.Identity);
            }

            // Storage space
            var usedStorageSpaceMegabytes = (int)Math.Round((double)user.UsedStorageSpace/1024/1024);
            var maximumStorageSpaceMegabytes = (int)Math.Round((double)user.MaximumStorageSpace/1024/1024);

            await stringWriter.WriteLineAsync(string.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8}",
                user.AppName.ToCsvValue(),
                user.Id.ToCsvValue(),
                user.UserName.ToCsvValue(),
                user.Created.ToCsvValue(),
                membershipsBuilder.ToCsvValue(),
                usedStorageSpaceMegabytes.ToCsvValue(),
                maximumStorageSpaceMegabytes.ToCsvValue(),
                user.VideosCount.ToCsvValue(),
                user.ProductName.ToCsvValue()));

            byte[] bytes = Encoding.UTF8.GetBytes(stringWriter.ToString());

            await stream.WriteAsync(bytes, 0, bytes.Length, cancellationToken);
            await stream.FlushAsync(cancellationToken);
        }
开发者ID:GusLab,项目名称:video-portal,代码行数:36,代码来源:UserForAdminCsvFormatter.cs


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