UTF-unknown icon indicating copy to clipboard operation
UTF-unknown copied to clipboard

Remove static methods from CharsetDetector, add an interface and create CharsetDetector.Instance

Open 304NotModified opened this issue 4 years ago • 1 comments

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) {...}

304NotModified avatar Oct 26 '21 20:10 304NotModified