add pocket video type

This commit is contained in:
2016-02-27 18:51:59 +01:00
parent bc2b17cc20
commit 48e75d21c0
4 changed files with 66 additions and 0 deletions
+10
View File
@@ -44,5 +44,15 @@ namespace PocketSharp.Models
/// </value>
[JsonProperty("src")]
public Uri Uri { get; set; }
/// <summary>
/// Gets or sets the URI.
/// </summary>
/// <value>
/// The URI.
/// </value>
[JsonProperty("type")]
[JsonConverter(typeof(VideoTypeConverter))]
public PocketVideoType Type { get; set; }
}
}
+11
View File
@@ -0,0 +1,11 @@
namespace PocketSharp.Models
{
public enum PocketVideoType
{
Unknown = 7,
YouTube = 1,
Vimeo = 2,
HTML = 5,
Flash = 6
}
}
+1
View File
@@ -63,6 +63,7 @@
<Compile Include="Models\PocketBoolean.cs" />
<Compile Include="Models\PocketLimits.cs" />
<Compile Include="Models\PocketStatistics.cs" />
<Compile Include="Models\PocketVideoType.cs" />
<Compile Include="Utilities\PocketAuthException.cs" />
<Compile Include="Utilities\PocketException.cs" />
<Compile Include="Components\Add.cs" />
+44
View File
@@ -201,4 +201,48 @@ namespace PocketSharp
return new PocketItem();
}
}
public class VideoTypeConverter : JsonConverter
{
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
writer.WriteValue(((PocketVideoType)value).ToString());
}
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
if (reader.Value == null)
{
return PocketVideoType.Unknown;
}
string nr = reader.Value.ToString();
if (nr == "1")
{
return PocketVideoType.YouTube;
}
if (nr == "2" || nr == "3" || nr == "4")
{
return PocketVideoType.Vimeo;
}
if (nr == "5")
{
return PocketVideoType.HTML;
}
if (nr == "6")
{
return PocketVideoType.Flash;
}
return PocketVideoType.Unknown;
}
public override bool CanConvert(Type objectType)
{
return objectType == typeof(int) || objectType == typeof(string);
}
}
}