Ejemplo n.º 1
0
 void OnFolderContentsChanged(object sender, EmailFolderChangeEventArgs args)
 {
     if (args.ChangeType == EmailFolderChangeType.Added)
     {
         dispatcherService.Dispatch(() =>
         {
             Emails.Add(new MailViewModel(args.Email, emailService));
         });
     }
     else
     {
         dispatcherService.Dispatch(() =>
         {
             Emails.Remove(Emails.Where(e => e.Email.Id == args.Email.Id).Single());
         });
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Raises the can execute changed.
 /// </summary>
 public void RaiseCanExecuteChanged()
 {
     if (_dispatcherService == null)
     {
         return;
     }
     _dispatcherService.Dispatch(new Action(NotifyCanExecuteChanged));
 }
 private void GetItems()
 {
     service.GetModelItems((res, ex) => {
         //this is on a different thread so you need to synchronize
         dispService.Dispatch(() => {
             Items = res;
         });
     });
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Core logic of syntax analyzer.
        /// </summary>
        /// <param name="node">The node.</param>
        /// <param name="token">The token.</param>
        /// <param name="onlySubNodes">if set to <c>true</c> [only sub nodes].</param>
        /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
        private Task AnalyzeCore(SyntaxNode node, CancellationToken token, bool onlySubNodes = false)
        {
            RootNode.AnalyzeId = _analyzeId;

            // visit all members
            if (!onlySubNodes)
            {
                Visit(node);
            }
            else
            {
                foreach (var subNode in node.ChildNodes())
                {
                    if (token.IsCancellationRequested)
                    {
                        return(Task.FromResult(0));
                    }

                    Visit(subNode);
                }
            }

            // remove all sub-walkers which where not touched in analysis
            _subWalkers.RemoveAll(x => x._analyzeId != _analyzeId);
            if (onlySubNodes)
            {
                return(Task.FromResult(0));
            }

            _dispatcherService.Dispatch(() =>
            {
                var tree = RootNode.AllTreeItems.ToList();
                foreach (var unused in NodeList.Where(x => !tree.Contains(x)).ToList())
                {
                    _nodeList.Remove(unused);
                }

                foreach (var added in tree.Where(x => !NodeList.Contains(x)).ToList())
                {
                    _nodeList.Add(added);
                }
            });

            return(Task.FromResult(0));
        }