示例#1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="unknownTypeStorageDir">only unknown Serializable types will be saved to a new location</param>
 static public void Save(string unknownTypeStorageDir = null)
 {
     if (unknownTypeStorageDir != null)
     {
         if (ReadOnly && PathRoutines.ArePathsEqual(unknownTypeStorageDir, UnknownTypeStorageDir))
         {
             throw new Exception("Config is read-only and cannot be saved to the same location: " + unknownTypeStorageDir);
         }
     }
     UnknownTypeStorageDir = unknownTypeStorageDir;
     lock (objectFullNames2serializable)
     {
         foreach (Serializable s in objectFullNames2serializable.Values)
         {
             if (s is AppSettings)
             {
                 s.Save(AppSettings.StorageDir + System.IO.Path.DirectorySeparatorChar + PathRoutines.GetFileName(s.__File));
             }
             else if (s is UserSettings)
             {
                 s.Save(UserSettings.StorageDir + System.IO.Path.DirectorySeparatorChar + PathRoutines.GetFileName(s.__File));
             }
             else
             {
                 s.Save(UnknownTypeStorageDir + System.IO.Path.DirectorySeparatorChar + PathRoutines.GetFileName(s.__File));
             }
         }
     }
 }
示例#2
0
 static public void Save(string storageDir = null)
 {
     storageDir = storageDir != null ? storageDir : DefaultStorageDir;
     if (ReadOnly && PathRoutines.ArePathsEqual(storageDir, StorageDir))
     {
         throw new Exception("Config is read-only and cannot be saved to the same location.");
     }
     StorageDir = storageDir;
     lock (objectFullNames2serializable)
     {
         foreach (Serializable s in objectFullNames2serializable.Values)
         {
             s.Save(StorageDir + System.IO.Path.DirectorySeparatorChar + PathRoutines.GetFileNameFromPath(s.__File));
         }
     }
 }