Esempio n. 1
0
        public async Task <IList <Activity> > GetMessages()
        {
            var response = await _client.Conversations
                           .GetActivitiesAsync(_conversation.ConversationId, _watermark)
                           .ConfigureAwait(false);

            var cardAttachments = response.Activities
                                  .Where(m => m.Attachments != null)
                                  .SelectMany(m => m.Attachments)
                                  .Where(m => m.ContentType == "application/vnd.microsoft.card.adaptive");

            foreach (var attachment in cardAttachments)
            {
                var jObject = (JObject)attachment.Content;
                var card    = jObject.ToObject <AdaptiveCard>();

                Device.BeginInvokeOnMainThread(() =>
                {
                    var xaml = _renderer.RenderAdaptiveCard(card);

                    xaml.WidthRequest    = 350;
                    xaml.Margin          = new Thickness(8);
                    xaml.BackgroundColor = Color.LightGray;

                    Items.Children.Add(xaml);
                });
            }

            _watermark = response.Watermark;
            return(response.Activities);
        }