using RestSharp; using RestSharp.Deserializers; using ServiceStack.Text; using System; using System.Net; namespace UptimeSharp { /// /// Custom JSON Deserializer which implements ServiceStack.Text /// internal class JsonDeserializer : IDeserializer { public const string JsonContentType = "application/json"; /// /// Deserializes the specified response. /// /// /// The response. /// public T Deserialize(IRestResponse response) { return JsonSerializer.DeserializeFromString(response.Content); } /// /// Adds custom deserialization for specific types. /// public static void AddCustomDeserialization() { // generate correct Uri format JsConfig.DeSerializeFn = value => { Uri uri; try { uri = new Uri(value); } catch { uri = null; } return uri; }; } /// /// Gets or sets the date format. /// /// /// The date format. /// public string DateFormat { get; set; } /// /// Gets or sets the namespace. /// /// /// The namespace. /// public string Namespace { get; set; } /// /// Gets or sets the root element. /// /// /// The root element. /// public string RootElement { get; set; } /// /// Gets the type of the content. /// /// /// The type of the content. /// public string ContentType { get { return JsonContentType; } } } }