You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

ModelMap.cs 1.0 kB

123456789101112131415161718192021222324252627282930313233
  1. using System;
  2. using System.Collections.Generic;
  3. namespace Discord.Serialization
  4. {
  5. public class ModelMap
  6. {
  7. private readonly List<PropertyMap> _propList;
  8. private readonly BufferDictionary<PropertyMap> _propDict;
  9. public string Path { get; }
  10. public bool HasDynamics { get; }
  11. public IReadOnlyList<PropertyMap> Properties => _propList;
  12. internal ModelMap(string path)
  13. {
  14. Path = path;
  15. _propList = new List<PropertyMap>();
  16. _propDict = new BufferDictionary<PropertyMap>();
  17. }
  18. internal void AddProperty(PropertyMap propMap)
  19. {
  20. _propList.Add(propMap);
  21. _propDict.Add(propMap.Utf8Key, propMap);
  22. }
  23. public bool TryGetProperty(ReadOnlyBuffer<byte> key, out PropertyMap value)
  24. => _propDict.TryGetValue(key, out value);
  25. public bool TryGetProperty(ReadOnlySpan<byte> key, out PropertyMap value)
  26. => _propDict.TryGetValue(key, out value);
  27. }
  28. }