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


C# TextWriter.WriteAsync方法代码示例

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

            }
        }
开发者ID:kaevans,项目名称:globalscaledemo,代码行数:25,代码来源:Helpers.cs

示例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()));
        }
开发者ID:tomastauer,项目名称:Tauco.Dicom,代码行数:16,代码来源:PatientTypeHandler.cs

示例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);
     }
 }
开发者ID:GrahamTheCoder,项目名称:Semver-AssemblyCompatibility,代码行数:10,代码来源:ApiNodeWriter.cs

示例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()
     );
 }
开发者ID:rivy,项目名称:MedallionShell,代码行数:16,代码来源:PipeHelpers.cs

示例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);
            }
        }
开发者ID:kaevans,项目名称:globalscaledemo,代码行数:54,代码来源:Functions.cs

示例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);
            }
        }
开发者ID:464884492,项目名称:Mvc,代码行数:19,代码来源:RazorView.cs

示例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");

		}
开发者ID:wfuser12,项目名称:log_webjobs_sample,代码行数:20,代码来源:Functions.cs

示例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()));
        }
开发者ID:tomastauer,项目名称:Tauco.Dicom,代码行数:26,代码来源:StudyTypeHandler.cs

示例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));
            }
        }
开发者ID:tomastauer,项目名称:Tauco.Dicom,代码行数:19,代码来源:StudyTypeHandler.cs

示例10: SayHello

 public async virtual Task SayHello(TextWriter writer)
 {
     await writer.WriteAsync("Hello World!");
 }
开发者ID:kswoll,项目名称:sexy-proxy,代码行数:4,代码来源:ReadMeTests.cs

示例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;
                    }
                }
            }
        }
开发者ID:phinq19,项目名称:git_example,代码行数:52,代码来源:ViewBuffer.cs

示例12: WriteLineStart

 private async Task WriteLineStart(IApiNodeComparison apiComparison, TextWriter file, int indentLevel)
 {
     file.WriteLine();
     await file.WriteAsync(ChangeTypeIndicator(apiComparison) + new string(' ', indentLevel * 2 + 1));
 }
开发者ID:GrahamTheCoder,项目名称:Semver-AssemblyCompatibility,代码行数:5,代码来源:ApiComparisonWriter.cs

示例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()));
        }
开发者ID:hangy,项目名称:openfoodfacts-category-web,代码行数:13,代码来源:LangFile.cs

示例14: AppendNewLine

 /// <summary>
 /// Append the NewLine string.
 /// </summary>
 public void AppendNewLine(TextWriter writer)
 {
     writer.WriteAsync(NewLine);
     ++Line;
     currentLineEmpty = true;
     Column = 0;
 }
开发者ID:hicknhack-software,项目名称:Twofold.Net,代码行数:10,代码来源:TextWriterController.cs

示例15: WriteListAsync

 private static async Task WriteListAsync(TextWriter writer, BufferEntryCollection values)
 {
     foreach (var value in values)
     {
         await writer.WriteAsync(value);
     }
 }
开发者ID:RehanSaeed,项目名称:Mvc,代码行数:7,代码来源:StringCollectionTextWriter.cs


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