using System; using System.Net.Http; namespace RestEase { #pragma warning disable CS0618 // Type or member is obsolete /// /// Helper capable of deserializing a response, to return to the caller /// public abstract class ResponseDeserializer : IResponseDeserializer { [Obsolete("Override Deserialize(string content, HttpResponseMessage response, ResponseDeserializerInfo info) instead", error: true)] T IResponseDeserializer.Deserialize(string? content, HttpResponseMessage response) { // This exists only so that we can assign instances of ResponseDeserializer to the IResponseDeserializer in RestClient throw new InvalidOperationException("This should never be called"); } /// /// Read the response string from the response, deserialize, and return a deserialized object /// /// Type of object to deserialize into /// String content read from the response /// HttpResponseMessage. Consider calling response.Content.ReadAsStringAsync() to retrieve a string /// Extra information about the response /// Deserialized response public virtual T Deserialize(string? content, HttpResponseMessage response, ResponseDeserializerInfo info) { throw new NotImplementedException($"You must override and implement T Deserialize(string content, HttpResponseMessage response, ResponseDeserializerInfo info) in {this.GetType().Name}"); } } #pragma warning restore CS0618 // Type or member is obsolete }