Exemplo n.º 1
0
        private SkyDriveFolder CreateSkyDriveFolderFromJson(FavoritesFolder folder)
        {
            var skyFolder = new SkyDriveFolder(folder.UniqueId, folder.Title, folder.Description, folder.Size, folder.Parent_id, SkyDriveItemType.Folder, folder.Updated_time, folder.Count);

            skyFolder.ImagePath = folder.ImagePath;
            skyFolder.SyncState = folder.SyncState;
            return(skyFolder);
        }
Exemplo n.º 2
0
 private void CopySkyDriveFolderToJson(SkyDriveFolder source, FavoritesFolder destination)
 {
     destination.Title              = source.Title;
     destination.UniqueId           = source.UniqueId;
     destination.Updated_time       = source.Updated_time;
     destination.Size               = source.Size;
     destination.Count              = source.Count;
     destination.ImagePath          = source.ImagePath;
     destination.Parent_id          = source.Parent_id;
     destination.Description        = source.Description;
     destination.ImageDominantColor = source.ImageDominantColor.ToString();
     destination.SyncState          = source.SyncState;
 }
Exemplo n.º 3
0
        public async override Task SaveData()
        {
            //skydrive folder to json schema
            FavoritesFolder    jsonFolder = new FavoritesFolder();
            SkyDriveDataSource source     = await SkyDriveDataSource.GetInstance();

            SkyDriveFolder rootFavoritesFolder;

            if (FolderCollection.TryGetValue(source.Root, out rootFavoritesFolder))
            {
                CopySkyDriveFolderToJson(rootFavoritesFolder, jsonFolder);
                PopulateJsonFromRootFavoritesFolder(rootFavoritesFolder, jsonFolder);
                string output = JsonConvert.SerializeObject(jsonFolder, Formatting.Indented);
                await Windows.Storage.FileIO.WriteTextAsync(storageFile, output);
            }
        }
Exemplo n.º 4
0
        private void populateFavoritesFromCache(FavoritesFolder folder)
        {
            var skyFolder = CreateSkyDriveFolderFromJson(folder);

            foreach (var item in folder.Items)
            {
                var file = CreateSkyDriveFileFromJson(item);
                skyFolder.Items.Add(file);
                FileCollection.Add(file.UniqueId, file);
            }
            foreach (var sourcefolder in folder.Subalbums)
            {
                var destinationfolder = CreateSkyDriveFolderFromJson(sourcefolder);
                skyFolder.Subalbums.Add(destinationfolder);
            }
            FolderCollection.Add(skyFolder.UniqueId, skyFolder);
            foreach (var sourcefolder in folder.Subalbums)
            {
                populateFavoritesFromCache(sourcefolder);
            }
        }
Exemplo n.º 5
0
 private void PopulateJsonFromRootFavoritesFolder(SkyDriveFolder skyFolder, FavoritesFolder folder)
 {
     folder.Subalbums = new List <FavoritesFolder>(skyFolder.Subalbums.Count);
     folder.Items     = new List <FavoritesFile>(skyFolder.Items.Count);
     foreach (var item in skyFolder.Items)
     {
         var favFile = new FavoritesFile();
         CopySkyDriveFileToJson(item, favFile);
         folder.Items.Add(favFile);
     }
     foreach (var item in skyFolder.Subalbums)
     {
         var            favFolder = new FavoritesFolder();
         SkyDriveFolder itemfolder;
         if (FolderCollection.TryGetValue(item.UniqueId, out itemfolder))
         {
             CopySkyDriveFolderToJson(itemfolder, favFolder);
             folder.Subalbums.Add(favFolder);
             PopulateJsonFromRootFavoritesFolder(itemfolder, favFolder);
         }
     }
 }