Example #1
0
        public static void WriteWallpapersList(string path, WallpapersManifest manifest)
        {
            JObject jsonData = new JObject();

            jsonData["nextID"] = manifest.nextID;
            JArray wallpapers = new JArray();

            foreach (var each in manifest.list)
            {
                string wallpaper = JsonConvert.SerializeObject(each);
                wallpapers.Add(JObject.Parse(wallpaper));
            }
            jsonData["wallpapers"] = wallpapers;

            string data = JsonConvert.SerializeObject(jsonData);

            SettingsUtil.WriteSettingsAsString(path, data);
        }
Example #2
0
        public static WallpapersManifest GetWallpapersList(string path)
        {
            string jsonData = SettingsUtil.ReadSettingsAsString(path);
            List <WallpaperManifestItem> list = new List <WallpaperManifestItem>();
            JObject obj  = JObject.Parse(jsonData);
            JArray  data = (JArray)obj["wallpapers"];

            if (data != null && data.Count > 0)
            {
                foreach (var item in data)
                {
                    list.Add(JsonConvert.DeserializeObject <WallpaperManifestItem>(item.ToString()));
                }
            }

            WallpapersManifest wallpaperManifest = new WallpapersManifest();

            wallpaperManifest.list   = list;
            wallpaperManifest.nextID = (int)obj["nextID"];
            return(wallpaperManifest);
        }