Skip to content

Instantly share code, notes, and snippets.

@CopperStarSystems
Created October 7, 2019 17:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CopperStarSystems/1ae59643bd8bf8163441cd7eaf8d486d to your computer and use it in GitHub Desktop.
Save CopperStarSystems/1ae59643bd8bf8163441cd7eaf8d486d to your computer and use it in GitHub Desktop.
FileReader.cs with Framework Wrapper
using System;
using Tdd.FrameworkWrappers.Lib.FrameworkWrappers;
namespace Tdd.FrameworkWrappers.Lib
{
public class FileReader
{
private readonly IFile file;
private readonly ILogger logger;
public FileReader(IFile file, ILogger logger)
{
this.file = file;
this.logger = logger;
}
public string ReadText(string filePath)
{
try
{
return file.ReadAllText(filePath);
}
catch (Exception e)
{
string message = $"Error reading file {filePath}";
logger.Log(LogLevelEnum.Error, message);
throw;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment