Exemplo n.º 1
0
        public async Task <AppContent> CreateNewAsync(string title)
        {
            CheckInitialized();
            var item = new AppContent {
                Id = Guid.NewGuid().ToString(), Title = title
            };

            Items.Add(item);
            await CreateActivityAsync(item);
            await SaveItemsAsync();

            return(item.Clone());
        }
Exemplo n.º 2
0
 public static AdaptiveCard ToAdaptiveCard(this AppContent self) => new AdaptiveCard
 {
     Version = "1.0",
     Body    =
     {
         new AdaptiveColumnSet
         {
             Columns =
             {
                 new AdaptiveColumn
                 {
                     Width = "auto",
                     Items =
                     {
                         new AdaptiveImage
                         {
                             Url   = new Uri("https://user-images.githubusercontent.com/79868/40269931-ed9022be-5bbf-11e8-83b9-e8cba533e405.jpg"),
                             Style = AdaptiveImageStyle.Person,
                             Size  = AdaptiveImageSize.Small,
                         }
                     }
                 },
                 new AdaptiveColumn
                 {
                     Width = "stretch",
                     Items =
                     {
                         new AdaptiveTextBlock
                         {
                             Weight   = AdaptiveTextWeight.Bolder,
                             Size     = AdaptiveTextSize.Large,
                             Wrap     = false,
                             MaxLines = 1,
                             Text     = self.Title ?? "",
                         },
                     }
                 }
             }
         },
         new AdaptiveTextBlock
         {
             Weight   = AdaptiveTextWeight.Default,
             Size     = AdaptiveTextSize.Default,
             Wrap     = true,
             MaxLines = 3,
             Text     = self.Content ?? "",
         }
     }
 };
Exemplo n.º 3
0
        private async Task CreateActivityAsync(AppContent target)
        {
            var channel  = UserActivityChannel.TryGetForWebAccount(Account);
            var activity = await channel.GetOrCreateUserActivityAsync(target.Id);

            activity.ActivationUri = new Uri($"decodedemo:?id={target.Id}");

            var card = target.ToAdaptiveCard();

            activity.VisualElements.Content     = AdaptiveCardBuilder.CreateAdaptiveCardFromJson(card.ToJson());
            activity.VisualElements.DisplayText = target.Title;

            await activity.SaveAsync();

            _currentActivity?.Dispose();
            _currentActivity = activity.CreateSession();
        }
Exemplo n.º 4
0
        public async Task AddOrUpdateDocumentAsync(AppContent appContent)
        {
            CheckInitialized();
            var target = Items.FirstOrDefault(x => x.Id == appContent.Id);

            if (target != null)
            {
                target.Title   = appContent.Title;
                target.Content = appContent.Content;
            }
            else
            {
                target    = appContent;
                target.Id = Guid.NewGuid().ToString();
            }

            await CreateActivityAsync(target);
            await SaveItemsAsync();
        }