aboutsummaryrefslogtreecommitdiff
path: root/src/ProtocolBuffers.Serialization/Http/MessageFormatOptions.cs
blob: 5b88ac9415f032c6cb845df40b08ab6812447660 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
using System;

namespace Google.ProtocolBuffers.Serialization
{
    /// <summary>
    /// Defines control information for the various formatting used with HTTP services
    /// </summary>
    public struct MessageFormatOptions
    {
        /// <summary>The mime type for xml content</summary>
        /// <remarks>Other valid xml mime types include: application/binary, application/x-protobuf</remarks>
        public const string ContentTypeProtoBuffer = "application/vnd.google.protobuf";

        /// <summary>The mime type for xml content</summary>
        /// <remarks>Other valid xml mime types include: text/xml</remarks>
        public const string ContentTypeXml = "application/xml";
        
        /// <summary>The mime type for json content</summary>
        /// <remarks>
        /// Other valid json mime types include: application/json, application/x-json, 
        /// application/x-javascript, text/javascript, text/x-javascript, text/x-json, text/json
        /// </remarks>
        public const string ContentTypeJson = "application/json";

        private string _defaultContentType;
        private string _xmlReaderRootElementName;
        private string _xmlWriterRootElementName;
        private ExtensionRegistry _extensionRegistry;

        /// <summary>
        /// The default content type to use if the input type is null or empty.  If this
        /// value is not supplied an ArgumentOutOfRangeException exception will be raised.
        /// </summary>
        public string DefaultContentType
        {
            get { return _defaultContentType ?? String.Empty; }
            set { _defaultContentType = value; }
        }

        /// <summary>
        /// The extension registry to use when reading messages
        /// </summary>
        public ExtensionRegistry ExtensionRegistry
        {
            get { return _extensionRegistry ?? ExtensionRegistry.Empty; }
            set { _extensionRegistry = value; }
        }

        /// <summary>
        /// The name of the xml root element when reading messages
        /// </summary>
        public string XmlReaderRootElementName
        {
            get { return _xmlReaderRootElementName ?? XmlFormatReader.DefaultRootElementName; }
            set { _xmlReaderRootElementName = value; }
        }

        /// <summary>
        /// Xml reader options
        /// </summary>
        public XmlReaderOptions XmlReaderOptions { get; set; }

        /// <summary>
        /// True to use formatted output including new-lines and default indentation
        /// </summary>
        public bool FormattedOutput { get; set; }

        /// <summary>
        /// The name of the xml root element when writing messages
        /// </summary>
        public string XmlWriterRootElementName
        {
            get { return _xmlWriterRootElementName ?? XmlFormatWriter.DefaultRootElementName; }
            set { _xmlWriterRootElementName = value; }
        }

        /// <summary>
        /// Xml writer options
        /// </summary>
        public XmlWriterOptions XmlWriterOptions { get; set; }
    }
}