public async Task PersistAsync(string data, InOutOptions options) { string sourcePath = GetType() .GetField(options.ToString(), BindingFlags.NonPublic | BindingFlags.Instance) .GetValue(this) as string; try { await File.WriteAllTextAsync(sourcePath, data, Token); } catch (System.Exception) { _logger.Log(LogLevel.Error, $"Failed to write to '{sourcePath}'! Check if this process has the required IO persmissions!"); throw; } }
public async Task <string> FetchAsync(InOutOptions options) { string sourcePath = GetType() .GetField(options.ToString(), BindingFlags.NonPublic | BindingFlags.Instance) .GetValue(this) as string; string result; try { result = await File.ReadAllTextAsync(sourcePath, Token); } catch (System.Exception) { _logger.Log(LogLevel.Error, $"Failed to read from '{sourcePath}'! Check if the file exists, or if this process has the required IO persmissions!"); throw; } return(result); }