本文整理汇总了C#中System.IO.TextWriter.WriteAsync方法的典型用法代码示例。如果您正苦于以下问题:C# TextWriter.WriteAsync方法的具体用法?C# TextWriter.WriteAsync怎么用?C# TextWriter.WriteAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.TextWriter
的用法示例。
在下文中一共展示了TextWriter.WriteAsync方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateThumbnailAsync
internal static async Task CreateThumbnailAsync(StorageRepository repo, string fileName, TextWriter log)
{
using (var memStream = await repo.GetBlob(StorageConfig.PhotosBlobContainerName, fileName))
{
MemoryStream thumbnail = null;
try
{
thumbnail = PhotoEditor.ProcessImage(memStream);
await repo.UploadBlobAsync(thumbnail, StorageConfig.ThumbnailsBlobContainerName, fileName);
}
catch (Exception oops)
{
await log.WriteAsync(oops.Message);
throw oops;
}
finally
{
if (null != thumbnail)
{
thumbnail.Dispose();
}
}
}
}
示例2: HandleAllPatients
/// <summary>
/// Handles retrieving of all patients.
/// </summary>
/// <param name="inputArguments">Parsed program input arguments</param>
/// <param name="writer">Writer the serialized result will be written into</param>
/// <returns>Represents an asynchronous operation</returns>
private async Task HandleAllPatients(InputArguments inputArguments, TextWriter writer)
{
var query = mPatientInfoProvider.GetPatients();
if (inputArguments.UseCache)
{
query = query.LoadFromCache();
}
await writer.WriteAsync(JsonConvert.SerializeObject(await query.ToListAsync()));
}
示例3: Write
public async Task Write(IApiNode apiNode, TextWriter file, CancellationToken cancellationToken, bool recurse = true)
{
if (recurse) file.WriteLine(); //Indentation is only correct after a newline (note: WriteLineAsync doesn't seem to do indentation at all)
await file.WriteAsync($"{AccessibilityPrefix(apiNode)}{apiNode.Signature}");
if (recurse || ShouldWriteMembersInline(apiNode))
{
var orderedMembers = MembersInCanonicalOrder(apiNode);
await WriteMembers(apiNode, file, cancellationToken, orderedMembers);
}
}
示例4: CopyToAsync
public static Task CopyToAsync(this TextReader reader, TextWriter writer, bool leaveReaderOpen, bool leaveWriterOpen)
{
return reader.PipeAsync(
async () =>
{
var buffer = new char[Constants.CharBufferSize];
int charsRead;
while ((charsRead = await reader.ReadAsync(buffer, 0, buffer.Length).ConfigureAwait(false)) > 0)
{
await writer.WriteAsync(buffer, 0, charsRead).ConfigureAwait(false);
}
},
leaveOpen: leaveReaderOpen,
extraDisposeAction: leaveWriterOpen ? default(Action) : () => writer.Dispose()
);
}
示例5: ProcessQueueMessage
// This function will get triggered/executed when a new message is written
// on an Azure Queue called queue.
public static async Task ProcessQueueMessage(
[QueueTrigger("uploadqueue")] string message,
TextWriter log)
{
log.WriteLineAsync(message).Wait();
var m = message.Split(',');
await log.WriteAsync("Message received: " + m);
var model = new PhotoModel
{
ID = m[0],
ServerFileName = m[1],
StorageAccountName = m[2],
Owner = m[3],
OwnerName = m[4],
BlobURL = m[5],
OriginRegion = m[6]
};
//Copy blob from source to destination
await log.WriteAsync("Replicating blob...");
await Helpers.ReplicateBlobAsync(model, log);
try
{
//Change the blob URL to point to the new location!
await log.WriteAsync("Getting blob URIs");
string storageConnectionString = SettingsHelper.LocalStorageConnectionString;
var repo = new StorageRepository(storageConnectionString);
model.BlobURL = repo.GetBlobURI(model.ServerFileName, StorageConfig.PhotosBlobContainerName).ToString();
model.ThumbnailURL = repo.GetBlobURI(model.ServerFileName, StorageConfig.ThumbnailsBlobContainerName).ToString();
//Create thumbnail
await log.WriteAsync("Creating thumbnail");
await Helpers.CreateThumbnailAsync(repo, model.ServerFileName, log);
//Store in table storage
await log.WriteAsync("Saving to table storage");
await Helpers.SaveToTableStorageAsync(model, log);
//Add to Redis cache
await log.WriteAsync("Saving to Redis");
await Helpers.SaveToRedisAsync(model, log);
}
catch (Exception oops)
{
await log.WriteLineAsync(oops.Message);
}
}
示例6: RenderAsync
public virtual async Task RenderAsync(ViewContext context, TextWriter writer)
{
var contentBuilder = new StringBuilder(1024);
using (var bodyWriter = new StringWriter(contentBuilder))
{
Output = bodyWriter;
Execute();
}
string bodyContent = contentBuilder.ToString();
if (!String.IsNullOrEmpty(Layout))
{
await RenderLayoutAsync(context, writer, bodyContent);
}
else
{
await writer.WriteAsync(bodyContent);
}
}
示例7: ProcessMultipleParameterQueueMessage
public static async Task ProcessMultipleParameterQueueMessage([QueueTrigger("emailcontainer")] Email emailInfo, TextWriter logger)
{
var storageAccount = CloudStorageAccount.Parse(ConfigurationManager.ConnectionStrings["AzureWebJobsStorage"].ToString());
var blobClient = storageAccount.CreateCloudBlobClient();
var logBlobContainer = blobClient.GetContainerReference("emailinfos");
logBlobContainer.CreateIfNotExists();
CloudBlockBlob logBlob = logBlobContainer.GetBlockBlobReference("credentials.txt");
await logBlob.UploadTextAsync(emailInfo.ToString());
var mailMessage = new MailMessage(emailInfo.Sender, emailInfo.Receiver, emailInfo.Subject, emailInfo.Body);
var netCred = new NetworkCredential(emailInfo.Sender, "pfG6u_TDlGvoHQAeyn3xBQ");
var smtpobj = new SmtpClient("smtp.mandrillapp.com", 587);
smtpobj.EnableSsl = true;
smtpobj.Credentials = netCred;
smtpobj.Send(mailMessage);
await logger.WriteAsync("Web jobs for sending email succedded");
}
示例8: HandleMultipleStudies
/// <summary>
/// Handles retrieving of multiple studies.
/// </summary>
/// <param name="inputArguments">Parsed program input arguments</param>
/// <param name="writer">Writer the serialized result will be written into</param>
/// <returns>Represents an asynchronous operation</returns>
private async Task HandleMultipleStudies(InputArguments inputArguments, TextWriter writer)
{
IDicomQuery<StudyInfo> query;
if (inputArguments.ParentIdentifier != null)
{
var patient = await mPatientInfoProvider.GetPatientByBirthNumberAsync(inputArguments.ParentIdentifier, inputArguments.UseCache);
query = mStudyInfoProvider.GetStudiesForPatient(patient);
}
else
{
query = mStudyInfoProvider.GetStudies();
}
if (inputArguments.UseCache)
{
query = query.LoadFromCache();
}
await writer.WriteAsync(JsonConvert.SerializeObject(await query.ToListAsync()));
}
示例9: HandleSingleStudy
/// <summary>
/// Handles retrieving of single study or downloading images for single study.
/// </summary>
/// <param name="inputArguments">Parsed program input arguments</param>
/// <param name="writer">Writer the serialized result will be written into</param>
/// <returns>Represents an asynchronous operation</returns>
private async Task HandleSingleStudy(InputArguments inputArguments, TextWriter writer)
{
var study = await mStudyInfoProvider.GetStudyByIDAsync(inputArguments.Identifier, inputArguments.UseCache);
if (inputArguments.Download)
{
await mStudyInfoProvider.DownloadImagesAsync(study);
}
else
{
await writer.WriteAsync(JsonConvert.SerializeObject(study));
}
}
示例10: SayHello
public async virtual Task SayHello(TextWriter writer)
{
await writer.WriteAsync("Hello World!");
}
示例11: WriteToAsync
/// <summary>
/// Writes the buffered content to <paramref name="writer"/>.
/// </summary>
/// <param name="writer">The <see cref="TextWriter"/>.</param>
/// <param name="encoder">The <see cref="HtmlEncoder"/>.</param>
/// <returns>A <see cref="Task"/> which will complete once content has been written.</returns>
public async Task WriteToAsync(TextWriter writer, HtmlEncoder encoder)
{
if (BufferSegments == null)
{
return;
}
var htmlTextWriter = writer as HtmlTextWriter;
if (htmlTextWriter != null)
{
htmlTextWriter.Write(this);
return;
}
for (var i = 0; i < BufferSegments.Count; i++)
{
var segment = BufferSegments[i];
var count = i == BufferSegments.Count - 1 ? CurrentCount : segment.Length;
for (var j = 0; j < count; j++)
{
var value = segment[j];
var valueAsString = value.Value as string;
if (valueAsString != null)
{
await writer.WriteAsync(valueAsString);
continue;
}
var valueAsViewBuffer = value.Value as ViewBuffer;
if (valueAsViewBuffer != null)
{
await valueAsViewBuffer.WriteToAsync(writer, encoder);
continue;
}
var valueAsHtmlContent = value.Value as IHtmlContent;
if (valueAsHtmlContent != null)
{
valueAsHtmlContent.WriteTo(writer, encoder);
continue;
}
}
}
}
示例12: WriteLineStart
private async Task WriteLineStart(IApiNodeComparison apiComparison, TextWriter file, int indentLevel)
{
file.WriteLine();
await file.WriteAsync(ChangeTypeIndicator(apiComparison) + new string(' ', indentLevel * 2 + 1));
}
示例13: WriteParentAsync
private static async Task WriteParentAsync(TextWriter writer, TranslationSet parent, IComparer<CultureData> languageComparer)
{
var mostImportantTranslation = parent.Translations.Where(t => t.Words.Count > 0).OrderByDescending(t => t.Language, languageComparer).FirstOrDefault();
if (mostImportantTranslation == null)
{
return;
}
await writer.WriteAsync(Constants.ParentIndicator);
await writer.WriteAsync(mostImportantTranslation.Language.Name);
await writer.WriteAsync(Constants.LanguageSeparator);
await writer.WriteLineAsync(string.Join(Constants.TermSeparator + " ", mostImportantTranslation.Words.First()));
}
示例14: AppendNewLine
/// <summary>
/// Append the NewLine string.
/// </summary>
public void AppendNewLine(TextWriter writer)
{
writer.WriteAsync(NewLine);
++Line;
currentLineEmpty = true;
Column = 0;
}
示例15: WriteListAsync
private static async Task WriteListAsync(TextWriter writer, BufferEntryCollection values)
{
foreach (var value in values)
{
await writer.WriteAsync(value);
}
}