always populate Items property with data; remove AddType as not necessary anymore;

This commit is contained in:
2013-12-04 19:34:59 +01:00
parent 3fd6842d25
commit bcb06380b2
4 changed files with 21 additions and 48 deletions
-8
View File
@@ -1,8 +0,0 @@
namespace PocketWP
{
public enum AddType
{
Single,
Multiple
}
}
+2 -20
View File
@@ -1,9 +1,9 @@
using System.Collections.Generic;
using PropertyChanged;
using System.Collections.Generic;
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Json;
using System.Text;
using PropertyChanged;
namespace PocketWP
{
@@ -11,15 +11,6 @@ namespace PocketWP
[DataContract]
public class PocketData
{
/// <summary>
/// Gets or sets the item.
/// </summary>
/// <value>
/// The item.
/// </value>
[DataMember]
public PocketDataItem Item { get; set; }
/// <summary>
/// Gets or sets the items.
/// </summary>
@@ -38,15 +29,6 @@ namespace PocketWP
[DataMember]
public string CallbackUri { get; set; }
/// <summary>
/// Gets the type.
/// </summary>
/// <value>
/// Single/Multiple items.
/// </value>
[DataMember]
public AddType Type { get; internal set; }
/// <summary>
/// Converts POCO to JSON.
/// </summary>
+19 -19
View File
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Runtime.Serialization.Json;
using System.Text;
@@ -37,15 +36,17 @@ namespace PocketWP
{
AddToPocket(new PocketData
{
Item = new PocketDataItem
Items = new List<PocketDataItem>()
{
Uri = uri,
Tags = tags,
Title = title,
TweetId = tweetId
new PocketDataItem
{
Uri = uri,
Tags = tags,
Title = title,
TweetId = tweetId
}
},
CallbackUri = callbackUri,
Type = AddType.Single
CallbackUri = callbackUri
});
}
@@ -59,19 +60,18 @@ namespace PocketWP
AddToPocket(new PocketData
{
Items = items,
CallbackUri = callbackUri,
Type = AddType.Multiple
CallbackUri = callbackUri
});
}
/// <summary>
/// Buries my nut.
/// Launch Pocket application URI with appended pocket data.
/// </summary>
/// <param name="data">The item.</param>
/// <param name="data">The pocket data.</param>
/// <exception cref="System.ArgumentNullException">item;Your nut can't be null</exception>
private static async void AddToPocket(PocketData data)
{
if (data == null)
if (data == null || data.Items == null)
{
throw new ArgumentNullException("data", "Your item can't be null");
}
@@ -82,21 +82,21 @@ namespace PocketWP
}
/// <summary>
/// Determines whether the specified URI has nuts.
/// Determines whether the specified URI contains pocket data.
/// </summary>
/// <param name="uri">The URI.</param>
/// <returns>True if nut is present</returns>
public static bool HasPocketItem(Uri uri)
/// <returns>True if pocket data is present</returns>
public static bool HasPocketData(Uri uri)
{
return uri.ToString().Contains(Uri.EscapeDataString(PocketUrl));
}
/// <summary>
/// Retrieves the nut.
/// Retrieves the pocket data.
/// </summary>
/// <param name="uri">The URI.</param>
/// <returns>The deserialised nut</returns>
public static PocketData RetrievePocketItem(Uri uri)
/// <returns>The deserialised pocket data</returns>
public static PocketData RetrievePocketData(Uri uri)
{
var pocketUri = uri.ToString().Replace("/Protocol?encodedLaunchUri=", string.Empty);
pocketUri = Uri.UnescapeDataString(pocketUri).Replace(PocketUrl, string.Empty);
-1
View File
@@ -87,7 +87,6 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Compile Include="AddType.cs" />
<Compile Include="PocketDataItem.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="PocketHelper.cs" />