ProtoMapAttribute.cs 1.1 KB

1234567891011121314151617181920212223242526272829
  1. using System;
  2. namespace ProtoBuf
  3. {
  4. /// <summary>
  5. /// Controls the formatting of elements in a dictionary, and indicates that
  6. /// "map" rules should be used: duplicates *replace* earlier values, rather
  7. /// than throwing an exception
  8. /// </summary>
  9. [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
  10. public class ProtoMapAttribute : Attribute
  11. {
  12. /// <summary>
  13. /// Describes the data-format used to store the key
  14. /// </summary>
  15. public DataFormat KeyFormat { get; set; }
  16. /// <summary>
  17. /// Describes the data-format used to store the value
  18. /// </summary>
  19. public DataFormat ValueFormat { get; set; }
  20. /// <summary>
  21. /// Disables "map" handling; dictionaries will use ".Add(key,value)" instead of "[key] = value",
  22. /// which means duplicate keys will cause an exception (instead of retaining the final value); if
  23. /// a proto schema is emitted, it will be produced using "repeated" instead of "map"
  24. /// </summary>
  25. public bool DisableMap { get; set; }
  26. }
  27. }