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); }
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)); }
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(); }
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; }
private void AssignGroupsToFileContent(FavoritesFile file) { this.AssignStoresToFavorites(file.Favorites); this.AssignGroupsToFavorites(file.Groups); }
internal void AssignServices(FavoritesFile file) { this.AssignServices(file.Favorites); this.AssignServices(file.Groups); }