예제 #1
0
 /// <summary>
 /// Delete saved file from disk
 /// </summary>
 /// <param name="filename"></param>
 /// <param name="folder"></param>
 public void DeleteSave(string filename, string folder = null)
 {
     if (string.IsNullOrEmpty(folder))
     {
         folder = defaultFolder;
     }
     SaveLoadUtility.DeleteSavedFile(filename, folder, baseFolder);
 }
예제 #2
0
 /// <summary>
 /// Gets the list of save files that have been created
 /// </summary>
 /// <param name="folder">sub folder</param>
 /// <returns>list of file names (excludes the path)</returns>
 public string[] GetFiles(string folder = null)
 {
     if (string.IsNullOrEmpty(folder))
     {
         folder = defaultFolder;
     }
     return(SaveLoadUtility.GetSavedFiles(folder, baseFolder));
 }
예제 #3
0
        /// <summary>
        /// Load an object from disk
        /// </summary>
        /// <param name="type">Type of object to be loaded</param>
        /// <param name="filename">Name of file to load object from</param>
        /// <param name="folder">Name of folder containing the file to be loaded</param>
        /// <returns>Instance of object to be loaded. Null if file did not exist.</returns>
        public object Load(Type type, string filename, string folder = null)
        {
            if (string.IsNullOrEmpty(folder))
            {
                folder = defaultFolder;
            }
            var saveLoadMethod = GetSaveLoadMethod(saveMethod);

            return(SaveLoadUtility.Load(type, saveLoadMethod, filename, folder, baseFolder));
        }
예제 #4
0
        /// <summary>
        /// Save an object to disk
        /// </summary>
        /// <param name="obj">object to be saved</param>
        /// <param name="filename">Name of file that will be written to</param>
        /// <param name="folder">Name of the folder that should contain the file</param>
        public void Save(object obj, string filename, string folder = null)
        {
            if (string.IsNullOrEmpty(folder))
            {
                folder = defaultFolder;
            }
            var saveLoadMethod = GetSaveLoadMethod(saveMethod);

            SaveLoadUtility.Save(obj, saveLoadMethod, filename, folder, baseFolder);
        }
예제 #5
0
        /// <summary>
        /// Load object from file and specify the method of save/load
        /// </summary>
        /// <param name="methodType">Method to be used to save the file to disk.</param>
        /// <param name="filename">Name of file to be read from.</param>
        /// <param name="folder">Name of the folder containing the file.</param>
        /// <typeparam name="T">Type of object to be loaded from the file.</typeparam>
        /// <returns>Object instance loaded from file. Null if file does not exist or load failed.</returns>
        public object LoadWithMethod(SerializationMethodType methodType, Type type, string filename, string folder = null)
        {
            var saveLoadMethod = GetSaveLoadMethod(methodType);

            return(SaveLoadUtility.Load(type, saveLoadMethod, filename, folder));
        }
예제 #6
0
        /// <summary>
        /// Save object to file and specify the method of save/load
        /// </summary>
        /// <param name="methodType">Method to be used to save the file to disk.</param>
        /// <param name="obj">Object to be written to disk.</param>
        /// <param name="filename">Name of file to write to.</param>
        /// <param name="folder">Name of folder to save to. If null the default folder will be used.</param>
        public void SaveWithMethod(SerializationMethodType methodType, object obj, string filename, string folder = null)
        {
            var saveLoadMethod = GetSaveLoadMethod(methodType);

            SaveLoadUtility.Save(obj, saveLoadMethod, filename, folder);
        }