當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。