diff options
author | csharptest <roger@csharptest.net> | 2012-10-14 23:03:24 -0500 |
---|---|---|
committer | rogerk <devnull@localhost> | 2012-10-14 23:03:24 -0500 |
commit | c9bce45a01cc8861ec7c88e84d947ed6ebc8f7d1 (patch) | |
tree | 67b0bed46bb50ec47a383fc355db4a73d568b482 /src/ProtocolBuffers.Serialization/Http | |
parent | 9f787cc64e47333ea717681c874843b44fee60e7 (diff) | |
download | protobuf-c9bce45a01cc8861ec7c88e84d947ed6ebc8f7d1.tar.gz protobuf-c9bce45a01cc8861ec7c88e84d947ed6ebc8f7d1.tar.bz2 protobuf-c9bce45a01cc8861ec7c88e84d947ed6ebc8f7d1.zip |
Portability Changes -
Removing uses of Enum to IConvertible from CodedIOStreams,
Removed MessageStreamIterator.FromFile on non-client profiles,
Removed use of Path.GetFileName,
Removed uses of Converter<T1, T2> delegate,
Removed Guid/DispId options from test protos
Diffstat (limited to 'src/ProtocolBuffers.Serialization/Http')
-rw-r--r-- | src/ProtocolBuffers.Serialization/Http/MessageFormatFactory.cs | 4 | ||||
-rw-r--r-- | src/ProtocolBuffers.Serialization/Http/MessageFormatOptions.cs | 37 |
2 files changed, 25 insertions, 16 deletions
diff --git a/src/ProtocolBuffers.Serialization/Http/MessageFormatFactory.cs b/src/ProtocolBuffers.Serialization/Http/MessageFormatFactory.cs index b3679bab..270af64b 100644 --- a/src/ProtocolBuffers.Serialization/Http/MessageFormatFactory.cs +++ b/src/ProtocolBuffers.Serialization/Http/MessageFormatFactory.cs @@ -78,7 +78,7 @@ namespace Google.ProtocolBuffers.Serialization.Http {
contentType = (contentType ?? String.Empty).Split(';')[0].Trim();
- Converter<Stream, ICodedInputStream> factory;
+ CodedInputBuilder factory;
if(!options.MimeInputTypesReadOnly.TryGetValue(contentType, out factory) || factory == null)
{
if(String.IsNullOrEmpty(options.DefaultContentType) ||
@@ -95,7 +95,7 @@ namespace Google.ProtocolBuffers.Serialization.Http {
contentType = (contentType ?? String.Empty).Split(';')[0].Trim();
- Converter<Stream, ICodedOutputStream> factory;
+ CodedOutputBuilder factory;
if (!options.MimeOutputTypesReadOnly.TryGetValue(contentType, out factory) || factory == null)
{
if (String.IsNullOrEmpty(options.DefaultContentType) ||
diff --git a/src/ProtocolBuffers.Serialization/Http/MessageFormatOptions.cs b/src/ProtocolBuffers.Serialization/Http/MessageFormatOptions.cs index 72d73717..1480e50a 100644 --- a/src/ProtocolBuffers.Serialization/Http/MessageFormatOptions.cs +++ b/src/ProtocolBuffers.Serialization/Http/MessageFormatOptions.cs @@ -6,6 +6,15 @@ using Google.ProtocolBuffers.Collections; namespace Google.ProtocolBuffers.Serialization.Http
{
/// <summary>
+ /// A delegate used to specify a method that constructs an ICodedInputStream from a .NET Stream.
+ /// </summary>
+ public delegate ICodedInputStream CodedInputBuilder(Stream stream);
+ /// <summary>
+ /// A delegate used to specify a method that constructs an ICodedOutputStream from a .NET Stream.
+ /// </summary>
+ public delegate ICodedOutputStream CodedOutputBuilder(Stream stream);
+
+ /// <summary>
/// Defines control information for the various formatting used with HTTP services
/// </summary>
public class MessageFormatOptions
@@ -32,9 +41,9 @@ namespace Google.ProtocolBuffers.Serialization.Http /// <summary>
/// Default mime-type handling for input
/// </summary>
- private static readonly IDictionary<string, Converter<Stream, ICodedInputStream>> MimeInputDefaults =
- new ReadOnlyDictionary<string, Converter<Stream, ICodedInputStream>>(
- new Dictionary<string, Converter<Stream, ICodedInputStream>>(StringComparer.OrdinalIgnoreCase)
+ private static readonly IDictionary<string, CodedInputBuilder> MimeInputDefaults =
+ new ReadOnlyDictionary<string, CodedInputBuilder>(
+ new Dictionary<string, CodedInputBuilder>(StringComparer.OrdinalIgnoreCase)
{
{"application/json", JsonFormatReader.CreateInstance},
{"application/x-json", JsonFormatReader.CreateInstance},
@@ -55,9 +64,9 @@ namespace Google.ProtocolBuffers.Serialization.Http /// <summary>
/// Default mime-type handling for output
/// </summary>
- private static readonly IDictionary<string, Converter<Stream, ICodedOutputStream>> MimeOutputDefaults =
- new ReadOnlyDictionary<string, Converter<Stream, ICodedOutputStream>>(
- new Dictionary<string, Converter<Stream, ICodedOutputStream>>(StringComparer.OrdinalIgnoreCase)
+ private static readonly IDictionary<string, CodedOutputBuilder> MimeOutputDefaults =
+ new ReadOnlyDictionary<string, CodedOutputBuilder>(
+ new Dictionary<string, CodedOutputBuilder>(StringComparer.OrdinalIgnoreCase)
{
{"application/json", JsonFormatWriter.CreateInstance},
{"application/x-json", JsonFormatWriter.CreateInstance},
@@ -81,35 +90,35 @@ namespace Google.ProtocolBuffers.Serialization.Http private string _xmlReaderRootElementName;
private string _xmlWriterRootElementName;
private ExtensionRegistry _extensionRegistry;
- private Dictionary<string, Converter<Stream, ICodedInputStream>> _mimeInputTypes;
- private Dictionary<string, Converter<Stream, ICodedOutputStream>> _mimeOutputTypes;
+ private Dictionary<string, CodedInputBuilder> _mimeInputTypes;
+ private Dictionary<string, CodedOutputBuilder> _mimeOutputTypes;
/// <summary> Provides access to modify the mime-type input stream construction </summary>
- public IDictionary<string, Converter<Stream, ICodedInputStream>> MimeInputTypes
+ public IDictionary<string, CodedInputBuilder> MimeInputTypes
{
get
{
return _mimeInputTypes ??
- (_mimeInputTypes = new Dictionary<string, Converter<Stream, ICodedInputStream>>(
+ (_mimeInputTypes = new Dictionary<string, CodedInputBuilder>(
MimeInputDefaults, StringComparer.OrdinalIgnoreCase));
}
}
/// <summary> Provides access to modify the mime-type input stream construction </summary>
- public IDictionary<string, Converter<Stream, ICodedOutputStream>> MimeOutputTypes
+ public IDictionary<string, CodedOutputBuilder> MimeOutputTypes
{
get
{
return _mimeOutputTypes ??
- (_mimeOutputTypes = new Dictionary<string, Converter<Stream, ICodedOutputStream>>(
+ (_mimeOutputTypes = new Dictionary<string, CodedOutputBuilder>(
MimeOutputDefaults, StringComparer.OrdinalIgnoreCase));
}
}
- internal IDictionary<string, Converter<Stream, ICodedInputStream>> MimeInputTypesReadOnly
+ internal IDictionary<string, CodedInputBuilder> MimeInputTypesReadOnly
{ get { return _mimeInputTypes ?? MimeInputDefaults; } }
- internal IDictionary<string, Converter<Stream, ICodedOutputStream>> MimeOutputTypesReadOnly
+ internal IDictionary<string, CodedOutputBuilder> MimeOutputTypesReadOnly
{ get { return _mimeOutputTypes ?? MimeOutputDefaults; } }
/// <summary>
|