public DetailedResponse <ToneAnalysis> AnalyzeTone(ContentMessage message)
        {
            var result = ToneAnalyzer.Tone(new ToneInput()
            {
                Text = message.ContentText
            }, sentences: true);

            return(result);
        }
Exemplo n.º 2
0
        public void Publish <TEvent>(TEvent @event) where TEvent : class, IEventMessage
        {
            var properties = new MessageProperties()
            {
                DeliveryMode = 2
            };
            var envelope = new ContentMessage(@event);
            var message  = new Message <ContentMessage>(envelope, properties);
            var bus      = RabbitHutch.CreateBus(ProviderConfiguration.StringConnection);

            bus.Publish(message);
        }
Exemplo n.º 3
0
        public static HttpResponseMessage ErrorResponseMessage(CommandResponse response)
        {
            //todo: don't return gibberish, make real messages for the enums (resx or something)
            var errorMessages = new ContentMessage
            {
                ErrorMessages = response.StatusCodes.Select(statusCode => statusCode.ToString()).ToList()
            };

            //todo: find a way to pick the media type formatter based on request accept headers.
            return(new HttpResponseMessage((HttpStatusCode)422)
            {
                Content = new ObjectContent(errorMessages.GetType(), errorMessages, new JsonMediaTypeFormatter())
            });
        }
Exemplo n.º 4
0
 /// <summary>
 /// Retrieves the body of a message as an UTF8 encoded string
 /// </summary>
 /// <param name="message"></param>
 /// <returns></returns>
 public static string GetMessageBodyString(this ContentMessage message)
 {
     return(System.Text.Encoding.UTF8.GetString(message.Data));
 }