GifDetector.cs 1002 B

123456789101112131415161718192021222324252627
  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.Video)]
  8. [FormatCategory(FormatCategory.Image)]
  9. internal sealed class GifDetector : AbstractSignatureDetector
  10. {
  11. private static readonly SignatureInformation[] GifSignatureInfo = {
  12. new() { Position = 0, Signature = "GIF87a"u8.ToArray() },
  13. new() { Position = 0, Signature = "GIF89a"u8.ToArray() },
  14. };
  15. public override string Extension => "gif";
  16. protected override SignatureInformation[] SignatureInformations => GifSignatureInfo;
  17. public override string MimeType => new MimeMapper().GetMimeFromExtension("." + Extension);
  18. public override List<FormatCategory> FormatCategories => GetType().GetCustomAttributes<FormatCategoryAttribute>().Select(a => a.Category).ToList();
  19. public override string ToString() => "Graphics Interchange Format Detector";
  20. }