January 2017
Intermediate to advanced
314 pages
6h 42m
English
To manage the complexity of code isolation, let's declare a C# interface which will manage the idiosyncrasies of multiple log targets:
public interface IContentWriter
{
Task<bool> Write(string content);
}
The basic idea here, is that the concrete classes which implement the interface should provide an implementation of this method that writes the log to the respective media. But on closer inspection, we find that it is better to write a base class implementation of this method and its associated semantics in an abstract class. The base class implementation can add a log entry to a queue (that would give concurrency support), flush the queue, and persist to target the media when a threshold (configured) is reached. A ...
Read now
Unlock full access