remove JSON prop from PocketItem and introduce an AfterRequest action with the passed raw response

This commit is contained in:
2018-07-02 16:41:18 +02:00
parent 7edc82d726
commit 8248f90b5b
2 changed files with 13 additions and 14 deletions
-9
View File
@@ -372,15 +372,6 @@ namespace PocketSharp.Models
get { return Images != null && Images.Count() > 0 ? Images.First() : null; } get { return Images != null && Images.Count() > 0 ? Images.First() : null; }
} }
/// <summary>
/// Gets and sets the JSON the model was deserialized from
/// </summary>
/// <value>
/// Model's original JSON representation
/// </value>
[JsonIgnore]
public string Json { get; set; }
/// <summary> /// <summary>
/// Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object. /// Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.
/// </summary> /// </summary>
+13 -5
View File
@@ -1,4 +1,4 @@
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Serialization; using Newtonsoft.Json.Serialization;
using PocketSharp.Models; using PocketSharp.Models;
using System; using System;
@@ -103,6 +103,14 @@ namespace PocketSharp
/// </value> /// </value>
public Action<string> PreRequest { get; set; } public Action<string> PreRequest { get; set; }
/// <summary>
/// Action which is executed after every request
/// </summary>
/// <value>
/// The after request callback.
/// </value>
public Action<string> AfterRequest { get; set; }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="PocketClient" /> class. /// Initializes a new instance of the <see cref="PocketClient" /> class.
@@ -233,10 +241,7 @@ namespace PocketSharp
request.Content = new FormUrlEncodedContent(parameters); request.Content = new FormUrlEncodedContent(parameters);
// call pre request action // call pre request action
if (PreRequest != null) PreRequest?.Invoke(method);
{
PreRequest(method);
}
// make async request // make async request
try try
@@ -280,6 +285,9 @@ namespace PocketSharp
} }
} }
// call after request action
AfterRequest?.Invoke(responseString);
// cache response // cache response
if (cacheHTTPResponseData) if (cacheHTTPResponseData)
{ {