Esempio n. 1
0
        public void PrepareShutdownEventHandler(object sender, PrepareShutdownEventArgs e)
        {
            var services = from m in ShellModuleService.Modules
                           select ShellModuleService.GetWorkItem(m).Services.Get <IShellInteractionService>() as ShellInteractionService;

            foreach (ShellInteractionService service in services)
            {
                service.OnShellTerminating(e);

                if (e.Cancel)
                {
                    return;
                }
            }

            if (e.Logout)
            {
                AppDomain.CurrentDomain.SetData("Logout", new object());
            }

            _shellView.ShowProgress();

            try
            {
                SettingsService.SaveSettings();

                IFavoritesService favoritesServices = WorkItem.RootWorkItem.Services.Get <IFavoritesService>();
                favoritesServices.SaveFavorites();
            }
            catch
            {
            }
            finally
            {
                _shellView.HideProgress();

                try
                {
                    foreach (ShellInteractionService service in services)
                    {
                        service.OnShellTerminated(new EventArgs());
                    }
                }
                finally
                {
                    //WorkItem.Services.Get<IChannelFactoryService>().Dispose();
                }
            }
        }
Esempio n. 2
0
 private void LoadFavoritesDocument(NSMetadataQuery query)
 {
     if (query.ResultCount == 1)
     {
         var item = (NSMetadataItem)query.ResultAtIndex(0);
         var url  = (NSUrl)item.ValueForAttribute(NSMetadataQuery.ItemURLKey);
         _document = new FavoritesDocument(url);
         _document.Open(success =>
         {
             if (success && _document.Data != null)
             {
                 var favorites = _favoritesService.LoadFavorites();
                 if (favorites.LastUpdated < _document.Data.LastUpdated)
                 {
                     _favoritesService.SaveFavorites(_document.Data);
                 }
             }
         });
     }
     else if (query.ResultCount == 0)
     {
         SaveFavoritesDocument();
     }
 }