/// <summary> /// Retrieves an object from a file. /// </summary> /// <typeparam name="T">Type of object retrieved</typeparam> /// <param name="filePath">Path to the file that contains the object</param> /// <param name="default">Default value of the object</param> /// <returns>Waiting task until completion with the object in the file</returns> public async Task <T> ReadFileAsync <T>(string filePath, T @default = default(T)) { string value = await StorageFileHelper.ReadTextFromFileAsync(Folder, filePath); return((value != null) ? JsonConvert.DeserializeObject <T>(value) : @default); }
private async Task <T?> ReadFileAsync <T>(StorageFolder folder, string filePath, T? @default = default) { string value = await StorageFileHelper.ReadTextFromFileAsync(folder, filePath); return((value != null) ? this.Serializer.Deserialize <T>(value) : @default); }