private async Task ProcessarImagemAsync(IDialogContext contexto) //IAwaitable<IMessageActivity> argument { var activity = contexto.Activity as Activity; var hasAttachment = activity.Attachments?.Any() == true; var uri = string.Empty; IExtractHttpContent content = null; if (hasAttachment) { uri = activity.Attachments[0].ContentUrl; content = new StreamFileContent(uri); } else { uri = activity.Text; content = new UriFileContent(uri); } try { customVision = new CustomVision(content, StorageProvider, RetrievalProvider); var reply = await customVision.ProcessImage(); await contexto.PostAsync(reply); contexto.Wait((c, a) => customVision.StoreImage()); } catch (Exception) { await contexto.PostAsync("Ops! Deu algo errado na hora de analisar sua imagem!"); } }
public async Task ToContent_returns_valid_content(string testContent) { Stream stream = new MemoryStream(Encoding.UTF8.GetBytes(testContent)); var fileContent = new StreamFileContent(stream); var httpContent = fileContent.ToContent(); httpContent.ShouldNotBeNull(); var actualValue = await httpContent.ReadAsStringAsync(); actualValue.ShouldBe(testContent); }