本文整理汇总了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);
}
示例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());
}
示例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());
}
示例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);
}
示例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);
}
示例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);
}