Esempio n. 1
0
 public Boolean RemoveFromVault(VaultIndex vaultIndex)
 {
     if (_vaults.Contains(vaultIndex))
     {
         _vaults.Remove(vaultIndex);
         Save();
         return(true);
     }
     else
     {
         return(false);
     }
 }
Esempio n. 2
0
        public static VaultIndex Prepare(string fullPath)
        {
            VaultIndex index = new VaultIndex(Guid.NewGuid().ToString(),
                                              String.Empty,
                                              String.Empty,
                                              SyncMode.LocalOnly,
                                              String.Empty,
                                              fullPath,
                                              String.Empty,
                                              true);

            return(index);
        }
Esempio n. 3
0
        public Boolean RemoveFromVault(Vault vault)
        {
            IEnumerable <VaultIndex> matchingVaults = _vaults.Where(vi => vi.ID == vault.ID);

            if (matchingVaults.Any())
            {
                VaultIndex vaultIndex = matchingVaults.First();
                _vaults.Remove(vaultIndex);
                Save();
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 4
0
        private static VaultIndexFile FromFile(String fullPath)
        {
            VaultIndexFile vaultIndexFile = new VaultIndexFile();

            vaultIndexFile._fullPath = fullPath;
            if (System.IO.File.Exists(vaultIndexFile._fullPath))
            {
                String  vaultIndexData = System.IO.File.ReadAllText(fullPath);
                JObject vaultIndexJSON = JObject.Parse(vaultIndexData);
                JArray  vaults         = vaultIndexJSON["Vaults"].Value <JArray>();
                foreach (JObject curVaultIndex in vaults)
                {
                    VaultIndex curIndex = VaultIndex.FromJSON(curVaultIndex);
                    vaultIndexFile._vaults.Add(curIndex);
                }
            }
            return(vaultIndexFile);
        }
Esempio n. 5
0
 public Boolean?DeleteFromVault(VaultIndex vaultIndex)
 {
     if (RemoveFromVault(vaultIndex))
     {
         try
         {
             System.IO.File.Delete(vaultIndex.FullPath);
             return(true);
         }
         catch
         {
             return(false);
         }
     }
     else
     {
         return(null);
     }
 }
Esempio n. 6
0
        public VaultIndex AddVaultToLocalVaultStoreIndex(Vault vault,
                                                         Common.SyncMode syncMode,
                                                         string provider,
                                                         string cloudProviderPath,
                                                         bool unopened)
        {
            VaultIndex vaultIndex = new VaultIndex(vault.ID,
                                                   vault.Name,
                                                   vault.Description,
                                                   syncMode,
                                                   provider,
                                                   vault.FullPath,
                                                   cloudProviderPath,
                                                   unopened);

            _vaults.Add(vaultIndex);
            Save();
            return(vaultIndex);
        }
Esempio n. 7
0
        public VaultIndex CreateLocalVaultStoreIndex(String name,
                                                     String description,
                                                     Common.SyncMode syncMode,
                                                     string provider,
                                                     String fullPath,
                                                     string cloudProviderPath)
        {
            VaultIndex vaultIndex = new VaultIndex(Guid.NewGuid().ToString(),
                                                   name,
                                                   description,
                                                   syncMode,
                                                   provider,
                                                   fullPath,
                                                   cloudProviderPath,
                                                   true);

            _vaults.Add(vaultIndex);
            Save();
            return(vaultIndex);
        }
Esempio n. 8
0
        public static VaultIndex FromJSON(JObject json)
        {
            string     id                = json["ID"].Value <string>();
            string     name              = json["Name"].Value <string>();
            string     description       = json["Description"].Value <string>();
            string     syncMode          = json["SyncMode"].Value <string>();
            string     provider          = json["Provider"].Value <string>();
            string     fullPath          = json["FullPath"].Value <string>();
            string     cloudProviderPath = json["CloudProviderPath"].Value <string>();
            bool       unopened          = json["Unopened"].Value <bool>();
            VaultIndex index             = new VaultIndex(id,
                                                          name,
                                                          description,
                                                          (SyncMode)Enum.Parse(typeof(SyncMode), syncMode),
                                                          provider,
                                                          fullPath,
                                                          cloudProviderPath,
                                                          unopened);

            return(index);
        }