/// <summary> /// Check whether a given setting exists. /// </summary> /// <param name="name">The name of the record</param> /// <returns>True if the setting exists, false otherwise</returns> public async Task <bool> Exists(string name) { if (!LargeSettings.Contains(name)) { return(helper.Exists(name, Strategy)); } return(await FileHelper.FileExistsAsync(name, StorageStrategy)); }
/// <summary> /// Read the value of a given setting. /// </summary> /// <typeparam name="T">The type of the setting</typeparam> /// <param name="name">The name of the setting</param> /// <param name="otherwise">The default value to return if the setting is not found</param> /// <returns>The setting if found, `otherwise` if not</returns> public async Task <T> Read <T>(string name, T otherwise) { if (!LargeSettings.Contains(name)) { return(helper.Read <T>(name, otherwise, Strategy)); } var value = await FileHelper.ReadFileAsync <T>(name, StorageStrategy); return(value == null ? otherwise : value); }
/// <summary> /// Save a setting. /// </summary> /// <typeparam name="T">The type of the setting</typeparam> /// <param name="name">The name of the setting</param> /// <param name="value">The value of the setting</param> public async Task Write <T>(string name, T value) { if (!LargeSettings.Contains(name)) { helper.Write <T>(name, value, Strategy); } else { await FileHelper.WriteFileAsync <T>(name, value, StorageStrategy); } }
/// <summary> /// Remove a given setting. /// </summary> /// <param name="name">The name of the setting</param> public async Task Remove(string name) { if (!LargeSettings.Contains(name)) { helper.Remove(name, Strategy); } else { await FileHelper.DeleteFileAsync(name, StorageStrategy); } await Task.CompletedTask; }