예제 #1
0
        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;
            }
        }
예제 #2
0
        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);
        }