using System; using System.Collections.Generic; using System.Linq; namespace Discord.Serialization { public class ModelMap where TModel : class, new() { private BufferDictionary _dictionary; public PropertyMap[] Properties { get; } public ModelMap(List properties) { Properties = properties.ToArray(); _dictionary = new BufferDictionary(properties.ToDictionary(x => x.Utf8Key)); } public bool TryGetProperty(ReadOnlyBuffer key, out PropertyMap value) => _dictionary.TryGetValue(key, out value); public bool TryGetProperty(ReadOnlySpan key, out PropertyMap value) => _dictionary.TryGetValue(key, out value); } }