Beispiel #1
0
 /// <summary>
 /// Implement to provide data to the collection.
 /// </summary>
 protected sealed override void Update()
 {
     _context.Synchronize();
     if (_context.Data.CheckItems == null)
     {
         return;
     }
     foreach (var jsonCheckItem in _context.Data.CheckItems)
     {
         var checkItem = Items.SingleOrDefault(ci => ci.Id == jsonCheckItem.Id);
         if (checkItem == null)
         {
             Items.Add(new CheckItem(jsonCheckItem, _context.Data.Id));
         }
         else
         {
             checkItem.Json = jsonCheckItem;
         }
     }
     foreach (var checkItem in Items.ToList())
     {
         if (_context.Data.CheckItems.All(jci => jci.Id != checkItem.Id))
         {
             Items.Remove(checkItem);
         }
     }
 }
        /// <summary>
        /// Manually updates the collection's data.
        /// </summary>
        /// <param name="ct">(Optional) A cancellation token for async processing.</param>
        public sealed override async Task Refresh(CancellationToken ct = default(CancellationToken))
        {
            await _context.Synchronize(ct);

            if (_context.Data.CheckItems == null)
            {
                return;
            }
            foreach (var jsonCheckItem in _context.Data.CheckItems)
            {
                var checkItem = Items.SingleOrDefault(ci => ci.Id == jsonCheckItem.Id);
                if (checkItem == null)
                {
                    Items.Add(new CheckItem(jsonCheckItem, _context.Data.Id));
                }
                else
                {
                    ((CheckItem)checkItem).Json = jsonCheckItem;
                }
            }
            foreach (var checkItem in Items.ToList())
            {
                if (_context.Data.CheckItems.All(jci => jci.Id != checkItem.Id))
                {
                    Items.Remove(checkItem);
                }
            }
        }
        internal sealed override async Task PerformRefresh(bool force, CancellationToken ct)
        {
            await _context.Synchronize(force, ct);

            if (_context.Data.CheckItems == null)
            {
                return;
            }
            EventAggregator.Unsubscribe(this);
            foreach (var jsonCheckItem in _context.Data.CheckItems)
            {
                var checkItem = Items.SingleOrDefault(ci => ci.Id == jsonCheckItem.Id);
                if (checkItem == null)
                {
                    Items.Add(new CheckItem(jsonCheckItem, _context.Data.Id));
                }
                else
                {
                    ((CheckItem)checkItem).Json = jsonCheckItem;
                }
            }
            EventAggregator.Subscribe(this);

            foreach (var checkItem in Items.ToList())
            {
                if (_context.Data.CheckItems.All(jci => jci.Id != checkItem.Id))
                {
                    Items.Remove(checkItem);
                }
            }
        }
 /// <summary>
 /// Refreshes the checklist data.
 /// </summary>
 /// <param name="ct">(Optional) A cancellation token for async processing.</param>
 public async Task Refresh(CancellationToken ct = default(CancellationToken))
 {
     await _context.Synchronize(ct);
 }
Beispiel #5
0
 /// <summary>
 /// Refreshes the checklist data.
 /// </summary>
 /// <param name="force">Indicates that the refresh should ignore the value in <see cref="TrelloConfiguration.RefreshThrottle"/> and make the call to the API.</param>
 /// <param name="ct">(Optional) A cancellation token for async processing.</param>
 public Task Refresh(bool force = false, CancellationToken ct = default(CancellationToken))
 {
     return(_context.Synchronize(force, ct));
 }