Add MakefileDetector for text viewer

This commit is contained in:
ema
2025-07-09 03:24:42 +08:00
parent d6cc984267
commit 0a79d59c79
13 changed files with 220 additions and 14 deletions

View File

@@ -27,13 +27,16 @@ public class FormatDetector
[
new XMLDetector(),
new JSONDetector(),
new MakefileDetector(),
];
public static IFormatDetector Detect(string text)
public static IFormatDetector Detect(string path, string text)
{
_ = path;
if (string.IsNullOrWhiteSpace(text)) return null;
return Instance.TextDetectors.Where(detector => detector.Detect(text))
return Instance.TextDetectors.Where(detector => detector.Detect(path, text))
.FirstOrDefault();
}
}
@@ -44,5 +47,5 @@ public interface IFormatDetector
public string Extension { get; }
public bool Detect(string text);
public bool Detect(string path, string text);
}