Remove static methods from CharsetDetector, add an interface and create CharsetDetector.Instance
304NotModified opened this issue · comments
Julian Verdurmen commented
For mocking.
e.g.
interface ICharsetDetector
{
DetectionResult DetectFromBytes(byte[] bytes);
DetectionResult DetectFromBytes(byte[] bytes, int offset, int len);
DetectionResult DetectFromStream(Stream stream);
DetectionResult DetectFromStream(Stream stream, long? maxBytesToRead);
}
public class CharsetDetector
{
public ICharsetDetector Instance => _instance;
}
and move to extensions for SRP:
public static class CharsetDetectorFileExtensions
{
public static DetectionResult DetectFromFile(this ICharsetDetector detector, string filePath) {...}
public static DetectionResult DetectionResult DetectFromFile(this ICharsetDetector detector, FileInfo file) {...}