add custom deserializers; update data-attributes for json.net
This commit is contained in:
+2
-1
@@ -165,4 +165,5 @@ $RECYCLE.BIN/
|
||||
# =========================
|
||||
|
||||
PocketSharp.Console/
|
||||
!PocketSharp.Website/Release/
|
||||
PocketSharp.WpfTests/
|
||||
!PocketSharp.Website/Release/
|
||||
|
||||
@@ -8,19 +8,9 @@ namespace PocketSharp.Tests
|
||||
public class UnitTest1
|
||||
{
|
||||
[TestMethod]
|
||||
public async Task TestMethod1()
|
||||
public void TestMethod1()
|
||||
{
|
||||
var tcs = new TaskCompletionSource<string>();
|
||||
|
||||
PocketClient client = new PocketClient(
|
||||
consumerKey: "15396-f6f92101d72c8e270a6c9bb3",
|
||||
callbackUri: "http://frontendplay.com",
|
||||
accessCode: "206d5286-230d-b3e2-48c6-fabf89"
|
||||
);
|
||||
|
||||
var items = await client.Retrieve(RetrieveFilter.Archive);
|
||||
|
||||
Assert.AreEqual(10, items.Capacity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+15
-7
@@ -1,24 +1,32 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2012
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PocketSharp", "PocketSharp\PocketSharp.csproj", "{1A291041-ADD8-467C-A6E4-0ACA26328CDF}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PocketSharp.Tests", "PocketSharp.Tests\PocketSharp.Tests.csproj", "{F1CEA363-7039-40BA-9744-0071F46BB90C}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PocketSharp", "PocketSharp\PocketSharp.csproj", "{817200C3-A327-4E35-9B5F-63A51C088577}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PocketSharp.WpfTests", "PocketSharp.WpfTests\PocketSharp.WpfTests.csproj", "{775569C2-987F-4AC4-8BA5-A315A21ED1B7}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{817200C3-A327-4E35-9B5F-63A51C088577} = {817200C3-A327-4E35-9B5F-63A51C088577}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{1A291041-ADD8-467C-A6E4-0ACA26328CDF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1A291041-ADD8-467C-A6E4-0ACA26328CDF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1A291041-ADD8-467C-A6E4-0ACA26328CDF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1A291041-ADD8-467C-A6E4-0ACA26328CDF}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{F1CEA363-7039-40BA-9744-0071F46BB90C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F1CEA363-7039-40BA-9744-0071F46BB90C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F1CEA363-7039-40BA-9744-0071F46BB90C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F1CEA363-7039-40BA-9744-0071F46BB90C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{817200C3-A327-4E35-9B5F-63A51C088577}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{817200C3-A327-4E35-9B5F-63A51C088577}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{817200C3-A327-4E35-9B5F-63A51C088577}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{817200C3-A327-4E35-9B5F-63A51C088577}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{775569C2-987F-4AC4-8BA5-A315A21ED1B7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{775569C2-987F-4AC4-8BA5-A315A21ED1B7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{775569C2-987F-4AC4-8BA5-A315A21ED1B7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{775569C2-987F-4AC4-8BA5-A315A21ED1B7}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
@@ -7,32 +7,45 @@ using System.Text;
|
||||
|
||||
namespace PocketSharp
|
||||
{
|
||||
//public class UnixDateTimeConverter : DateTimeConverterBase
|
||||
//{
|
||||
// /// <summary>
|
||||
// /// Writes the JSON representation of the object.
|
||||
// /// </summary>
|
||||
// /// <param name="writer">The <see cref="T:Newtonsoft.Json.JsonWriter"/> to write to.</param><param name="value">The value.</param><param name="serializer">The calling serializer.</param>
|
||||
// //public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
|
||||
// //{
|
||||
// // DateTime epoc = new DateTime(1970, 1, 1);
|
||||
// // var delta = (DateTime)value - epoc;
|
||||
|
||||
// // writer.WriteValue((long)delta.TotalSeconds);
|
||||
// //}
|
||||
public class BoolConverter : JsonConverter
|
||||
{
|
||||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
|
||||
{
|
||||
writer.WriteValue(((bool)value) ? 1 : 0);
|
||||
}
|
||||
|
||||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
|
||||
{
|
||||
return reader.Value.ToString() == "1";
|
||||
}
|
||||
|
||||
public override bool CanConvert(Type objectType)
|
||||
{
|
||||
return objectType == typeof(bool);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ///// <summary>
|
||||
// ///// Reads the JSON representation of the object.
|
||||
// ///// </summary>
|
||||
// ///// <param name="reader">The <see cref = "JsonReader" /> to read from.</param>
|
||||
// ///// <param name="objectType">Type of the object.</param>
|
||||
// ///// <param name="existingValue">The existing value of object being read.</param>
|
||||
// ///// <param name="serializer">The calling serializer.</param>
|
||||
// ///// <returns>The object value.</returns>
|
||||
// //public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
|
||||
// //{
|
||||
// // return existingValue == "0" ? null : new DateTime(1970, 1, 1, 0, 0, 0, 0).AddSeconds(Convert.ToDouble(existingValue)).ToLocalTime();
|
||||
// //}
|
||||
//}
|
||||
|
||||
public class UnixDateTimeConverter : DateTimeConverterBase
|
||||
{
|
||||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
|
||||
{
|
||||
DateTime epoc = new DateTime(1970, 1, 1);
|
||||
var delta = (DateTime)value - epoc;
|
||||
|
||||
writer.WriteValue((long)delta.TotalSeconds);
|
||||
}
|
||||
|
||||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
|
||||
{
|
||||
if(reader.Value.ToString() == "0")
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new DateTime(1970, 1, 1, 0, 0, 0, 0).AddSeconds(Convert.ToDouble(reader.Value)).ToLocalTime();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace PocketSharp.Models
|
||||
@@ -6,7 +7,7 @@ namespace PocketSharp.Models
|
||||
/// <summary>
|
||||
/// Author
|
||||
/// </summary>
|
||||
[DataContract]
|
||||
[JsonObject]
|
||||
public class PocketAuthor
|
||||
{
|
||||
/// <summary>
|
||||
@@ -15,7 +16,7 @@ namespace PocketSharp.Models
|
||||
/// <value>
|
||||
/// The ID.
|
||||
/// </value>
|
||||
[DataMember(Name = "author_id")]
|
||||
[JsonProperty("author_id")]
|
||||
public string ID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -24,7 +25,7 @@ namespace PocketSharp.Models
|
||||
/// <value>
|
||||
/// The name.
|
||||
/// </value>
|
||||
[DataMember]
|
||||
[JsonProperty]
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -33,7 +34,7 @@ namespace PocketSharp.Models
|
||||
/// <value>
|
||||
/// The URI.
|
||||
/// </value>
|
||||
[DataMember(Name = "url")]
|
||||
[JsonProperty("url")]
|
||||
public Uri Uri { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace PocketSharp.Models
|
||||
@@ -6,7 +7,7 @@ namespace PocketSharp.Models
|
||||
/// <summary>
|
||||
/// Image
|
||||
/// </summary>
|
||||
[DataContract]
|
||||
[JsonObject]
|
||||
public class PocketImage
|
||||
{
|
||||
/// <summary>
|
||||
@@ -15,7 +16,7 @@ namespace PocketSharp.Models
|
||||
/// <value>
|
||||
/// The ID.
|
||||
/// </value>
|
||||
[DataMember(Name = "image_id")]
|
||||
[JsonProperty("image_id")]
|
||||
public string ID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -24,7 +25,7 @@ namespace PocketSharp.Models
|
||||
/// <value>
|
||||
/// The caption.
|
||||
/// </value>
|
||||
[DataMember]
|
||||
[JsonProperty]
|
||||
public string Caption { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -33,7 +34,7 @@ namespace PocketSharp.Models
|
||||
/// <value>
|
||||
/// The credit.
|
||||
/// </value>
|
||||
[DataMember]
|
||||
[JsonProperty]
|
||||
public string Credit { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -42,7 +43,7 @@ namespace PocketSharp.Models
|
||||
/// <value>
|
||||
/// The URI.
|
||||
/// </value>
|
||||
[DataMember(Name = "src")]
|
||||
[JsonProperty("src")]
|
||||
public Uri Uri { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
@@ -8,7 +9,7 @@ namespace PocketSharp.Models
|
||||
/// Item containing all available data
|
||||
/// see: http://getpocket.com/developer/docs/v3/retrieve
|
||||
/// </summary>
|
||||
[DataContract]
|
||||
[JsonObject]
|
||||
public class PocketItem
|
||||
{
|
||||
/// <summary>
|
||||
@@ -17,7 +18,7 @@ namespace PocketSharp.Models
|
||||
/// <value>
|
||||
/// The ID.
|
||||
/// </value>
|
||||
[DataMember(Name = "item_id")]
|
||||
[JsonProperty("item_id")]
|
||||
public int ID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -26,7 +27,7 @@ namespace PocketSharp.Models
|
||||
/// <value>
|
||||
/// The URI.
|
||||
/// </value>
|
||||
[DataMember(Name = "resolved_url")]
|
||||
[JsonProperty("resolved_url")]
|
||||
public Uri Uri { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -35,7 +36,7 @@ namespace PocketSharp.Models
|
||||
/// <value>
|
||||
/// The title.
|
||||
/// </value>
|
||||
[DataMember(Name = "resolved_title")]
|
||||
[JsonProperty("resolved_title")]
|
||||
public string Title { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -44,7 +45,7 @@ namespace PocketSharp.Models
|
||||
/// <value>
|
||||
/// The full title.
|
||||
/// </value>
|
||||
[DataMember(Name = "given_title")]
|
||||
[JsonProperty("given_title")]
|
||||
public string FullTitle { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -53,7 +54,7 @@ namespace PocketSharp.Models
|
||||
/// <value>
|
||||
/// The excerpt.
|
||||
/// </value>
|
||||
[DataMember]
|
||||
[JsonProperty]
|
||||
public string Excerpt { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -62,7 +63,7 @@ namespace PocketSharp.Models
|
||||
/// <value>
|
||||
/// The status.
|
||||
/// </value>
|
||||
[DataMember]
|
||||
[JsonProperty]
|
||||
public int Status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -71,7 +72,7 @@ namespace PocketSharp.Models
|
||||
/// <value>
|
||||
/// <c>true</c> if this instance is favorite; otherwise, <c>false</c>.
|
||||
/// </value>
|
||||
[DataMember(Name = "favorite")]
|
||||
[JsonProperty("favorite")]
|
||||
public bool IsFavorite { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -80,7 +81,7 @@ namespace PocketSharp.Models
|
||||
/// <value>
|
||||
/// <c>true</c> if this instance is archive; otherwise, <c>false</c>.
|
||||
/// </value>
|
||||
[IgnoreDataMember]
|
||||
[JsonIgnore]
|
||||
public bool IsArchive { get { return Status == 1; } }
|
||||
|
||||
/// <summary>
|
||||
@@ -89,7 +90,7 @@ namespace PocketSharp.Models
|
||||
/// <value>
|
||||
/// <c>true</c> if this instance is deleted; otherwise, <c>false</c>.
|
||||
/// </value>
|
||||
[IgnoreDataMember]
|
||||
[JsonIgnore]
|
||||
public bool IsDeleted { get { return Status == 2; } }
|
||||
|
||||
/// <summary>
|
||||
@@ -98,7 +99,7 @@ namespace PocketSharp.Models
|
||||
/// <value>
|
||||
/// <c>true</c> if this instance is article; otherwise, <c>false</c>.
|
||||
/// </value>
|
||||
[DataMember(Name = "is_article")]
|
||||
[JsonProperty("is_article")]
|
||||
public bool IsArticle { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -107,7 +108,7 @@ namespace PocketSharp.Models
|
||||
/// <value>
|
||||
/// <c>true</c> if this instance has image; otherwise, <c>false</c>.
|
||||
/// </value>
|
||||
[DataMember(Name = "has_image")]
|
||||
[JsonProperty("has_image")]
|
||||
public bool HasImage { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -116,7 +117,7 @@ namespace PocketSharp.Models
|
||||
/// <value>
|
||||
/// <c>true</c> if this instance has video; otherwise, <c>false</c>.
|
||||
/// </value>
|
||||
[DataMember(Name = "has_video")]
|
||||
[JsonProperty("has_video")]
|
||||
public bool HasVideo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -125,7 +126,7 @@ namespace PocketSharp.Models
|
||||
/// <value>
|
||||
/// The word count.
|
||||
/// </value>
|
||||
[DataMember(Name = "word_count")]
|
||||
[JsonProperty("word_count")]
|
||||
public int WordCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -134,7 +135,7 @@ namespace PocketSharp.Models
|
||||
/// <value>
|
||||
/// The sort.
|
||||
/// </value>
|
||||
[DataMember(Name = "sort_id")]
|
||||
[JsonProperty("sort_id")]
|
||||
public int Sort { get; set; }
|
||||
|
||||
|
||||
@@ -144,7 +145,7 @@ namespace PocketSharp.Models
|
||||
/// <value>
|
||||
/// The add time.
|
||||
/// </value>
|
||||
[DataMember(Name = "time_added")]
|
||||
[JsonProperty("time_added")]
|
||||
public DateTime? AddTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -153,7 +154,7 @@ namespace PocketSharp.Models
|
||||
/// <value>
|
||||
/// The update time.
|
||||
/// </value>
|
||||
[DataMember(Name = "time_updated")]
|
||||
[JsonProperty("time_updated")]
|
||||
public DateTime? UpdateTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -162,7 +163,7 @@ namespace PocketSharp.Models
|
||||
/// <value>
|
||||
/// The read time.
|
||||
/// </value>
|
||||
[DataMember(Name = "time_read")]
|
||||
[JsonProperty("time_read")]
|
||||
public DateTime? ReadTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -171,7 +172,7 @@ namespace PocketSharp.Models
|
||||
/// <value>
|
||||
/// The favorite time.
|
||||
/// </value>
|
||||
[DataMember(Name = "time_favorited")]
|
||||
[JsonProperty("time_favorited")]
|
||||
public DateTime? FavoriteTime { get; set; }
|
||||
|
||||
|
||||
@@ -181,7 +182,7 @@ namespace PocketSharp.Models
|
||||
/// <value>
|
||||
/// The _ tag dictionary.
|
||||
/// </value>
|
||||
[DataMember(Name = "tags")]
|
||||
[JsonProperty("tags")]
|
||||
public Dictionary<string, PocketTag> TagDictionary { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -190,7 +191,7 @@ namespace PocketSharp.Models
|
||||
/// <value>
|
||||
/// The _ image dictionary.
|
||||
/// </value>
|
||||
[DataMember(Name = "images")]
|
||||
[JsonProperty("images")]
|
||||
public Dictionary<string, PocketImage> ImageDictionary { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -199,7 +200,7 @@ namespace PocketSharp.Models
|
||||
/// <value>
|
||||
/// The _ video dictionary.
|
||||
/// </value>
|
||||
[DataMember(Name = "videos")]
|
||||
[JsonProperty("videos")]
|
||||
public Dictionary<string, PocketVideo> VideoDictionary { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -208,7 +209,7 @@ namespace PocketSharp.Models
|
||||
/// <value>
|
||||
/// The _ author dictionary.
|
||||
/// </value>
|
||||
[DataMember(Name = "authors")]
|
||||
[JsonProperty("authors")]
|
||||
public Dictionary<string, PocketAuthor> AuthorDictionary { get; set; }
|
||||
|
||||
|
||||
@@ -218,7 +219,7 @@ namespace PocketSharp.Models
|
||||
/// <value>
|
||||
/// The tags.
|
||||
/// </value>
|
||||
[IgnoreDataMember]
|
||||
[JsonIgnore]
|
||||
public List<PocketTag> Tags
|
||||
{
|
||||
get { return Utilities.DictionaryToList<PocketTag>(TagDictionary); }
|
||||
@@ -230,7 +231,7 @@ namespace PocketSharp.Models
|
||||
/// <value>
|
||||
/// The images.
|
||||
/// </value>
|
||||
[IgnoreDataMember]
|
||||
[JsonIgnore]
|
||||
public List<PocketImage> Images
|
||||
{
|
||||
get { return Utilities.DictionaryToList<PocketImage>(ImageDictionary); }
|
||||
@@ -242,7 +243,7 @@ namespace PocketSharp.Models
|
||||
/// <value>
|
||||
/// The lead image.
|
||||
/// </value>
|
||||
[IgnoreDataMember]
|
||||
[JsonIgnore]
|
||||
public PocketImage LeadImage
|
||||
{
|
||||
get { return Images != null ? Images[0] : null; }
|
||||
@@ -254,7 +255,7 @@ namespace PocketSharp.Models
|
||||
/// <value>
|
||||
/// The videos.
|
||||
/// </value>
|
||||
[IgnoreDataMember]
|
||||
[JsonIgnore]
|
||||
public List<PocketVideo> Videos
|
||||
{
|
||||
get { return Utilities.DictionaryToList<PocketVideo>(VideoDictionary); }
|
||||
@@ -266,7 +267,7 @@ namespace PocketSharp.Models
|
||||
/// <value>
|
||||
/// The authors.
|
||||
/// </value>
|
||||
[IgnoreDataMember]
|
||||
[JsonIgnore]
|
||||
public List<PocketAuthor> Authors
|
||||
{
|
||||
get { return Utilities.DictionaryToList<PocketAuthor>(AuthorDictionary); }
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
using System.Runtime.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace PocketSharp.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// Tag
|
||||
/// </summary>
|
||||
[DataContract]
|
||||
[JsonObject]
|
||||
public class PocketTag
|
||||
{
|
||||
/// <summary>
|
||||
@@ -14,7 +15,7 @@ namespace PocketSharp.Models
|
||||
/// <value>
|
||||
/// The name.
|
||||
/// </value>
|
||||
[DataMember(Name = "tag")]
|
||||
[JsonProperty("tag")]
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace PocketSharp.Models
|
||||
@@ -6,7 +7,7 @@ namespace PocketSharp.Models
|
||||
/// <summary>
|
||||
/// Video
|
||||
/// </summary>
|
||||
[DataContract]
|
||||
[JsonObject]
|
||||
public class PocketVideo
|
||||
{
|
||||
/// <summary>
|
||||
@@ -15,7 +16,7 @@ namespace PocketSharp.Models
|
||||
/// <value>
|
||||
/// The ID.
|
||||
/// </value>
|
||||
[DataMember(Name = "video_id")]
|
||||
[JsonProperty("video_id")]
|
||||
public string ID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -24,7 +25,7 @@ namespace PocketSharp.Models
|
||||
/// <value>
|
||||
/// The external ID.
|
||||
/// </value>
|
||||
[DataMember(Name = "vid")]
|
||||
[JsonProperty("vid")]
|
||||
public string ExternalID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -33,7 +34,7 @@ namespace PocketSharp.Models
|
||||
/// <value>
|
||||
/// The URI.
|
||||
/// </value>
|
||||
[DataMember(Name = "src")]
|
||||
[JsonProperty("src")]
|
||||
public Uri Uri { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
using System.Runtime.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace PocketSharp.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// Access Code
|
||||
/// </summary>
|
||||
[DataContract]
|
||||
[JsonObject]
|
||||
internal class AccessCode
|
||||
{
|
||||
/// <summary>
|
||||
@@ -14,7 +15,7 @@ namespace PocketSharp.Models
|
||||
/// <value>
|
||||
/// The code.
|
||||
/// </value>
|
||||
[DataMember(Name = "access_token")]
|
||||
[JsonProperty("access_token")]
|
||||
public string Code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -23,7 +24,7 @@ namespace PocketSharp.Models
|
||||
/// <value>
|
||||
/// The username.
|
||||
/// </value>
|
||||
[DataMember]
|
||||
[JsonProperty]
|
||||
public string Username { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
using System.Runtime.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace PocketSharp.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// Add Response
|
||||
/// </summary>
|
||||
[DataContract]
|
||||
[JsonObject]
|
||||
internal class Add : ResponseBase
|
||||
{
|
||||
/// <summary>
|
||||
@@ -14,7 +15,7 @@ namespace PocketSharp.Models
|
||||
/// <value>
|
||||
/// The item.
|
||||
/// </value>
|
||||
[DataMember]
|
||||
[JsonProperty]
|
||||
public PocketItem Item { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
using System.Runtime.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace PocketSharp.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// Modify Response
|
||||
/// </summary>
|
||||
[DataContract]
|
||||
[JsonObject]
|
||||
internal class Modify : ResponseBase
|
||||
{
|
||||
/// <summary>
|
||||
@@ -14,7 +15,7 @@ namespace PocketSharp.Models
|
||||
/// <value>
|
||||
/// The action results.
|
||||
/// </value>
|
||||
[DataMember(Name = "action_results")]
|
||||
[JsonProperty("action_results")]
|
||||
public bool[] ActionResults { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
using System.Runtime.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace PocketSharp.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// Request Code
|
||||
/// </summary>
|
||||
[DataContract]
|
||||
[JsonObject]
|
||||
internal class RequestCode
|
||||
{
|
||||
/// <summary>
|
||||
@@ -14,7 +15,7 @@ namespace PocketSharp.Models
|
||||
/// <value>
|
||||
/// The code.
|
||||
/// </value>
|
||||
[DataMember]
|
||||
[JsonProperty]
|
||||
public string Code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -23,7 +24,7 @@ namespace PocketSharp.Models
|
||||
/// <value>
|
||||
/// The state.
|
||||
/// </value>
|
||||
[DataMember]
|
||||
[JsonProperty]
|
||||
public string State { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
using System.Runtime.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace PocketSharp.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// Base for Responses
|
||||
/// </summary>
|
||||
[DataContract]
|
||||
[JsonObject]
|
||||
internal class ResponseBase
|
||||
{
|
||||
/// <summary>
|
||||
@@ -14,7 +15,7 @@ namespace PocketSharp.Models
|
||||
/// <value>
|
||||
/// <c>true</c> if status is OK; otherwise, <c>false</c>.
|
||||
/// </value>
|
||||
[DataMember(Name = "status")]
|
||||
[JsonProperty("status")]
|
||||
public bool Status { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace PocketSharp.Models
|
||||
@@ -6,7 +7,7 @@ namespace PocketSharp.Models
|
||||
/// <summary>
|
||||
/// Item Response
|
||||
/// </summary>
|
||||
[DataContract]
|
||||
[JsonObject]
|
||||
internal class Retrieve : ResponseBase
|
||||
{
|
||||
/// <summary>
|
||||
@@ -15,7 +16,7 @@ namespace PocketSharp.Models
|
||||
/// <value>
|
||||
/// The complete.
|
||||
/// </value>
|
||||
[DataMember(Name = "complete")]
|
||||
[JsonProperty("complete")]
|
||||
public int Complete { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -24,7 +25,7 @@ namespace PocketSharp.Models
|
||||
/// <value>
|
||||
/// The since.
|
||||
/// </value>
|
||||
[DataMember]
|
||||
[JsonProperty]
|
||||
public int Since { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -33,7 +34,7 @@ namespace PocketSharp.Models
|
||||
/// <value>
|
||||
/// The _ item dictionary.
|
||||
/// </value>
|
||||
[DataMember(Name = "list")]
|
||||
[JsonProperty("list")]
|
||||
public Dictionary<string, PocketItem> ItemDictionary { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -42,7 +43,7 @@ namespace PocketSharp.Models
|
||||
/// <value>
|
||||
/// The items.
|
||||
/// </value>
|
||||
[IgnoreDataMember]
|
||||
[JsonIgnore]
|
||||
public List<PocketItem> Items
|
||||
{
|
||||
get { return Utilities.DictionaryToList<PocketItem>(ItemDictionary); }
|
||||
|
||||
@@ -152,7 +152,11 @@ namespace PocketSharp
|
||||
string responseString = response.Content.ReadAsStringAsync().Result;
|
||||
|
||||
// deserialize object
|
||||
return JsonConvert.DeserializeObject<T>(responseString);
|
||||
return JsonConvert.DeserializeObject<T>(
|
||||
responseString,
|
||||
new BoolConverter(),
|
||||
new UnixDateTimeConverter()
|
||||
);
|
||||
|
||||
//ValidateResponse(response);
|
||||
}
|
||||
|
||||
@@ -2,25 +2,20 @@
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<MinimumVisualStudioVersion>10.0</MinimumVisualStudioVersion>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{1A291041-ADD8-467C-A6E4-0ACA26328CDF}</ProjectGuid>
|
||||
<ProjectGuid>{817200C3-A327-4E35-9B5F-63A51C088577}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>PocketSharp</RootNamespace>
|
||||
<AssemblyName>PocketSharp</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<TargetFrameworkProfile>Profile96</TargetFrameworkProfile>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
|
||||
<RestorePackages>true</RestorePackages>
|
||||
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<TargetFrameworkProfile>Profile88</TargetFrameworkProfile>
|
||||
<MinimumVisualStudioVersion>10.0</MinimumVisualStudioVersion>
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
<UpgradeBackupLocation>
|
||||
</UpgradeBackupLocation>
|
||||
<OldToolsVersion>4.0</OldToolsVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
@@ -30,7 +25,6 @@
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<DocumentationFile>bin\Debug\PocketSharp.XML</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
@@ -40,6 +34,39 @@
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<!-- A reference to the entire .NET Framework is automatically included -->
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="APIException.cs" />
|
||||
<Compile Include="Components\Add.cs" />
|
||||
<Compile Include="Components\Authentification.cs" />
|
||||
<Compile Include="Components\Modify.cs" />
|
||||
<Compile Include="Components\ModifyTags.cs" />
|
||||
<Compile Include="Components\Retrieve.cs" />
|
||||
<Compile Include="JsonDeserializer.cs" />
|
||||
<Compile Include="JsonExtensions.cs" />
|
||||
<Compile Include="Models\Parameters\ActionParameter.cs" />
|
||||
<Compile Include="Models\Parameters\AddParameters.cs" />
|
||||
<Compile Include="Models\Parameters\ModifyParameters.cs" />
|
||||
<Compile Include="Models\Parameters\Parameter.cs" />
|
||||
<Compile Include="Models\Parameters\RetrieveParameters.cs" />
|
||||
<Compile Include="Models\PocketAuthor.cs" />
|
||||
<Compile Include="Models\PocketImage.cs" />
|
||||
<Compile Include="Models\PocketItem.cs" />
|
||||
<Compile Include="Models\PocketTag.cs" />
|
||||
<Compile Include="Models\PocketVideo.cs" />
|
||||
<Compile Include="Models\Response\AccessCode.cs" />
|
||||
<Compile Include="Models\Response\Add.cs" />
|
||||
<Compile Include="Models\Response\Modify.cs" />
|
||||
<Compile Include="Models\Response\RequestCode.cs" />
|
||||
<Compile Include="Models\Response\ResponseBase.cs" />
|
||||
<Compile Include="Models\Response\Retrieve.cs" />
|
||||
<Compile Include="PocketClient.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Utilities.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.Threading.Tasks">
|
||||
<HintPath>..\packages\Microsoft.Bcl.Async.1.0.16\lib\portable-net40+sl4+win8+wp71\Microsoft.Threading.Tasks.dll</HintPath>
|
||||
@@ -50,8 +77,6 @@
|
||||
<Reference Include="Newtonsoft.Json">
|
||||
<HintPath>..\packages\Newtonsoft.Json.5.0.6\lib\portable-net40+sl4+wp7+win8\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.IO">
|
||||
<HintPath>..\packages\Microsoft.Bcl.1.1.3\lib\portable-net40+sl4+win8+wp71\System.IO.dll</HintPath>
|
||||
</Reference>
|
||||
@@ -67,55 +92,24 @@
|
||||
<Reference Include="System.Runtime">
|
||||
<HintPath>..\packages\Microsoft.Bcl.1.1.3\lib\portable-net40+sl4+win8+wp71\System.Runtime.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
<Reference Include="System.Threading.Tasks">
|
||||
<HintPath>..\packages\Microsoft.Bcl.1.1.3\lib\portable-net40+sl4+win8+wp71\System.Threading.Tasks.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="APIException.cs" />
|
||||
<Compile Include="Components\Add.cs" />
|
||||
<Compile Include="Components\Authentification.cs" />
|
||||
<Compile Include="Components\Modify.cs" />
|
||||
<Compile Include="Components\ModifyTags.cs" />
|
||||
<Compile Include="Components\Retrieve.cs" />
|
||||
<Compile Include="JsonDeserializer.cs" />
|
||||
<Compile Include="JsonExtensions.cs" />
|
||||
<Compile Include="Models\Parameters\Parameter.cs" />
|
||||
<Compile Include="Models\Response\AccessCode.cs" />
|
||||
<Compile Include="Models\Response\RequestCode.cs" />
|
||||
<Compile Include="Models\Parameters\AddParameters.cs" />
|
||||
<Compile Include="Models\PocketAuthor.cs" />
|
||||
<Compile Include="Models\PocketImage.cs" />
|
||||
<Compile Include="Models\PocketVideo.cs" />
|
||||
<Compile Include="Models\Response\Add.cs" />
|
||||
<Compile Include="Models\Response\Modify.cs" />
|
||||
<Compile Include="Models\Parameters\ActionParameter.cs" />
|
||||
<Compile Include="Models\Parameters\ModifyParameters.cs" />
|
||||
<Compile Include="Models\Parameters\RetrieveParameters.cs" />
|
||||
<Compile Include="Models\PocketItem.cs" />
|
||||
<Compile Include="Models\PocketTag.cs" />
|
||||
<Compile Include="Models\Response\ResponseBase.cs" />
|
||||
<Compile Include="Models\Response\Retrieve.cs" />
|
||||
<Compile Include="PocketClient.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Utilities.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="authentication-screen.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
|
||||
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
|
||||
</Target>
|
||||
<Import Project="..\packages\Microsoft.Bcl.Build.1.0.10\tools\Microsoft.Bcl.Build.targets" Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.10\tools\Microsoft.Bcl.Build.targets')" />
|
||||
<Target Name="EnsureBclBuildImported" BeforeTargets="BeforeBuild" Condition="'$(BclBuildImported)' == ''">
|
||||
<Error Condition="!Exists('..\packages\Microsoft.Bcl.Build.1.0.10\tools\Microsoft.Bcl.Build.targets')" Text="This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=317567." HelpKeyword="BCLBUILD2001" />
|
||||
<Error Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.10\tools\Microsoft.Bcl.Build.targets')" Text="The build restored NuGet packages. Build the project again to include these packages in the build. For more information, see http://go.microsoft.com/fwlink/?LinkID=317568." HelpKeyword="BCLBUILD2002" />
|
||||
</Target>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Resources;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
@@ -25,4 +26,4 @@ using System.Runtime.InteropServices;
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("0.4.0")]
|
||||
[assembly: AssemblyFileVersion("0.4.0")]
|
||||
[assembly: AssemblyFileVersion("0.4.0")]
|
||||
@@ -4,5 +4,5 @@
|
||||
<package id="Microsoft.Bcl.Async" version="1.0.16" targetFramework="portable-net45+sl40+wp71+win" />
|
||||
<package id="Microsoft.Bcl.Build" version="1.0.10" targetFramework="portable-net45+sl40+wp71+win" />
|
||||
<package id="Microsoft.Net.Http" version="2.2.13" targetFramework="portable-net45+sl40+wp71+win" />
|
||||
<package id="Newtonsoft.Json" version="5.0.6" targetFramework="portable-net40+sl40+wp71+win" />
|
||||
<package id="Newtonsoft.Json" version="5.0.6" targetFramework="portable-net403+sl40+wp71+win" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user