public static void ClearStorage(StorageBase s)
 {
     if (s != null)
     {
         if (s.Count() <= 0)
         {
             return;
         }
         s.Clear();
         s.Save();
     }
 }
        public static async Task <bool> RestoreStorage(StorageBase s, string url = null)
        {
            if (string.IsNullOrWhiteSpace(url))
            {
                string backupName = s.GetPath() + ".bk";
                if (!File.Exists(backupName))
                {
                    return(false);
                }

                s.Load(backupName);
                s.Save();
                return(true);
            }

            using (WebClient wc = new WebClient())
            {
                try
                {
                    await wc.DownloadFileTaskAsync(url, s.GetPath());
                }
                catch (Exception)
                {
                    return(false);
                }

                if (!File.Exists(s.GetPath()))
                {
                    return(false);
                }

                s.Load();
                s.Save();
            }

            return(true);
        }
        private static bool Validate(StorageBase s)
        {
            if (s == null)
            {
                return(false);
            }

            if (CreateEmptyIfNeeded(s.GetPath()))
            {
                if (s.Count() > 0)
                {
                    s.Save();
                }
                return(false);
            }

            return(true);
        }