WriteAsync() public méthode

public WriteAsync ( char value ) : Task
value char
Résultat Task
Exemple #1
0
        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();
                    }
                }

            }
        }
        /// <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()));
        }
 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);
     }
 }
Exemple #4
0
 private void write(string title, IList <Diagnostic> errors)
 {
     if (errors.Count > 0)
     {
         writer.WriteAsync(errors.Count.ToString());
     }
     else
     {
         writer.WriteAsync("No");
     }
     writer.WriteAsync(" error");
     if (errors.Count > 1)
     {
         writer.WriteAsync('s');
     }
     writer.WriteAsync(" in \"");
     writer.WriteAsync(title);
     if (errors.Count > 0)
     {
         writer.WriteLineAsync("\":");
         foreach (var e in errors)
         {
             writer.WriteLine(e.ToString());
         }
     }
     else
     {
         writer.WriteLineAsync("\".");
     }
 }
Exemple #5
0
    static int WriteAsync(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 2 && TypeChecker.CheckTypes <char>(L, 2))
            {
                System.IO.TextWriter obj = (System.IO.TextWriter)ToLua.CheckObject <System.IO.TextWriter>(L, 1);
                char arg0 = (char)LuaDLL.lua_tonumber(L, 2);
                System.Threading.Tasks.Task o = obj.WriteAsync(arg0);
                ToLua.PushObject(L, o);
                return(1);
            }
            else if (count == 2 && TypeChecker.CheckTypes <string>(L, 2))
            {
                System.IO.TextWriter obj = (System.IO.TextWriter)ToLua.CheckObject <System.IO.TextWriter>(L, 1);
                string arg0 = ToLua.ToString(L, 2);
                System.Threading.Tasks.Task o = obj.WriteAsync(arg0);
                ToLua.PushObject(L, o);
                return(1);
            }
            else if (count == 2 && TypeChecker.CheckTypes <char[]>(L, 2))
            {
                System.IO.TextWriter obj = (System.IO.TextWriter)ToLua.CheckObject <System.IO.TextWriter>(L, 1);
                char[] arg0 = ToLua.CheckCharBuffer(L, 2);
                System.Threading.Tasks.Task o = obj.WriteAsync(arg0);
                ToLua.PushObject(L, o);
                return(1);
            }
            else if (count == 4)
            {
                System.IO.TextWriter obj = (System.IO.TextWriter)ToLua.CheckObject <System.IO.TextWriter>(L, 1);
                char[] arg0 = ToLua.CheckCharBuffer(L, 2);
                int    arg1 = (int)LuaDLL.luaL_checknumber(L, 3);
                int    arg2 = (int)LuaDLL.luaL_checknumber(L, 4);
                System.Threading.Tasks.Task o = obj.WriteAsync(arg0, arg1, arg2);
                ToLua.PushObject(L, o);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: System.IO.TextWriter.WriteAsync"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Exemple #6
0
 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()
     );
 }
Exemple #7
0
        // 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);
            }
        }
Exemple #8
0
        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);
            }
        }
		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");

		}
Exemple #10
0
        private static async Task GenerujTrescFormularza(IHtmlHelper helper, string actionName,
                                                         string controllerName, System.IO.TextWriter writer,
                                                         object model,
                                                         string akcjaAnuluj = null)
        {
            using (helper.BeginForm(actionName, controllerName, FormMethod.Post,
                                    new { enctype = "multipart/form-data" }))
            {
                helper.AntiForgeryToken();
                await writer.WriteLineAsync("<div class=\"form-horizontal\">");

                await writer.WriteLineAsync("<hr/>");

                writer.WriteLine(helper.ValidationSummary(true, "", new { @class = "text-danger" }));

                helper.DopiszEdytoryDlaPropertiesow(model, writer);
                helper.GenerujPrzyciskiFormularza(akcjaAnuluj).WriteTo(writer, HtmlEncoder.Default);

                await writer.WriteAsync("</div>");
            }
        }
Exemple #11
0
        /// <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;
                    }
                }
            }
        }
Exemple #12
0
            static async Task WriteStackItemAsync(System.IO.TextWriter writer, Neo.VM.Types.StackItem item, int indent = 1, string prefix = "")
            {
                switch (item)
                {
                case Neo.VM.Types.Boolean _:
                    await WriteLineAsync(item.GetBoolean()? "true" : "false").ConfigureAwait(false);

                    break;

                case Neo.VM.Types.Integer @int:
                    await WriteLineAsync(@int.GetInteger().ToString()).ConfigureAwait(false);

                    break;

                case Neo.VM.Types.Buffer buffer:
                    await WriteLineAsync(Neo.Helper.ToHexString(buffer.GetSpan())).ConfigureAwait(false);

                    break;

                case Neo.VM.Types.ByteString byteString:
                    await WriteLineAsync(Neo.Helper.ToHexString(byteString.GetSpan())).ConfigureAwait(false);

                    break;

                case Neo.VM.Types.Null _:
                    await WriteLineAsync("<null>").ConfigureAwait(false);

                    break;

                case Neo.VM.Types.Array array:
                    await WriteLineAsync($"Array: ({array.Count})").ConfigureAwait(false);

                    for (int i = 0; i < array.Count; i++)
                    {
                        await WriteStackItemAsync(writer, array[i], indent + 1).ConfigureAwait(false);
                    }
                    break;

                case Neo.VM.Types.Map map:
                    await WriteLineAsync($"Map: ({map.Count})").ConfigureAwait(false);

                    foreach (var m in map)
                    {
                        await WriteStackItemAsync(writer, m.Key, indent + 1, "key:   ").ConfigureAwait(false);
                        await WriteStackItemAsync(writer, m.Value, indent + 1, "value: ").ConfigureAwait(false);
                    }
                    break;
                }

                async Task WriteLineAsync(string value)
                {
                    for (var i = 0; i < indent; i++)
                    {
                        await writer.WriteAsync("  ").ConfigureAwait(false);
                    }

                    if (!string.IsNullOrEmpty(prefix))
                    {
                        await writer.WriteAsync(prefix).ConfigureAwait(false);
                    }

                    await writer.WriteLineAsync(value).ConfigureAwait(false);
                }
            }
 private async Task WriteLineStart(IApiNodeComparison apiComparison, TextWriter file, int indentLevel)
 {
     file.WriteLine();
     await file.WriteAsync(ChangeTypeIndicator(apiComparison) + new string(' ', indentLevel * 2 + 1));
 }
Exemple #14
0
 public override Task WriteAsync(char value)
 {
     lock (this) {
         return(writer.WriteAsync(value));
     }
 }
 /// <summary>
 /// Append the NewLine string.
 /// </summary>
 public void AppendNewLine(TextWriter writer)
 {
     writer.WriteAsync(NewLine);
     ++Line;
     currentLineEmpty = true;
     Column = 0;
 }
        /// <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()));
        }
        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()));
        }
 private async Task WriteAutogeneratedShortnamesInline(TextWriter file, CancellationToken cancellationToken, IOrderedEnumerable<IApiNode> orderedMembers)
 {
     var accessibleMembers = orderedMembers.Select(GetShortNameFromAutoGeneratedMember);
     var memberString = $" {{ {string.Join("; ", accessibleMembers)}; }}";
     await file.WriteAsync(memberString);
 }
        /// <summary>
        /// Handles retrieving of multiple series.
        /// </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 HandleMultipleSeries(InputArguments inputArguments, TextWriter writer)
        {
            IDicomQuery<SeriesInfo> query;
            if (inputArguments.ParentIdentifier != null)
            {
                var study = await mStudyInfoProvider.GetStudyByIDAsync(inputArguments.ParentIdentifier, inputArguments.UseCache);
                query = mSeriesInfoProvider.GetSeriesForStudy(study);
            }
            else
            {
                query = mSeriesInfoProvider.GetSeries();
            }

            if (inputArguments.UseCache)
            {
                query = query.LoadFromCache();
            }

            await writer.WriteAsync(JsonConvert.SerializeObject(await query.ToListAsync()));
        }
 /// <summary>
 /// Handles retrieving of single series.
 /// </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 HandleSingleSeries(InputArguments inputArguments, TextWriter writer)
 {
     var series = await mSeriesInfoProvider.GetSeriesByIDAsync(inputArguments.Identifier, inputArguments.UseCache);
     await writer.WriteAsync(JsonConvert.SerializeObject(series));
 }
Exemple #21
0
		public async Task WritePrivateAsync(TextWriter writer) {
			await writer.WriteAsync(PrivateDataAsJson());
		}
Exemple #22
0
 public async virtual Task SayHello(TextWriter writer)
 {
     await writer.WriteAsync("Hello World!");
 }
        /// <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));
            }
        }
        /// <summary>
        /// Handles retrieving of single patient or downloading images for single patient.
        /// </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 HandleSinglePatient(InputArguments inputArguments, TextWriter writer)
        {
            var patient = await mPatientInfoProvider.GetPatientByBirthNumberAsync(inputArguments.Identifier, inputArguments.UseCache);

            if (inputArguments.Download)
            {
                await mPatientInfoProvider.DownloadImagesAsync(patient);
            }
            else
            {
                await writer.WriteAsync(JsonConvert.SerializeObject(patient));
            }
        }
 private static async Task WriteListAsync(TextWriter writer, BufferEntryCollection values)
 {
     foreach (var value in values)
     {
         await writer.WriteAsync(value);
     }
 }
        private static async Task WriteToAsync(TextWriter writer, string prefix, LanguageWordList wordList)
        {
            if (wordList.Words.Count == 0)
            {
                return;
            }

            if (!string.IsNullOrWhiteSpace(prefix))
            {
                await writer.WriteAsync(prefix);
                await writer.WriteAsync(Constants.PrefixSeparator);
            }

            await writer.WriteAsync(wordList.Language.Name);
            await writer.WriteAsync(Constants.LanguageSeparator);
            await writer.WriteLineAsync(string.Join(Constants.TermSeparator + " ", wordList.Words));
        }