internal Mime(string name, string format, MagicNumber[] magicNumbers = null) { Name = name ?? throw new ArgumentNullException(nameof(name)); Format = format ?? throw new ArgumentNullException(nameof(name)); Type = MediaTypeHelper.Parse(name.AsSpan().Slice(0, name.IndexOf('/'))); Signatures = magicNumbers ?? Array.Empty <MagicNumber>(); }
internal static bool TryGetFromName(string name, out Mime result) { int seperatorIndex = name.IndexOf('/'); var lhs = name.AsSpan().Slice(0, seperatorIndex); var rhs = name.Substring(seperatorIndex + 1); if (sets.TryGetValue(MediaTypeHelper.Parse(lhs), out var set)) { return(set.TryGetValue(rhs, out result)); } result = default; return(false); }