コード例 #1
0
ファイル: FilePersistence.cs プロジェクト: wykpisz/Terminals
        public bool Initialize()
        {
            this.storedCredentials.Initialize();
            FavoritesFile file = this.LoadFile();

            this.groups.AddAllToCache(file.Groups.Cast <IGroup>().ToList());
            this.favorites.AddAllToCache(file.Favorites.Cast <IFavorite>().ToList());
            this.UpdateFavoritesInGroups(file.FavoritesInGroups);
            return(true);
        }
コード例 #2
0
        internal SerializationContext CreateDataFromCache(UnknonwPluginElements cachedUnknown)
        {
            var file = new FavoritesFile
            {
                Favorites         = this.favorites.Cast <Favorite>().ToArray(),
                Groups            = this.groups.Cast <Group>().ToArray(),
                FavoritesInGroups = this.GetFavoriteInGroups()
            };

            return(new SerializationContext(file, cachedUnknown));
        }
コード例 #3
0
ファイル: FilePersistence.cs プロジェクト: wykpisz/Terminals
        private void FavoritesFileChanged(object sender, EventArgs e)
        {
            FavoritesFile file = this.LoadFile();

            // dont report changes immediately, we have to wait till memberships are refreshed properly
            this.Dispatcher.StartDelayedUpdate();
            List <IGroup> addedGroups = this.groups.Merge(file.Groups.Cast <IGroup>().ToList());

            this.favorites.Merge(file.Favorites.Cast <IFavorite>().ToList());
            // first update also present groups assignment,
            // than send the favorite update also for present favorites
            List <IGroup> updated = this.UpdateFavoritesInGroups(file.FavoritesInGroups);

            updated = ListsHelper.GetMissingSourcesInTarget(updated, addedGroups);
            this.Dispatcher.ReportGroupsUpdated(updated);
            this.Dispatcher.EndDelayedUpdate();
        }
コード例 #4
0
 private FavoritesFile LoadFileContent()
 {
     string fileLocation = this.fileLocations.Favorites;
     object fileContent = Serialize.DeserializeXMLFromDisk(fileLocation, typeof(FavoritesFile));
     var file = fileContent as FavoritesFile;
     if (file == null)
         file = new FavoritesFile();
     this.AssignGroupsToFileContent(file);
     return file;
 }
コード例 #5
0
 private void AssignGroupsToFileContent(FavoritesFile file)
 {
     this.AssignStoresToFavorites(file.Favorites);
     this.AssignGroupsToFavorites(file.Groups);
 }
コード例 #6
0
 internal void AssignServices(FavoritesFile file)
 {
     this.AssignServices(file.Favorites);
     this.AssignServices(file.Groups);
 }