/// <summary> /// Saves an object inside a file. /// There is no limitation to use this method (refers to <see cref="Save{T}(string, T)"/> method for simple objects). /// </summary> /// <typeparam name="T">Type of object saved</typeparam> /// <param name="filePath">Path to the file that will contain the object</param> /// <param name="value">Object to save</param> /// <returns>The <see cref="StorageFile"/> where the object was saved</returns> public Task <StorageFile> SaveFileAsync <T>(string filePath, T value) { return(StorageFileHelper.WriteTextToFileAsync(Folder, serializer.Serialize(value)?.ToString(), filePath, CreationCollisionOption.ReplaceExisting)); }
/// <summary> /// Saves an object inside a file. /// There is no limitation to use this method (refers to <see cref="Save{T}(string, T)"/> method for simple objects). /// </summary> /// <typeparam name="T">Type of object saved</typeparam> /// <param name="filePath">Path to the file that will contain the object</param> /// <param name="value">Object to save</param> /// <returns>The <see cref="StorageFile"/> where the object was saved</returns> public Task <StorageFile> SaveFileAsync <T>(string filePath, T value) { return(StorageFileHelper.WriteTextToFileAsync(Folder, JsonConvert.SerializeObject(value), filePath, CreationCollisionOption.ReplaceExisting)); }
private async Task <StorageFile> CreateFileAsync <T>(StorageFolder folder, string filePath, T value) { return(await StorageFileHelper.WriteTextToFileAsync(folder, Serializer.Serialize(value)?.ToString(), NormalizePath(filePath), CreationCollisionOption.ReplaceExisting)); }