using Google.Protobuf;
using System;
using System.IO;
using System.Net;
using System.Net.Http;
using System.Net.Http.Formatting;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using System.Web.Http;
using Tango.PMR.Stubs;
using Tango.PMR.Synchronization;
namespace Tango.Web.Formatters
{
///
/// Represents a protobuf web request/response formatter capable of formatting messages using protobuf.
///
///
public class ProtoBufFormatter : MediaTypeFormatter
{
private static readonly MediaTypeHeaderValue mediaType = new MediaTypeHeaderValue("application/x-protobuf");
///
/// Initializes a new instance of the class.
///
public ProtoBufFormatter()
{
SupportedMediaTypes.Add(mediaType);
}
///
/// Gets the default type of the media.
///
///
/// The default type of the media.
///
public static MediaTypeHeaderValue DefaultMediaType
{
get { return mediaType; }
}
///
/// Queries whether this can deserializean object of the specified type.
///
/// The type to deserialize.
///
/// true if the can deserialize the type; otherwise, false.
///
public override bool CanReadType(Type type)
{
return true;
}
///
/// Queries whether this can serializean object of the specified type.
///
/// The type to serialize.
///
/// true if the can serialize the type; otherwise, false.
///
public override bool CanWriteType(Type type)
{
return true;
}
///
/// Reads from stream asynchronous.
///
/// The type.
/// The stream.
/// The content.
/// The formatter logger.
///
public override Task