Created
July 29, 2013 14:38
-
-
Save hagbarddenstore/6104769 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface ILogger | |
{ | |
void Log(string message); | |
} | |
class WriteToLogFile | |
{ | |
private string _logFilePath; | |
public string LogFilePath | |
{ | |
get | |
{ | |
if (string.IsNullOrEmpty(_logFilePath)) | |
{ | |
_logFilePath = ConfigurationManager.AppSettings["LogFilePath"]; | |
} | |
return _logFilePath; | |
} | |
set | |
{ | |
_logFilePath = value; | |
} | |
} | |
public void Log(string message) | |
{ | |
// TODO: Implement the actual logging stuff... | |
} | |
} | |
class MyController : Controller | |
{ | |
private ILogger _logger; | |
public MyController(ILogger logger) | |
{ | |
_logger = logger; | |
} | |
public ActionResult Log(string message) | |
{ | |
_logger.Log(message); | |
return Content("It was logged!"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment