using System;
using System.Net.Http;
namespace RestEase
{
#pragma warning disable CS0618 // Type or member is obsolete
///
/// Helper which knows how to serialize a request body
///
public abstract class RequestBodySerializer : IRequestBodySerializer
{
[Obsolete("Override SerializeBody(T body, RequestBodySerializerInfo info) instead", error: true)]
HttpContent IRequestBodySerializer.SerializeBody(T body)
{
// This exists only so that we can assign instances of ResponseDeserializer to the IResponseDeserializer in RestClient
throw new InvalidOperationException("This should never be called");
}
///
/// Serialize the given request body
///
/// Body to serialize
/// Extra information about the request
/// Type of the body to serialize
/// HttpContent to assign to the request
public virtual HttpContent? SerializeBody(T body, RequestBodySerializerInfo info)
{
throw new NotImplementedException($"You must override and implement SerializeBody(T body, RequestBodySerializerInfo info) in {this.GetType().Name}");
}
}
#pragma warning restore CS0618 // Type or member is obsolete
}