1
1

IconDetector.cs 893 B

12345678910111213141516171819202122232425
  1. using System.Collections.Generic;
  2. using System.IO;
  3. using System.Linq;
  4. using System.Reflection;
  5. using Masuit.Tools.Mime;
  6. namespace Masuit.Tools.Files.FileDetector.Detectors;
  7. [FormatCategory(FormatCategory.Image)]
  8. internal sealed class IconDetector : AbstractSignatureDetector
  9. {
  10. private static readonly SignatureInformation[] IcoSignatureInfo = {
  11. new() { Position = 0, Signature = new byte [] { 0x00, 0x00, 0x01, 0x00 } },
  12. };
  13. public override string Extension => "ico";
  14. protected override SignatureInformation[] SignatureInformations => IcoSignatureInfo;
  15. public override string MimeType => new MimeMapper().GetMimeFromExtension("." + Extension);
  16. public override List<FormatCategory> FormatCategories => GetType().GetCustomAttributes<FormatCategoryAttribute>().Select(a => a.Category).ToList();
  17. public override string ToString() => "Icon Detector";
  18. }