MessageFormatOptions.cs 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. using System;
  2. namespace Google.ProtocolBuffers.Serialization
  3. {
  4. /// <summary>
  5. /// Defines control information for the various formatting used with HTTP services
  6. /// </summary>
  7. public struct MessageFormatOptions
  8. {
  9. /// <summary>The mime type for xml content</summary>
  10. /// <remarks>Other valid xml mime types include: application/binary, application/x-protobuf</remarks>
  11. public const string ContentTypeProtoBuffer = "application/vnd.google.protobuf";
  12. /// <summary>The mime type for xml content</summary>
  13. /// <remarks>Other valid xml mime types include: text/xml</remarks>
  14. public const string ContentTypeXml = "application/xml";
  15. /// <summary>The mime type for json content</summary>
  16. /// <remarks>
  17. /// Other valid json mime types include: application/json, application/x-json,
  18. /// application/x-javascript, text/javascript, text/x-javascript, text/x-json, text/json
  19. /// </remarks>
  20. public const string ContentTypeJson = "application/json";
  21. private string _defaultContentType;
  22. private string _xmlReaderRootElementName;
  23. private string _xmlWriterRootElementName;
  24. private ExtensionRegistry _extensionRegistry;
  25. /// <summary>
  26. /// The default content type to use if the input type is null or empty. If this
  27. /// value is not supplied an ArgumentOutOfRangeException exception will be raised.
  28. /// </summary>
  29. public string DefaultContentType
  30. {
  31. get { return _defaultContentType ?? String.Empty; }
  32. set { _defaultContentType = value; }
  33. }
  34. /// <summary>
  35. /// The extension registry to use when reading messages
  36. /// </summary>
  37. public ExtensionRegistry ExtensionRegistry
  38. {
  39. get { return _extensionRegistry ?? ExtensionRegistry.Empty; }
  40. set { _extensionRegistry = value; }
  41. }
  42. /// <summary>
  43. /// The name of the xml root element when reading messages
  44. /// </summary>
  45. public string XmlReaderRootElementName
  46. {
  47. get { return _xmlReaderRootElementName ?? XmlFormatReader.DefaultRootElementName; }
  48. set { _xmlReaderRootElementName = value; }
  49. }
  50. /// <summary>
  51. /// Xml reader options
  52. /// </summary>
  53. public XmlReaderOptions XmlReaderOptions { get; set; }
  54. /// <summary>
  55. /// True to use formatted output including new-lines and default indentation
  56. /// </summary>
  57. public bool FormattedOutput { get; set; }
  58. /// <summary>
  59. /// The name of the xml root element when writing messages
  60. /// </summary>
  61. public string XmlWriterRootElementName
  62. {
  63. get { return _xmlWriterRootElementName ?? XmlFormatWriter.DefaultRootElementName; }
  64. set { _xmlWriterRootElementName = value; }
  65. }
  66. /// <summary>
  67. /// Xml writer options
  68. /// </summary>
  69. public XmlWriterOptions XmlWriterOptions { get; set; }
  70. }
  71. }