21 Commits

Author SHA1 Message Date
swcs 1ca93bf07f update version 2014-06-17 10:46:00 +02:00
swcs 556e8004f3 fix Action parameter "url", so batch adding is working now 2014-06-17 10:45:24 +02:00
swcs 7cad855f9c return correct response status for "Send" 2014-06-17 10:14:26 +02:00
swcs 366908a070 fix json converter bug 2014-05-27 00:38:48 +02:00
swcs d141c7b255 fix deserializer bug 2014-05-11 23:07:49 +02:00
swcs 8531d20162 make PocketClient disposable 2014-05-11 22:59:06 +02:00
swcs 4f42ed719a separate HttpClient for parser API 2014-05-11 22:54:44 +02:00
swcs b46cc56362 implement ParserAPI func 2014-05-11 22:50:06 +02:00
swcs 500bd1c65d itemID prop for Tags; PocketArticle model 2014-05-11 22:26:08 +02:00
swcs a207ca7ca4 ConvertJsonToList 2014-05-03 18:54:19 +02:00
swcs 07c9f06f75 add IComparable and tostring/gethashcode to PocketItem 2014-05-02 17:59:26 +02:00
swcs a1ff132ba9 change assemblyversion 2014-05-01 18:14:17 +02:00
swcs 82896d6fb4 prevent creation of Lists and use IEnumerable where possible 2014-05-01 17:56:18 +02:00
swcs 36683c7402 add tags as string 2014-04-20 12:36:20 +02:00
swcs 4e5a8ab096 remove internal search and use official by Pocket 2014-04-17 10:26:59 +02:00
swcs 47baa0fd97 update docs 2014-04-05 11:44:03 +02:00
swcs ec25258de9 assembly version 2014-04-03 12:00:31 +02:00
swcs 6999185c96 remove unnecessary action in tests 2014-04-03 11:50:12 +02:00
swcs 7669d8880e first running version of new package 2014-04-03 11:45:00 +02:00
swcs 38b6a62686 add new test 2014-04-02 16:57:28 +02:00
swcs 0f7f626d15 update readme 2014-03-13 21:28:22 +01:00
57 changed files with 824 additions and 1466 deletions
+4
View File
@@ -1,3 +1,7 @@
### 4.0.0 (2014-04-03)
- Support for Universal apps (dropped SL and WP7 support)
### 3.2.0 (2014-03-13)
- add raw JSON to each PocketItem (PR #22)
@@ -1,8 +0,0 @@
<Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="PocketSharp.Silverlight.App"
>
<Application.Resources>
</Application.Resources>
</Application>
@@ -1,68 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
namespace PocketSharp.Silverlight
{
public partial class App : Application
{
public App()
{
this.Startup += this.Application_Startup;
this.Exit += this.Application_Exit;
this.UnhandledException += this.Application_UnhandledException;
InitializeComponent();
}
private void Application_Startup(object sender, StartupEventArgs e)
{
this.RootVisual = new MainPage();
}
private void Application_Exit(object sender, EventArgs e)
{
}
private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
{
// If the app is running outside of the debugger then report the exception using
// the browser's exception mechanism. On IE this will display it a yellow alert
// icon in the status bar and Firefox will display a script error.
if (!System.Diagnostics.Debugger.IsAttached)
{
// NOTE: This will allow the application to continue running after an exception has been thrown
// but not handled.
// For production applications this error handling should be replaced with something that will
// report the error to the website and stop the application.
e.Handled = true;
Deployment.Current.Dispatcher.BeginInvoke(delegate { ReportErrorToDOM(e); });
}
}
private void ReportErrorToDOM(ApplicationUnhandledExceptionEventArgs e)
{
try
{
string errorMsg = e.ExceptionObject.Message + e.ExceptionObject.StackTrace;
errorMsg = errorMsg.Replace('"', '\'').Replace("\r\n", @"\n");
System.Windows.Browser.HtmlPage.Window.Eval("throw new Error(\"Unhandled Error in Silverlight Application " + errorMsg + "\");");
}
catch (Exception)
{
}
}
}
}
@@ -1,16 +0,0 @@
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk" x:Class="PocketSharp.Silverlight.MainPage"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">
<Grid x:Name="LayoutRoot" Background="White">
<Button Content="Load Items" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Width="380" Height="34" Click="Button_Click"/>
<sdk:DataGrid x:Name="Content" HorizontalAlignment="Left" Height="241" Margin="10,49,0,0" VerticalAlignment="Top" Width="380" FrozenColumnCount="2"/>
</Grid>
</UserControl>
@@ -1,60 +0,0 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
namespace PocketSharp.Silverlight
{
public partial class MainPage : UserControl
{
ObservableCollection<Site> _Sites = new ObservableCollection<Site>();
public ObservableCollection<Site> Sites { get { return _Sites; } }
public class Site
{
public string Url { get; set; }
public string Content { get; set; }
}
public MainPage()
{
InitializeComponent();
}
private async void Button_Click(object sender, RoutedEventArgs e)
{
// !! please don't misuse this account !!
PocketClient client = new PocketClient(
consumerKey: "15396-f6f92101d72c8e270a6c9bb3",
callbackUri: "http://frontendplay.com",
accessCode: "80acf6c5-c198-03c0-b94c-e74402"
);
List<PocketSharp.Models.PocketItem> items = null;
try
{
items = await client.Get();
items.ForEach(item =>
{
Sites.Add(new Site()
{
Content = item.Title,
Url = item.Uri.ToString()
});
});
Content.ItemsSource = Sites;
}
catch (PocketException ex)
{
Debug.WriteLine(ex.Message);
}
}
}
}
@@ -1,172 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{656345D2-AF4C-4F88-9C9F-EBF54D7691DB}</ProjectGuid>
<ProjectTypeGuids>{A1591282-1198-4647-A2B1-27E5FF5F6F3B};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>PocketSharp.Silverlight</RootNamespace>
<AssemblyName>PocketSharp.Silverlight</AssemblyName>
<TargetFrameworkIdentifier>Silverlight</TargetFrameworkIdentifier>
<TargetFrameworkVersion>v5.0</TargetFrameworkVersion>
<SilverlightVersion>$(TargetFrameworkVersion)</SilverlightVersion>
<SilverlightApplication>true</SilverlightApplication>
<SupportedCultures>
</SupportedCultures>
<XapOutputs>true</XapOutputs>
<GenerateSilverlightManifest>true</GenerateSilverlightManifest>
<XapFilename>PocketSharp.Silverlight.xap</XapFilename>
<SilverlightManifestTemplate>Properties\AppManifest.xml</SilverlightManifestTemplate>
<SilverlightAppEntry>PocketSharp.Silverlight.App</SilverlightAppEntry>
<TestPageFileName>PocketSharp.SilverlightTestPage.html</TestPageFileName>
<CreateTestPage>true</CreateTestPage>
<ValidateXaml>true</ValidateXaml>
<EnableOutOfBrowser>false</EnableOutOfBrowser>
<OutOfBrowserSettingsFile>Properties\OutOfBrowserSettings.xml</OutOfBrowserSettingsFile>
<UsePlatformExtensions>false</UsePlatformExtensions>
<ThrowErrorsInValidation>true</ThrowErrorsInValidation>
<LinkedServerProject>
</LinkedServerProject>
<ExpressionBlendVersion>12.0.40612.10</ExpressionBlendVersion>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
<RestorePackages>true</RestorePackages>
</PropertyGroup>
<!-- This property group is only here to support building this project using the
MSBuild 3.5 toolset. In order to work correctly with this older toolset, it needs
to set the TargetFrameworkVersion to v3.5 -->
<PropertyGroup Condition="'$(MSBuildToolsVersion)' == '3.5'">
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>Bin\Debug</OutputPath>
<DefineConstants>DEBUG;TRACE;SILVERLIGHT</DefineConstants>
<NoStdLib>true</NoStdLib>
<NoConfig>true</NoConfig>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>Bin\Release</OutputPath>
<DefineConstants>TRACE;SILVERLIGHT</DefineConstants>
<NoStdLib>true</NoStdLib>
<NoConfig>true</NoConfig>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Threading.Tasks, Version=1.0.12.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\Microsoft.Bcl.Async.1.0.165\lib\sl4\Microsoft.Threading.Tasks.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Threading.Tasks.Extensions, Version=1.0.12.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\Microsoft.Bcl.Async.1.0.165\lib\sl4\Microsoft.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Threading.Tasks.Extensions.Silverlight, Version=1.0.165.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\Microsoft.Bcl.Async.1.0.165\lib\sl4\Microsoft.Threading.Tasks.Extensions.Silverlight.dll</HintPath>
</Reference>
<Reference Include="mscorlib" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.IO, Version=1.5.11.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\Microsoft.Bcl.1.1.6\lib\sl5\System.IO.dll</HintPath>
</Reference>
<Reference Include="System.Net.Http, Version=1.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\Microsoft.Net.Http.2.2.18\lib\portable-net40+sl4+win8+wp71\System.Net.Http.dll</HintPath>
</Reference>
<Reference Include="System.Net.Http.Extensions">
<HintPath>..\..\packages\Microsoft.Net.Http.2.2.18\lib\portable-net40+sl4+win8+wp71\System.Net.Http.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.Net.Http.Primitives, Version=1.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\Microsoft.Net.Http.2.2.18\lib\portable-net40+sl4+win8+wp71\System.Net.Http.Primitives.dll</HintPath>
</Reference>
<Reference Include="System.Runtime, Version=2.6.6.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\Microsoft.Bcl.1.1.6\lib\sl5\System.Runtime.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Tasks, Version=2.6.6.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\Microsoft.Bcl.1.1.6\lib\sl5\System.Threading.Tasks.dll</HintPath>
</Reference>
<Reference Include="System.Windows" />
<Reference Include="system" />
<Reference Include="System.Core">
<HintPath>$(TargetFrameworkDirectory)System.Core.dll</HintPath>
</Reference>
<Reference Include="System.Net" />
<Reference Include="System.Windows.Controls.Data" />
<Reference Include="System.Windows.Controls.Data.Input" />
<Reference Include="System.Windows.Data" />
<Reference Include="System.Xml" />
<Reference Include="System.Windows.Browser" />
</ItemGroup>
<ItemGroup>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
</Compile>
<Compile Include="MainPage.xaml.cs">
<DependentUpon>MainPage.xaml</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</ApplicationDefinition>
<Page Include="MainPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
<None Include="Properties\AppManifest.xml" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\PocketSharp\PocketSharp.csproj">
<Project>{817200c3-a327-4e35-9b5f-63a51c088577}</Project>
<Name>PocketSharp</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Silverlight\$(SilverlightVersion)\Microsoft.Silverlight.CSharp.targets" />
<!-- 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>
<Target Name="AfterBuild">
</Target>
-->
<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="{A1591282-1198-4647-A2B1-27E5FF5F6F3B}">
<SilverlightProjectProperties />
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
<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.13\tools\Microsoft.Bcl.Build.targets" Condition="Exists('..\..\packages\Microsoft.Bcl.Build.1.0.13\tools\Microsoft.Bcl.Build.targets')" />
<Target Name="EnsureBclBuildImported" BeforeTargets="BeforeBuild" Condition="'$(BclBuildImported)' == ''">
<Error Condition="!Exists('..\..\packages\Microsoft.Bcl.Build.1.0.13\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.13\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>
</Project>
@@ -1,6 +0,0 @@
<Deployment xmlns="http://schemas.microsoft.com/client/2007/deployment"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
>
<Deployment.Parts>
</Deployment.Parts>
</Deployment>
@@ -1,35 +0,0 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("PocketSharp.Silverlight")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("PocketSharp.Silverlight")]
[assembly: AssemblyCopyright("Copyright © 2013")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("656345d2-af4c-4f88-9c9f-ebf54d7691db")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
@@ -1,7 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Bcl" version="1.1.6" targetFramework="sl50" />
<package id="Microsoft.Bcl.Async" version="1.0.165" targetFramework="sl50" />
<package id="Microsoft.Bcl.Build" version="1.0.13" targetFramework="sl50" />
<package id="Microsoft.Net.Http" version="2.2.18" targetFramework="sl50" />
</packages>
@@ -130,6 +130,7 @@
</DesignData>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
<None Include="Properties\AppManifest.xml" />
<None Include="Properties\WMAppManifest.xml">
@@ -5,6 +5,7 @@ using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Threading.Tasks;
using System.Linq;
namespace PocketSharp.WP8.ViewModels
{
@@ -74,7 +75,7 @@ namespace PocketSharp.WP8.ViewModels
try
{
items = await client.Get();
items = (await client.Get()).ToList();
items.ForEach(item =>
{
@@ -4,11 +4,11 @@
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.6.3.0" newVersion="2.6.3.0" />
<bindingRedirect oldVersion="0.0.0.0-2.6.7.0" newVersion="2.6.7.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.6.3.0" newVersion="2.6.3.0" />
<bindingRedirect oldVersion="0.0.0.0-2.6.7.0" newVersion="2.6.7.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
@@ -2,6 +2,7 @@ using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Windows;
using System.Linq;
namespace PocketSharp.Wpf
{
@@ -40,7 +41,7 @@ namespace PocketSharp.Wpf
try
{
items = await client.Get();
items = (await client.Get()).ToList();
items.ForEach(item =>
{
+59 -2
View File
@@ -3,6 +3,7 @@ using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Xunit;
using System.Linq;
namespace PocketSharp.Tests
{
@@ -47,7 +48,7 @@ namespace PocketSharp.Tests
tweetID: "380051788172632065"
);
List<PocketItem> items = await client.Get();
List<PocketItem> items = (await client.Get()).ToList();
PocketItem itemDesired = null;
items.ForEach(itm =>
@@ -60,9 +61,65 @@ namespace PocketSharp.Tests
Assert.NotNull(itemDesired);
Assert.Equal(itemDesired.ID, item.ID);
Assert.Equal(itemDesired.Tags.Count, 3);
Assert.Equal(itemDesired.Tags.Count(), 3);
itemsToDelete.Add(item.ID);
}
[Fact]
public async Task ItemViaActionsIsAdded()
{
List<PocketAction> actions = new List<PocketAction>();
actions.Add(new PocketAction()
{
Uri = new Uri("http://frontendplay.com/story/4015/string-indexer-for-text-resources-in-nancy"),
Action = "add",
Time = DateTime.Now
});
bool success = await client.SendActions(actions);
Assert.True(success);
IEnumerable<PocketItem> items = await client.Search("in nancy");
Assert.NotNull(items);
Assert.True(items.Count() > 0);
itemsToDelete.Add(items.First().ID);
}
[Fact]
public async Task ItemsViaActionsIsAdded()
{
List<PocketAction> actions = new List<PocketAction>();
actions.Add(new PocketAction()
{
Uri = new Uri("http://frontendplay.com/story/4015/string-indexer-for-text-resources-in-nancy"),
Action = "add",
Time = DateTime.Now
});
actions.Add(new PocketAction()
{
Uri = new Uri("http://frontendplay.com/story/4013/build-a-custom-razor-viewbase-in-nancy"),
Action = "add",
Time = DateTime.Now
});
bool success = await client.SendActions(actions);
Assert.True(success);
IEnumerable<PocketItem> items = await client.Search("in nancy");
Assert.NotNull(items);
Assert.True(items.Count() == 2);
itemsToDelete.AddRange(items.Select(item => item.ID));
}
}
}
+45 -44
View File
@@ -5,6 +5,7 @@ using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Xunit;
using System.Linq;
namespace PocketSharp.Tests
{
@@ -16,7 +17,7 @@ namespace PocketSharp.Tests
[Fact]
public async Task AreItemsRetrieved()
{
List<PocketItem> items = await client.Get();
List<PocketItem> items = (await client.Get()).ToList();
Assert.True(items.Count > 0);
}
@@ -24,7 +25,7 @@ namespace PocketSharp.Tests
[Fact]
public async Task IsItemRetrievedById()
{
List<PocketItem> items = await client.Get();
List<PocketItem> items = (await client.Get()).ToList();
PocketItem item = items[0];
PocketItem itemDuplicate = await client.Get(item.ID);
@@ -35,7 +36,7 @@ namespace PocketSharp.Tests
[Fact]
public async Task IsItemJsonPopulated()
{
List<PocketItem> items = await client.Get();
List<PocketItem> items = (await client.Get()).ToList();
string schemaJson = @"{
'description': 'PocketItem',
'type': 'object'
@@ -53,16 +54,16 @@ namespace PocketSharp.Tests
[Fact]
public async Task AreFilteredItemsRetrieved()
{
List<PocketItem> items = await client.Get(RetrieveFilter.Favorite);
IEnumerable<PocketItem> items = await client.Get(RetrieveFilter.Favorite);
Assert.True(items.Count > 0);
Assert.True(items.Count() > 0);
}
[Fact]
public async Task RetrieveWithMultipleFilters()
{
List<PocketItem> items = await client.Get(
IEnumerable<PocketItem> items = await client.Get(
state: State.unread,
tag: "pocket",
sort: Sort.title,
@@ -70,29 +71,29 @@ namespace PocketSharp.Tests
count: 2
);
Assert.InRange<int>(items.Count, 0, 2);
Assert.InRange<int>(items.Count(), 0, 2);
}
[Fact]
public async Task ItemContainsUri()
{
List<PocketItem> items = await client.Get(count: 1);
IEnumerable<PocketItem> items = await client.Get(count: 1);
Assert.True(items.Count == 1);
Assert.True(items[0].Uri.ToString().StartsWith("http"));
Assert.True(items.Count() == 1);
Assert.True(items.First().Uri.ToString().StartsWith("http"));
}
[Fact]
public async Task InvalidRetrievalReturnsNoResults()
{
List<PocketItem> items = await client.Get(
IEnumerable<PocketItem> items = await client.Get(
favorite: true,
search: "xoiu987a#;"
);
Assert.False(items.Count > 0);
Assert.False(items.Count() > 0);
PocketItem item = await client.Get("99999999");
@@ -100,48 +101,48 @@ namespace PocketSharp.Tests
items = await client.Get(RetrieveFilter.Video);
Assert.False(items.Count > 0);
Assert.False(items.Count() > 0);
}
[Fact]
public async Task SearchReturnsResult()
{
List<PocketItem> items = await client.Search("pocket");
IEnumerable<PocketItem> items = await client.Search("pocket");
Assert.True(items.Count > 0);
Assert.True(items[0].FullTitle.ToLower().Contains("pocket"));
Assert.True(items.Count() > 0);
Assert.True(items.First().FullTitle.ToLower().Contains("pocket"));
}
[Fact]
public async Task InvalidSearchReturnsNoResult()
{
List<PocketItem> items = await client.Search("adsüasd-opiu2;.398dfyx");
IEnumerable<PocketItem> items = await client.Search("adsüasd-opiu2;.398dfyx");
Assert.False(items.Count > 0);
Assert.False(items.Count() > 0);
}
[Fact]
public async Task RetrieveTagsReturnsResult()
{
List<PocketTag> items = await client.GetTags();
IEnumerable<PocketTag> items = await client.GetTags();
Assert.True(items.Count > 0);
Assert.True(items.Count() > 0);
}
[Fact]
public async Task SearchByTagsReturnsResult()
{
List<PocketItem> items = await client.SearchByTag("pocket");
IEnumerable<PocketItem> items = await client.SearchByTag("pocket");
Assert.True(items.Count == 1);
Assert.True(items.Count() == 1);
bool found = false;
items[0].Tags.ForEach(tag =>
items.First().Tags.ToList().ForEach(tag =>
{
if (tag.Name.Contains("pocket"))
{
@@ -156,9 +157,9 @@ namespace PocketSharp.Tests
[Fact]
public async Task InvalidSearchByTagsReturnsNoResult()
{
List<PocketItem> items = await client.SearchByTag("adsüasd-opiu2;.398dfyx");
IEnumerable<PocketItem> items = await client.SearchByTag("adsüasd-opiu2;.398dfyx");
Assert.False(items.Count > 0);
Assert.False(items.Count() > 0);
}
@@ -183,10 +184,10 @@ namespace PocketSharp.Tests
[Fact]
public async Task IsNewPocketItemListGeneratorWorking()
{
List<PocketItem> items = await client.Get(count: 1, tag: "pocket");
PocketItem item = items[0];
IEnumerable<PocketItem> items = await client.Get(count: 1, tag: "pocket");
PocketItem item = items.First();
Assert.True(item.Tags.Find(i => i.Name == "pocket") != null);
Assert.True(item.Tags.ToList().Find(i => i.Name == "pocket") != null);
}
@@ -195,20 +196,20 @@ namespace PocketSharp.Tests
{
DateTime since = DateTime.UtcNow;
List<PocketItem> items = await client.Get(state: State.all);
PocketItem itemToModify = items[0];
IEnumerable<PocketItem> items = await client.Get(state: State.all);
PocketItem itemToModify = items.First();
Assert.True(items.Count >= 3);
Assert.True(items.Count() >= 3);
items = await client.Get(state: State.all, since: since);
Assert.True(items == null || items.Count == 0);
Assert.True(items == null || items.Count() == 0);
await client.AddTags(itemToModify, new string[] { "pocketsharp" });
items = await client.Get(state: State.all, since: since);
Assert.True(items.Count > 0);
Assert.True(items.Count() > 0);
await client.RemoveTags(itemToModify, new string[] { "pocketsharp" });
}
@@ -219,20 +220,20 @@ namespace PocketSharp.Tests
{
DateTime since = DateTime.UtcNow;
List<PocketItem> items = await client.Get(state: State.all);
PocketItem itemToModify = items[0];
IEnumerable<PocketItem> items = await client.Get(state: State.all);
PocketItem itemToModify = items.First();
Assert.True(items.Count >= 3);
Assert.True(items.Count() >= 3);
items = await client.Get(state: State.all, since: since);
Assert.True(items == null || items.Count == 0);
Assert.True(items == null || items.Count() == 0);
await client.Favorite(itemToModify);
items = await client.Get(state: State.all, since: since);
Assert.True(items.Count > 0);
Assert.True(items.Count() > 0);
await client.Unfavorite(itemToModify);
@@ -242,7 +243,7 @@ namespace PocketSharp.Tests
items = await client.Get(state: State.all, since: since);
Assert.True(items.Count > 0);
Assert.True(items.Count() > 0);
await client.Unarchive(itemToModify);
}
@@ -255,7 +256,7 @@ namespace PocketSharp.Tests
PocketItem item = await client.Add(new Uri("http://frontendplay.com"));
List<PocketItem> items = await client.Get(state: State.all, since: since);
IEnumerable<PocketItem> items = await client.Get(state: State.all, since: since);
since = DateTime.UtcNow;
@@ -263,7 +264,7 @@ namespace PocketSharp.Tests
items = await client.Get(state: State.all, since: since);
Assert.True(items.Count == 1 && items[0].IsDeleted);
Assert.True(items.Count() == 1 && items.First().IsDeleted);
}
[Fact]
@@ -271,11 +272,11 @@ namespace PocketSharp.Tests
{
PocketItem item = await client.Add(new Uri("http://de.ign.com/m/feature/21608/die-20-besten-kurzfilme-des-jahres-2013?bust=1"));
List<PocketItem> items = await client.Get(state: State.all);
IEnumerable<PocketItem> items = await client.Get(state: State.all);
Assert.NotNull(item.Uri);
Assert.NotNull(items[0].Uri);
Assert.Equal(item.Uri, items[0].Uri);
Assert.NotNull(items.First().Uri);
Assert.Equal(item.Uri, items.First().Uri);
itemsToDelete.Add(item.ID);
}
+3 -2
View File
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Xunit;
using System.Linq;
namespace PocketSharp.Tests
{
@@ -19,8 +20,8 @@ namespace PocketSharp.Tests
[Fact]
public async Task CheckPreRequestAction()
{
List<PocketItem> items = await client.Get(count: 1);
PocketItem item = items[0];
IEnumerable<PocketItem> items = await client.Get(count: 1);
PocketItem item = items.First();
await client.Favorite(item);
await client.Unfavorite(item);
+4 -4
View File
@@ -21,7 +21,7 @@ namespace PocketSharp.Tests
item = await GetItemById(item.ID);
Assert.True(item.Tags.Count >= 2);
Assert.True(item.Tags.Count() >= 2);
Assert.NotNull(item.Tags.Single<PocketTag>(tag => tag.Name == "test_tag"));
Assert.NotNull(item.Tags.Single<PocketTag>(tag => tag.Name == "test_tag2"));
@@ -44,7 +44,7 @@ namespace PocketSharp.Tests
item = await GetItemById(item.ID);
Assert.True(item.Tags.Count >= 2);
Assert.True(item.Tags.Count() >= 2);
Assert.True(await client.RemoveTags(item));
@@ -63,7 +63,7 @@ namespace PocketSharp.Tests
item = await GetItemById(item.ID);
Assert.Equal(item.Tags.Count, 2);
Assert.Equal(item.Tags.Count(), 2);
Assert.NotNull(item.Tags.SingleOrDefault<PocketTag>(tag => tag.Name == "test_tag"));
Assert.NotNull(item.Tags.SingleOrDefault<PocketTag>(tag => tag.Name == "test_tag2"));
@@ -85,7 +85,7 @@ namespace PocketSharp.Tests
private async Task<PocketItem> GetItemById(string id, bool archive = false)
{
List<PocketItem> items = await client.Get(state: archive ? State.archive : State.unread);
List<PocketItem> items = (await client.Get(state: archive ? State.archive : State.unread)).ToList();
PocketItem itemDesired = null;
items.ForEach(itm =>
+23 -4
View File
@@ -72,8 +72,7 @@ namespace PocketSharp.Tests
{
new PocketAction() { Action = "favorite", ID = item.ID },
new PocketAction() { Action = "tags_add", ID = item.ID, Tags = new string[] { "new_tag", "another_tag" } },
new PocketAction() { Action = "archive", ID = item.ID },
new PocketAction() { Action = "tag_rename", ID = item.ID, OldTag = "social", NewTag = "not_social" }
new PocketAction() { Action = "archive", ID = item.ID }
});
Assert.True(success);
@@ -84,7 +83,6 @@ namespace PocketSharp.Tests
Assert.True(item.IsArchive);
Assert.NotNull(item.Tags.Single<PocketTag>(tag => tag.Name == "new_tag"));
Assert.NotNull(item.Tags.Single<PocketTag>(tag => tag.Name == "another_tag"));
Assert.NotNull(item.Tags.Single<PocketTag>(tag => tag.Name == "not_social"));
}
@@ -103,6 +101,27 @@ namespace PocketSharp.Tests
}
[Fact]
public async Task AreMultipleActionsOnOneItemPerformed()
{
PocketItem item = await Setup();
bool success = await client.SendActions(new List<PocketAction>()
{
new PocketAction() { Action = "unarchive", ID = item.ID },
new PocketAction() { Action = "archive", ID = item.ID },
new PocketAction() { Action = "unfavorite", ID = item.ID }
});
Assert.True(success);
item = await client.Get(item.ID);
Assert.False(item.IsFavorite);
Assert.True(item.IsArchive);
}
private async Task<PocketItem> Setup()
{
PocketItem item = await client.Add(
@@ -118,7 +137,7 @@ namespace PocketSharp.Tests
private async Task<PocketItem> GetItemById(string id, bool archive = false)
{
List<PocketItem> items = await client.Get(state: archive ? State.archive : State.unread);
List<PocketItem> items = (await client.Get(state: archive ? State.archive : State.unread)).ToList();
PocketItem itemDesired = null;
items.ForEach(itm =>
+14 -11
View File
@@ -39,26 +39,29 @@
<ItemGroup>
<Reference Include="Microsoft.Threading.Tasks, Version=1.0.12.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Microsoft.Bcl.Async.1.0.165\lib\net45\Microsoft.Threading.Tasks.dll</HintPath>
<HintPath>..\packages\Microsoft.Bcl.Async.1.0.166\lib\net40\Microsoft.Threading.Tasks.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Threading.Tasks.Extensions, Version=1.0.12.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Microsoft.Bcl.Async.1.0.165\lib\net45\Microsoft.Threading.Tasks.Extensions.dll</HintPath>
<HintPath>..\packages\Microsoft.Bcl.Async.1.0.166\lib\net40\Microsoft.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<Reference Include="Microsoft.Threading.Tasks.Extensions.Desktop">
<HintPath>..\packages\Microsoft.Bcl.Async.1.0.166\lib\net40\Microsoft.Threading.Tasks.Extensions.Desktop.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Newtonsoft.Json.5.0.8\lib\net45\Newtonsoft.Json.dll</HintPath>
<HintPath>..\packages\Newtonsoft.Json.6.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Net" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Net.Http.Extensions, Version=2.2.18.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Reference Include="System.Net.Http.Extensions, Version=2.2.19.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Microsoft.Net.Http.2.2.18\lib\net45\System.Net.Http.Extensions.dll</HintPath>
<HintPath>..\packages\Microsoft.Net.Http.2.2.19\lib\net45\System.Net.Http.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.Net.Http.Primitives, Version=4.2.18.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Reference Include="System.Net.Http.Primitives, Version=4.2.19.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Microsoft.Net.Http.2.2.18\lib\net45\System.Net.Http.Primitives.dll</HintPath>
<HintPath>..\packages\Microsoft.Net.Http.2.2.19\lib\net45\System.Net.Http.Primitives.dll</HintPath>
</Reference>
<Reference Include="System.Net.Http.WebRequest" />
<Reference Include="xunit">
@@ -123,10 +126,10 @@
</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.13\tools\Microsoft.Bcl.Build.targets" Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.13\tools\Microsoft.Bcl.Build.targets')" />
<Import Project="..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets" Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" />
<Target Name="EnsureBclBuildImported" BeforeTargets="BeforeBuild" Condition="'$(BclBuildImported)' == ''">
<Error Condition="!Exists('..\packages\Microsoft.Bcl.Build.1.0.13\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.13\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" />
<Error Condition="!Exists('..\packages\Microsoft.Bcl.Build.1.0.14\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.14\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.
Other similar extension points exist, see Microsoft.Common.targets.
+15 -15
View File
@@ -30,50 +30,50 @@ namespace PocketSharp.Tests
[Fact]
public async Task Are100ItemsRetrievedProperly()
{
List<PocketItem> items = await client.Get(count: 100, state: State.all);
Assert.True(items.Count == 100);
IEnumerable<PocketItem> items = await client.Get(count: 100, state: State.all);
Assert.True(items.Count() == 100);
}
[Fact]
public async Task Are1000ItemsRetrievedProperly()
{
List<PocketItem> items = await client.Get(count: 1000, state: State.all);
Assert.True(items.Count == 1000);
IEnumerable<PocketItem> items = await client.Get(count: 1000, state: State.all);
Assert.True(items.Count() == 1000);
}
[Fact]
public async Task Are2500ItemsRetrievedProperly()
{
List<PocketItem> items = await client.Get(count: 2500, state: State.all);
Assert.True(items.Count == 2500);
IEnumerable<PocketItem> items = await client.Get(count: 2500, state: State.all);
Assert.True(items.Count() == 2500);
}
[Fact]
public async Task Are5000ItemsRetrievedProperly()
{
List<PocketItem> items = await client.Get(count: 5000, state: State.all);
Assert.True(items.Count == 5000);
IEnumerable<PocketItem> items = await client.Get(count: 5000, state: State.all);
Assert.True(items.Count() == 5000);
}
[Fact]
public async Task IsSearchSuccessfullyOnBigList()
{
List<PocketItem> items = await client.Get(search: "google");
IEnumerable<PocketItem> items = await client.Get(search: "google");
Assert.True(items.Count > 0);
Assert.True(items[0].Title.ToLower().Contains("google") || items[0].Uri.ToString().ToLower().Contains("google"));
Assert.True(items.Count() > 0);
Assert.True(items.First().Title.ToLower().Contains("google") || items.First().Uri.ToString().ToLower().Contains("google"));
}
[Fact]
public async Task IsTagSearchSuccessfullyOnBigList()
{
List<PocketItem> items = await client.SearchByTag(tags[0]);
IEnumerable<PocketItem> items = await client.SearchByTag(tags[0]);
Assert.True(items.Count > 1);
Assert.True(items.Count() > 1);
bool found = false;
items[0].Tags.ForEach(tag =>
items.First().Tags.ToList().ForEach(tag =>
{
if (tag.Name.Contains(tags[0]))
{
@@ -87,7 +87,7 @@ namespace PocketSharp.Tests
[Fact]
public async Task RetrieveTagsReturnsResultOnBigList()
{
List<PocketTag> items = await client.GetTags();
List<PocketTag> items = (await client.GetTags()).ToList();
items.ForEach(tag =>
{
+1 -1
View File
@@ -4,7 +4,7 @@
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Net.Http.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.18.0" newVersion="4.2.18.0" />
<bindingRedirect oldVersion="0.0.0.0-4.2.19.0" newVersion="4.2.19.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
+5 -5
View File
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Bcl" version="1.1.6" targetFramework="net45" />
<package id="Microsoft.Bcl.Async" version="1.0.165" targetFramework="net45" />
<package id="Microsoft.Bcl.Build" version="1.0.13" targetFramework="net45" />
<package id="Microsoft.Net.Http" version="2.2.18" targetFramework="net45" />
<package id="Newtonsoft.Json" version="5.0.8" targetFramework="net45" />
<package id="Microsoft.Bcl" version="1.1.7" targetFramework="net45" />
<package id="Microsoft.Bcl.Async" version="1.0.166" targetFramework="net45" />
<package id="Microsoft.Bcl.Build" version="1.0.14" targetFramework="net45" />
<package id="Microsoft.Net.Http" version="2.2.19" targetFramework="net45" />
<package id="Newtonsoft.Json" version="6.0.2" targetFramework="net45" />
<package id="xunit" version="1.9.2" targetFramework="net45" />
</packages>
-19
View File
@@ -1,19 +0,0 @@
<Application
x:Class="PocketSharp.WP7.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone">
<!--Application Resources-->
<Application.Resources>
</Application.Resources>
<Application.ApplicationLifetimeObjects>
<!--Required object that handles lifetime events for the application-->
<shell:PhoneApplicationService
Launching="Application_Launching" Closing="Application_Closing"
Activated="Application_Activated" Deactivated="Application_Deactivated"/>
</Application.ApplicationLifetimeObjects>
</Application>
-151
View File
@@ -1,151 +0,0 @@
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using PocketSharp.WP7.ViewModels;
using System.Windows;
using System.Windows.Navigation;
namespace PocketSharp.WP7
{
public partial class App : Application
{
private static MainViewModel viewModel = null;
/// <summary>
/// A static ViewModel used by the views to bind against.
/// </summary>
/// <returns>The MainViewModel object.</returns>
public static MainViewModel ViewModel
{
get
{
// Delay creation of the view model until necessary
if (viewModel == null)
viewModel = new MainViewModel();
return viewModel;
}
}
/// <summary>
/// Provides easy access to the root frame of the Phone Application.
/// </summary>
/// <returns>The root frame of the Phone Application.</returns>
public PhoneApplicationFrame RootFrame { get; private set; }
/// <summary>
/// Constructor for the Application object.
/// </summary>
public App()
{
// Global handler for uncaught exceptions.
UnhandledException += Application_UnhandledException;
// Standard Silverlight initialization
InitializeComponent();
// Phone-specific initialization
InitializePhoneApplication();
// Show graphics profiling information while debugging.
if (System.Diagnostics.Debugger.IsAttached)
{
// Display the current frame rate counters.
Application.Current.Host.Settings.EnableFrameRateCounter = true;
// Show the areas of the app that are being redrawn in each frame.
//Application.Current.Host.Settings.EnableRedrawRegions = true;
// Enable non-production analysis visualization mode,
// which shows areas of a page that are handed off to GPU with a colored overlay.
//Application.Current.Host.Settings.EnableCacheVisualization = true;
// Disable the application idle detection by setting the UserIdleDetectionMode property of the
// application's PhoneApplicationService object to Disabled.
// Caution:- Use this under debug mode only. Application that disables user idle detection will continue to run
// and consume battery power when the user is not using the phone.
PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;
}
}
// Code to execute when the application is launching (eg, from Start)
// This code will not execute when the application is reactivated
private void Application_Launching(object sender, LaunchingEventArgs e)
{
}
// Code to execute when the application is activated (brought to foreground)
// This code will not execute when the application is first launched
private void Application_Activated(object sender, ActivatedEventArgs e)
{
}
// Code to execute when the application is deactivated (sent to background)
// This code will not execute when the application is closing
private void Application_Deactivated(object sender, DeactivatedEventArgs e)
{
}
// Code to execute when the application is closing (eg, user hit Back)
// This code will not execute when the application is deactivated
private void Application_Closing(object sender, ClosingEventArgs e)
{
}
// Code to execute if a navigation fails
private void RootFrame_NavigationFailed(object sender, NavigationFailedEventArgs e)
{
if (System.Diagnostics.Debugger.IsAttached)
{
// A navigation has failed; break into the debugger
System.Diagnostics.Debugger.Break();
}
}
// Code to execute on Unhandled Exceptions
private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
{
if (System.Diagnostics.Debugger.IsAttached)
{
// An unhandled exception has occurred; break into the debugger
System.Diagnostics.Debugger.Break();
}
}
#region Phone application initialization
// Avoid double-initialization
private bool phoneApplicationInitialized = false;
// Do not add any additional code to this method
private void InitializePhoneApplication()
{
if (phoneApplicationInitialized)
return;
// Create the frame but don't set it as RootVisual yet; this allows the splash
// screen to remain active until the application is ready to render.
RootFrame = new PhoneApplicationFrame();
RootFrame.Navigated += CompleteInitializePhoneApplication;
// Handle navigation failures
RootFrame.NavigationFailed += RootFrame_NavigationFailed;
// Ensure we don't initialize again
phoneApplicationInitialized = true;
}
// Do not add any additional code to this method
private void CompleteInitializePhoneApplication(object sender, NavigationEventArgs e)
{
// Set the root visual to allow the application to render
if (RootVisual != RootFrame)
RootVisual = RootFrame;
// Remove this handler since it is no longer needed
RootFrame.Navigated -= CompleteInitializePhoneApplication;
}
#endregion
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

-45
View File
@@ -1,45 +0,0 @@
<phone:PhoneApplicationPage
x:Class="PocketSharp.WP7.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
shell:SystemTray.IsVisible="True">
<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!--TitlePanel contains the name of the application and page title-->
<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
<TextBlock x:Name="ApplicationTitle" Text="MY APPLICATION" Style="{StaticResource PhoneTextNormalStyle}"/>
<TextBlock x:Name="PageTitle" Text="page name" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
<Button Click="Button_Click">Load Data</Button>
</StackPanel>
<!--ContentPanel contains LongListSelector and LongListSelector ItemTemplate. Place additional content here-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<ListBox x:Name="MainLongListSelector" Margin="0,0,-12,0" ItemsSource="{Binding Items}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Margin="0,0,0,17">
<TextBlock Text="{Binding LineOne}" TextWrapping="Wrap" Style="{StaticResource PhoneTextExtraLargeStyle}"/>
<TextBlock Text="{Binding LineTwo}" TextWrapping="Wrap" Margin="12,-6,12,0" Style="{StaticResource PhoneTextSubtleStyle}"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</Grid>
</phone:PhoneApplicationPage>
-22
View File
@@ -1,22 +0,0 @@
using Microsoft.Phone.Controls;
using System.Windows;
namespace PocketSharp.WP7
{
public partial class MainPage : PhoneApplicationPage
{
// Constructor
public MainPage()
{
InitializeComponent();
// Set the data context of the LongListSelector control to the sample data
DataContext = App.ViewModel;
}
private async void Button_Click(object sender, RoutedEventArgs e)
{
await App.ViewModel.LoadData();
}
}
}
-155
View File
@@ -1,155 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>10.0.20506</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{6F542037-C48B-4EC5-A326-DDBEBF5FDFA2}</ProjectGuid>
<ProjectTypeGuids>{C089C8C0-30E0-4E22-80C0-CE093F111A43};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>PocketSharp.WP7</RootNamespace>
<AssemblyName>PocketSharp.WP7</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<SilverlightVersion>$(TargetFrameworkVersion)</SilverlightVersion>
<TargetFrameworkProfile>WindowsPhone71</TargetFrameworkProfile>
<TargetFrameworkIdentifier>Silverlight</TargetFrameworkIdentifier>
<SilverlightApplication>true</SilverlightApplication>
<SupportedCultures>
</SupportedCultures>
<XapOutputs>true</XapOutputs>
<GenerateSilverlightManifest>true</GenerateSilverlightManifest>
<XapFilename>PocketSharp.WP7.xap</XapFilename>
<SilverlightManifestTemplate>Properties\AppManifest.xml</SilverlightManifestTemplate>
<SilverlightAppEntry>PocketSharp.WP7.App</SilverlightAppEntry>
<ValidateXaml>true</ValidateXaml>
<ThrowErrorsInValidation>true</ThrowErrorsInValidation>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<RestorePackages>true</RestorePackages>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>Bin\Debug</OutputPath>
<DefineConstants>DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
<NoStdLib>true</NoStdLib>
<NoConfig>true</NoConfig>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>Bin\Release</OutputPath>
<DefineConstants>TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
<NoStdLib>true</NoStdLib>
<NoConfig>true</NoConfig>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Phone" />
<Reference Include="Microsoft.Phone.Interop" />
<Reference Include="Microsoft.Threading.Tasks">
<HintPath>..\packages\Microsoft.Bcl.Async.1.0.165\lib\sl4-windowsphone71\Microsoft.Threading.Tasks.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Threading.Tasks.Extensions">
<HintPath>..\packages\Microsoft.Bcl.Async.1.0.165\lib\sl4-windowsphone71\Microsoft.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Threading.Tasks.Extensions.Phone">
<HintPath>..\packages\Microsoft.Bcl.Async.1.0.165\lib\sl4-windowsphone71\Microsoft.Threading.Tasks.Extensions.Phone.dll</HintPath>
</Reference>
<Reference Include="System.IO, Version=1.5.11.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Microsoft.Bcl.1.1.6\lib\sl4-windowsphone71\System.IO.dll</HintPath>
</Reference>
<Reference Include="System.Net.Http">
<HintPath>..\packages\Microsoft.Net.Http.2.2.18\lib\sl4-windowsphone71\System.Net.Http.dll</HintPath>
</Reference>
<Reference Include="System.Net.Http.Extensions">
<HintPath>..\packages\Microsoft.Net.Http.2.2.18\lib\sl4-windowsphone71\System.Net.Http.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.Net.Http.Primitives">
<HintPath>..\packages\Microsoft.Net.Http.2.2.18\lib\sl4-windowsphone71\System.Net.Http.Primitives.dll</HintPath>
</Reference>
<Reference Include="System.Runtime, Version=1.5.11.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Microsoft.Bcl.1.1.6\lib\sl4-windowsphone71\System.Runtime.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Tasks, Version=1.5.11.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Microsoft.Bcl.1.1.6\lib\sl4-windowsphone71\System.Threading.Tasks.dll</HintPath>
</Reference>
<Reference Include="System.Windows" />
<Reference Include="system" />
<Reference Include="System.Core" />
<Reference Include="System.Net" />
<Reference Include="System.Xml" />
<Reference Include="mscorlib.extensions" />
</ItemGroup>
<ItemGroup>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
</Compile>
<Compile Include="MainPage.xaml.cs">
<DependentUpon>MainPage.xaml</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ViewModels\ItemViewModel.cs" />
<Compile Include="ViewModels\MainViewModel.cs" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</ApplicationDefinition>
<Page Include="MainPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<None Include="Properties\AppManifest.xml" />
<None Include="Properties\WMAppManifest.xml" />
</ItemGroup>
<ItemGroup>
<Content Include="ApplicationIcon.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Background.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="SplashScreenImage.jpg" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\PocketSharp\PocketSharp.csproj">
<Project>{817200C3-A327-4E35-9B5F-63A51C088577}</Project>
<Name>PocketSharp</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\Silverlight for Phone\$(TargetFrameworkVersion)\Microsoft.Silverlight.$(TargetFrameworkProfile).Overrides.targets" />
<Import Project="$(MSBuildExtensionsPath)\Microsoft\Silverlight for Phone\$(TargetFrameworkVersion)\Microsoft.Silverlight.CSharp.targets" />
<!-- 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>
<Target Name="AfterBuild">
</Target>
-->
<ProjectExtensions />
<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.13\tools\Microsoft.Bcl.Build.targets" Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.13\tools\Microsoft.Bcl.Build.targets')" />
<Target Name="EnsureBclBuildImported" BeforeTargets="BeforeBuild" Condition="'$(BclBuildImported)' == ''">
<Error Condition="!Exists('..\packages\Microsoft.Bcl.Build.1.0.13\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.13\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>
</Project>
@@ -1,6 +0,0 @@
<Deployment xmlns="http://schemas.microsoft.com/client/2007/deployment"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
>
<Deployment.Parts>
</Deployment.Parts>
</Deployment>
@@ -1,37 +0,0 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Resources;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("PocketSharp.WP7")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("PocketSharp.WP7")]
[assembly: AssemblyCopyright("Copyright © 2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("775e1575-245f-45be-85f8-e6289b22b330")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: NeutralResourcesLanguageAttribute("en-US")]
@@ -1,35 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Deployment xmlns="http://schemas.microsoft.com/windowsphone/2009/deployment" AppPlatformVersion="7.1">
<App xmlns="" ProductID="{6f542037-c48b-4ec5-a326-ddbebf5fdfa2}" Title="PocketSharp.WP7" RuntimeType="Silverlight" Version="1.0.0.0" Genre="apps.normal" Author="PocketSharp.WP7 author" Description="Sample description" Publisher="PocketSharp.WP7">
<IconPath IsRelative="true" IsResource="false">ApplicationIcon.png</IconPath>
<Capabilities>
<Capability Name="ID_CAP_GAMERSERVICES"/>
<Capability Name="ID_CAP_IDENTITY_DEVICE"/>
<Capability Name="ID_CAP_IDENTITY_USER"/>
<Capability Name="ID_CAP_LOCATION"/>
<Capability Name="ID_CAP_MEDIALIB"/>
<Capability Name="ID_CAP_MICROPHONE"/>
<Capability Name="ID_CAP_NETWORKING"/>
<Capability Name="ID_CAP_PHONEDIALER"/>
<Capability Name="ID_CAP_PUSH_NOTIFICATION"/>
<Capability Name="ID_CAP_SENSORS"/>
<Capability Name="ID_CAP_WEBBROWSERCOMPONENT"/>
<Capability Name="ID_CAP_ISV_CAMERA"/>
<Capability Name="ID_CAP_CONTACTS"/>
<Capability Name="ID_CAP_APPOINTMENTS"/>
</Capabilities>
<Tasks>
<DefaultTask Name ="_default" NavigationPage="MainPage.xaml"/>
</Tasks>
<Tokens>
<PrimaryToken TokenID="PocketSharp.WP7Token" TaskName="_default">
<TemplateType5>
<BackgroundImageURI IsRelative="true" IsResource="false">Background.png</BackgroundImageURI>
<Count>0</Count>
<Title>PocketSharp.WP7</Title>
</TemplateType5>
</PrimaryToken>
</Tokens>
</App>
</Deployment>
Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.2 KiB

-102
View File
@@ -1,102 +0,0 @@
using System;
using System.ComponentModel;
namespace PocketSharp.WP7.ViewModels
{
public class ItemViewModel : INotifyPropertyChanged
{
private string _id;
/// <summary>
/// Sample ViewModel property; this property is used to identify the object.
/// </summary>
/// <returns></returns>
public string ID
{
get
{
return _id;
}
set
{
if (value != _id)
{
_id = value;
NotifyPropertyChanged("ID");
}
}
}
private string _lineOne;
/// <summary>
/// Sample ViewModel property; this property is used in the view to display its value using a Binding.
/// </summary>
/// <returns></returns>
public string LineOne
{
get
{
return _lineOne;
}
set
{
if (value != _lineOne)
{
_lineOne = value;
NotifyPropertyChanged("LineOne");
}
}
}
private string _lineTwo;
/// <summary>
/// Sample ViewModel property; this property is used in the view to display its value using a Binding.
/// </summary>
/// <returns></returns>
public string LineTwo
{
get
{
return _lineTwo;
}
set
{
if (value != _lineTwo)
{
_lineTwo = value;
NotifyPropertyChanged("LineTwo");
}
}
}
private string _lineThree;
/// <summary>
/// Sample ViewModel property; this property is used in the view to display its value using a Binding.
/// </summary>
/// <returns></returns>
public string LineThree
{
get
{
return _lineThree;
}
set
{
if (value != _lineThree)
{
_lineThree = value;
NotifyPropertyChanged("LineThree");
}
}
}
public event PropertyChangedEventHandler PropertyChanged;
private void NotifyPropertyChanged(String propertyName)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (null != handler)
{
handler(this, new PropertyChangedEventArgs(propertyName));
}
}
}
}
-106
View File
@@ -1,106 +0,0 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Threading.Tasks;
namespace PocketSharp.WP7.ViewModels
{
public class MainViewModel : INotifyPropertyChanged
{
public MainViewModel()
{
this.Items = new ObservableCollection<ItemViewModel>();
}
/// <summary>
/// A collection for ItemViewModel objects.
/// </summary>
public ObservableCollection<ItemViewModel> Items { get; private set; }
private string _sampleProperty = "Sample Runtime Property Value";
/// <summary>
/// Sample ViewModel property; this property is used in the view to display its value using a Binding
/// </summary>
/// <returns></returns>
public string SampleProperty
{
get
{
return _sampleProperty;
}
set
{
if (value != _sampleProperty)
{
_sampleProperty = value;
NotifyPropertyChanged("SampleProperty");
}
}
}
/// <summary>
/// Sample property that returns a localized string
/// </summary>
public string LocalizedSampleProperty
{
get
{
return "test";
}
}
public bool IsDataLoaded
{
get;
private set;
}
/// <summary>
/// Creates and adds a few ItemViewModel objects into the Items collection.
/// </summary>
public async Task LoadData()
{
// !! please don't misuse this account !!
PocketClient client = new PocketClient(
consumerKey: "15396-f6f92101d72c8e270a6c9bb3",
callbackUri: "http://frontendplay.com",
accessCode: "80acf6c5-c198-03c0-b94c-e74402"
);
List<PocketSharp.Models.PocketItem> items = null;
try
{
items = await client.Get();
items.ForEach(item =>
{
this.Items.Add(new ItemViewModel()
{
ID = item.ID.ToString(),
LineOne = item.Title,
LineTwo = item.Uri.ToString()
});
});
}
catch (PocketException ex)
{
Debug.WriteLine(ex.Message);
}
this.IsDataLoaded = true;
}
public event PropertyChangedEventHandler PropertyChanged;
private void NotifyPropertyChanged(String propertyName)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (null != handler)
{
handler(this, new PropertyChangedEventArgs(propertyName));
}
}
}
}
-7
View File
@@ -1,7 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Bcl" version="1.1.6" targetFramework="wp71" />
<package id="Microsoft.Bcl.Async" version="1.0.165" targetFramework="wp71" />
<package id="Microsoft.Bcl.Build" version="1.0.13" targetFramework="wp71" />
<package id="Microsoft.Net.Http" version="2.2.18" targetFramework="wp71" />
</packages>
+13 -35
View File
@@ -1,20 +1,9 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PocketSharp", "PocketSharp\PocketSharp.csproj", "{817200C3-A327-4E35-9B5F-63A51C088577}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PocketSharp.Wpf", "PocketSharp.Examples\PocketSharp.Wpf\PocketSharp.Wpf.csproj", "{775569C2-987F-4AC4-8BA5-A315A21ED1B7}"
ProjectSection(ProjectDependencies) = postProject
{817200C3-A327-4E35-9B5F-63A51C088577} = {817200C3-A327-4E35-9B5F-63A51C088577}
EndProjectSection
EndProject
# Visual Studio 2013
VisualStudioVersion = 12.0.30324.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "PocketSharp.Examples", "PocketSharp.Examples", "{AFD4E3F1-B23C-4924-BA5B-D917FBADB8FA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PocketSharp.Silverlight", "PocketSharp.Examples\PocketSharp.Silverlight\PocketSharp.Silverlight.csproj", "{656345D2-AF4C-4F88-9C9F-EBF54D7691DB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PocketSharp.WP8", "PocketSharp.Examples\PocketSharp.WP8\PocketSharp.WP8.csproj", "{47721A56-2128-4C5A-8B92-995FFC353304}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PocketSharp.Tests", "PocketSharp.Tests\PocketSharp.Tests.csproj", "{CA3C491B-A8CA-426C-A0BB-E91636767467}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{19DD45B5-B849-49E7-89D6-16C89B9B96C7}"
ProjectSection(SolutionItems) = preProject
.nuget\NuGet.Config = .nuget\NuGet.Config
@@ -22,7 +11,16 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{19DD45
.nuget\NuGet.targets = .nuget\NuGet.targets
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PocketSharp.WP7", "PocketSharp.WP7\PocketSharp.WP7.csproj", "{6F542037-C48B-4EC5-A326-DDBEBF5FDFA2}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PocketSharp", "PocketSharp\PocketSharp.csproj", "{817200C3-A327-4E35-9B5F-63A51C088577}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PocketSharp.Wpf", "PocketSharp.Examples\PocketSharp.Wpf\PocketSharp.Wpf.csproj", "{775569C2-987F-4AC4-8BA5-A315A21ED1B7}"
ProjectSection(ProjectDependencies) = postProject
{817200C3-A327-4E35-9B5F-63A51C088577} = {817200C3-A327-4E35-9B5F-63A51C088577}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PocketSharp.WP8", "PocketSharp.Examples\PocketSharp.WP8\PocketSharp.WP8.csproj", "{47721A56-2128-4C5A-8B92-995FFC353304}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PocketSharp.Tests", "PocketSharp.Tests\PocketSharp.Tests.csproj", "{CA3C491B-A8CA-426C-A0BB-E91636767467}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -51,14 +49,6 @@ Global
{775569C2-987F-4AC4-8BA5-A315A21ED1B7}.Release|Any CPU.Build.0 = Release|Any CPU
{775569C2-987F-4AC4-8BA5-A315A21ED1B7}.Release|ARM.ActiveCfg = Release|Any CPU
{775569C2-987F-4AC4-8BA5-A315A21ED1B7}.Release|x86.ActiveCfg = Release|Any CPU
{656345D2-AF4C-4F88-9C9F-EBF54D7691DB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{656345D2-AF4C-4F88-9C9F-EBF54D7691DB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{656345D2-AF4C-4F88-9C9F-EBF54D7691DB}.Debug|ARM.ActiveCfg = Debug|Any CPU
{656345D2-AF4C-4F88-9C9F-EBF54D7691DB}.Debug|x86.ActiveCfg = Debug|Any CPU
{656345D2-AF4C-4F88-9C9F-EBF54D7691DB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{656345D2-AF4C-4F88-9C9F-EBF54D7691DB}.Release|Any CPU.Build.0 = Release|Any CPU
{656345D2-AF4C-4F88-9C9F-EBF54D7691DB}.Release|ARM.ActiveCfg = Release|Any CPU
{656345D2-AF4C-4F88-9C9F-EBF54D7691DB}.Release|x86.ActiveCfg = Release|Any CPU
{47721A56-2128-4C5A-8B92-995FFC353304}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{47721A56-2128-4C5A-8B92-995FFC353304}.Debug|Any CPU.Build.0 = Debug|Any CPU
{47721A56-2128-4C5A-8B92-995FFC353304}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
@@ -85,24 +75,12 @@ Global
{CA3C491B-A8CA-426C-A0BB-E91636767467}.Release|Any CPU.Build.0 = Release|Any CPU
{CA3C491B-A8CA-426C-A0BB-E91636767467}.Release|ARM.ActiveCfg = Release|Any CPU
{CA3C491B-A8CA-426C-A0BB-E91636767467}.Release|x86.ActiveCfg = Release|Any CPU
{6F542037-C48B-4EC5-A326-DDBEBF5FDFA2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6F542037-C48B-4EC5-A326-DDBEBF5FDFA2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6F542037-C48B-4EC5-A326-DDBEBF5FDFA2}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{6F542037-C48B-4EC5-A326-DDBEBF5FDFA2}.Debug|ARM.ActiveCfg = Debug|Any CPU
{6F542037-C48B-4EC5-A326-DDBEBF5FDFA2}.Debug|x86.ActiveCfg = Debug|Any CPU
{6F542037-C48B-4EC5-A326-DDBEBF5FDFA2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6F542037-C48B-4EC5-A326-DDBEBF5FDFA2}.Release|Any CPU.Build.0 = Release|Any CPU
{6F542037-C48B-4EC5-A326-DDBEBF5FDFA2}.Release|Any CPU.Deploy.0 = Release|Any CPU
{6F542037-C48B-4EC5-A326-DDBEBF5FDFA2}.Release|ARM.ActiveCfg = Release|Any CPU
{6F542037-C48B-4EC5-A326-DDBEBF5FDFA2}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{775569C2-987F-4AC4-8BA5-A315A21ED1B7} = {AFD4E3F1-B23C-4924-BA5B-D917FBADB8FA}
{656345D2-AF4C-4F88-9C9F-EBF54D7691DB} = {AFD4E3F1-B23C-4924-BA5B-D917FBADB8FA}
{47721A56-2128-4C5A-8B92-995FFC353304} = {AFD4E3F1-B23C-4924-BA5B-D917FBADB8FA}
{6F542037-C48B-4EC5-A326-DDBEBF5FDFA2} = {AFD4E3F1-B23C-4924-BA5B-D917FBADB8FA}
EndGlobalSection
EndGlobal
+64 -41
View File
@@ -29,7 +29,7 @@ namespace PocketSharp
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
public async Task<List<PocketItem>> Get(
public async Task<IEnumerable<PocketItem>> Get(
State? state = null,
bool? favorite = null,
string tag = null,
@@ -58,9 +58,7 @@ namespace PocketSharp
Offset = offset
};
Retrieve response = await Request<Retrieve>("get", cancellationToken, parameters.Convert());
return response.Items;
return (await Request<Retrieve>("get", cancellationToken, parameters.Convert())).Items;
}
@@ -74,12 +72,10 @@ namespace PocketSharp
/// <exception cref="PocketException"></exception>
public async Task<PocketItem> Get(string itemID, CancellationToken cancellationToken = default(CancellationToken))
{
List<PocketItem> items = await Get(
return (await Get(
cancellationToken: cancellationToken,
state: State.all
);
return items.SingleOrDefault<PocketItem>(item => item.ID == itemID);
)).SingleOrDefault<PocketItem>(item => item.ID == itemID);
}
@@ -90,7 +86,7 @@ namespace PocketSharp
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
public async Task<List<PocketItem>> Get(RetrieveFilter filter, CancellationToken cancellationToken = default(CancellationToken))
public async Task<IEnumerable<PocketItem>> Get(RetrieveFilter filter, CancellationToken cancellationToken = default(CancellationToken))
{
RetrieveParameters parameters = new RetrieveParameters();
@@ -121,9 +117,19 @@ namespace PocketSharp
parameters.DetailType = DetailType.complete;
Retrieve response = await Request<Retrieve>("get", cancellationToken, parameters.Convert());
return (await Request<Retrieve>("get", cancellationToken, parameters.Convert())).Items;
}
return response.Items;
/// <summary>
/// Converts a raw JSON response to a PocketItem list
/// </summary>
/// <param name="itemsJSON">The raw JSON response.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
public IEnumerable<PocketItem> ConvertJsonToList(string itemsJSON)
{
return DeserializeJson<Retrieve>(itemsJSON).Items;
}
@@ -134,18 +140,19 @@ namespace PocketSharp
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
public async Task<List<PocketTag>> GetTags(CancellationToken cancellationToken = default(CancellationToken))
public async Task<IEnumerable<PocketTag>> GetTags(CancellationToken cancellationToken = default(CancellationToken))
{
List<PocketItem> items = await Get(
IEnumerable<PocketItem> items = await Get(
cancellationToken: cancellationToken,
state: State.all
);
return items.Where(item => item.Tags != null)
.SelectMany(item => item.Tags)
.GroupBy(item => item.Name)
.Select(item => item.First())
.ToList<PocketTag>();
return items
.Where(item => item.Tags != null)
.SelectMany(item => item.Tags)
.GroupBy(item => item.Name)
.Select(item => item.First())
.ToList<PocketTag>();
}
@@ -156,9 +163,10 @@ namespace PocketSharp
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
public async Task<List<PocketItem>> SearchByTag(string tag, CancellationToken cancellationToken = default(CancellationToken))
public async Task<IEnumerable<PocketItem>> SearchByTag(string tag, CancellationToken cancellationToken = default(CancellationToken))
{
return await Get(
state: State.all,
cancellationToken: cancellationToken,
tag: tag
);
@@ -169,37 +177,52 @@ namespace PocketSharp
/// Retrieves items which match the specified search string in title and URI
/// </summary>
/// <param name="searchString">The search string.</param>
/// <param name="searchInUri">if set to <c>true</c> [search in URI].</param>
/// <param name="tag">Filter by tag.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns>
/// <exception cref="System.ArgumentOutOfRangeException">Search string length has to be a minimum of 2 chars</exception>
/// <exception cref="PocketException"></exception>
public async Task<List<PocketItem>> Search(string searchString, bool searchInUri = true, CancellationToken cancellationToken = default(CancellationToken))
public async Task<IEnumerable<PocketItem>> Search(string searchString, string tag = null, CancellationToken cancellationToken = default(CancellationToken))
{
List<PocketItem> items = await Get(RetrieveFilter.All, cancellationToken);
return Search(items, searchString);
}
/// <summary>
/// Finds the specified search string in title and URI for an available list of items
/// </summary>
/// <param name="availableItems">The available items.</param>
/// <param name="searchString">The search string.</param>
/// <returns></returns>
/// <exception cref="System.ArgumentOutOfRangeException">Search string length has to be a minimum of 2 chars</exception>
/// <exception cref="PocketException"></exception>
public List<PocketItem> Search(List<PocketItem> availableItems, string searchString)
{
if (searchString.Length < 2)
if (String.IsNullOrEmpty(searchString) || searchString.Length < 2)
{
throw new ArgumentOutOfRangeException("Search string length has to be a minimum of 2 chars");
}
return availableItems.Where(item => (
(!String.IsNullOrEmpty(item.FullTitle) && item.FullTitle.ToLower().Contains(searchString))
|| item.Uri.ToString().ToLower().Contains(searchString)
)).ToList();
return await Get(
state: State.all,
search: searchString,
tag: tag,
cancellationToken: cancellationToken
);
}
/// <summary>
/// Retrieves the article content from an URI
/// WARNING:
/// You have to pass the parseUri in the PocketClient ctor for this method to work.
/// This is a private API and can only be used by authenticated users.
/// </summary>
/// <param name="tag">The article URI.</param>
/// <param name="includeImages">Include images into content or use placeholder.</param>
/// <param name="includeVideos">Include videos into content or use placeholder.</param>
/// <param name="forceRefresh">Force refresh of the content (don't use cache).</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
public async Task<PocketArticle> GetArticle(Uri uri, bool includeImages = true, bool includeVideos = true, bool forceRefresh = false, CancellationToken cancellationToken = default(CancellationToken))
{
Dictionary<string, string> parameters = new Dictionary<string, string>()
{
{ "url", uri.OriginalString },
{ "images", includeImages ? "1" : "0" },
{ "videos", includeVideos ? "1" : "0" },
{ "refresh", forceRefresh ? "1" : "0" },
{ "output", "json" }
};
return await Request<PocketArticle>("", cancellationToken, parameters, false, true);
}
}
+16 -1
View File
@@ -1,4 +1,5 @@
using PocketSharp.Models;
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
@@ -18,12 +19,26 @@ namespace PocketSharp
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
public async Task<bool> SendActions(List<PocketAction> actions, CancellationToken cancellationToken = default(CancellationToken))
public async Task<bool> SendActions(IEnumerable<PocketAction> actions, CancellationToken cancellationToken = default(CancellationToken))
{
return await Send(actions, cancellationToken);
}
/// <summary>
/// Sends an action.
/// See: http://getpocket.com/developer/docs/v3/modify
/// </summary>
/// <param name="action">The action.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
public async Task<bool> SendAction(PocketAction action, CancellationToken cancellationToken = default(CancellationToken))
{
return await Send(new List<PocketAction>() { action }, cancellationToken);
}
/// <summary>
/// Archives the specified item.
/// </summary>
-86
View File
@@ -1,86 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Choose>
<When Condition="$(NCrunchOriginalSolutionDir) != '' And $(NCrunchOriginalSolutionDir) != '*Undefined*'">
<PropertyGroup>
<FodySolutionDir>$(NCrunchOriginalSolutionDir)</FodySolutionDir>
</PropertyGroup>
</When>
<When Condition="$(SolutionDir) != '' And $(SolutionDir) != '*Undefined*'">
<PropertyGroup>
<FodySolutionDir>$(SolutionDir)</FodySolutionDir>
</PropertyGroup>
</When>
<When Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">
<PropertyGroup>
<FodySolutionDir>$(MSBuildProjectDirectory)\..\</FodySolutionDir>
</PropertyGroup>
</When>
</Choose>
<Choose>
<When Condition="$(KeyOriginatorFile) != '' And $(KeyOriginatorFile) != '*Undefined*'">
<PropertyGroup>
<FodyKeyFilePath>$(KeyOriginatorFile)</FodyKeyFilePath>
</PropertyGroup>
</When>
<When Condition="$(AssemblyOriginatorKeyFile) != '' And $(AssemblyOriginatorKeyFile) != '*Undefined*'">
<PropertyGroup>
<FodyKeyFilePath>$(AssemblyOriginatorKeyFile)</FodyKeyFilePath>
</PropertyGroup>
</When>
<Otherwise >
<PropertyGroup>
<FodyKeyFilePath></FodyKeyFilePath>
</PropertyGroup>
</Otherwise>
</Choose>
<PropertyGroup>
<IntermediateDir>$(ProjectDir)$(IntermediateOutputPath)</IntermediateDir>
<FodySignAssembly Condition="$(FodySignAssembly) == '' Or $(FodySignAssembly) == '*Undefined*'">$(SignAssembly)</FodySignAssembly>
<FodyPath Condition="$(FodyPath) == '' Or $(FodyPath) == '*Undefined*'">$(MSBuildThisFileDirectory)</FodyPath>
</PropertyGroup>
<UsingTask
TaskName="Fody.WeavingTask"
AssemblyFile="$(FodyPath)\Fody.dll" />
<Target
AfterTargets="AfterCompile"
Name="WinFodyTarget"
Condition=" '$(OS)' == 'Windows_NT'">
<Fody.WeavingTask
AssemblyPath="@(IntermediateAssembly)"
IntermediateDir="$(IntermediateDir)"
KeyFilePath="$(FodyKeyFilePath)"
ProjectDirectory="$(ProjectDir)"
SolutionDir="$(FodySolutionDir)"
References="@(ReferencePath)"
SignAssembly="$(FodySignAssembly)"
ReferenceCopyLocalPaths="@(ReferenceCopyLocalPaths)"
DefineConstants="$(DefineConstants)"
/>
</Target>
<Target
AfterTargets="AfterBuild"
Name="NonWinFodyTarget"
Condition=" '$(OS)' != 'Windows_NT'">
<Fody.WeavingTask
AssemblyPath="$(TargetPath)"
IntermediateDir="$(IntermediateDir)"
KeyFilePath="$(FodyKeyFilePath)"
ProjectDirectory="$(ProjectDir)"
SolutionDir="$(FodySolutionDir)"
References="@(ReferencePath)"
SignAssembly="$(FodySignAssembly)"
ReferenceCopyLocalPaths="$(ReferenceCopyLocalPaths)"
DefineConstants="$(DefineConstants)"
/>
</Target>
<!--Support for ncrunch-->
<ItemGroup>
<None Include="$(FodyPath)\*.*" />
</ItemGroup>
</Project>
+1 -1
View File
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8" ?>
<Weavers>
<PropertyChanged />
</Weavers>
+30 -12
View File
@@ -127,7 +127,7 @@ namespace PocketSharp
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
Task<List<PocketItem>> Get(
Task<IEnumerable<PocketItem>> Get(
State? state = null,
bool? favorite = null,
string tag = null,
@@ -158,7 +158,15 @@ namespace PocketSharp
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
Task<List<PocketItem>> Get(RetrieveFilter filter, CancellationToken cancellationToken = default(CancellationToken));
Task<IEnumerable<PocketItem>> Get(RetrieveFilter filter, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Converts a raw JSON response to a PocketItem list
/// </summary>
/// <param name="itemsJSON">The raw JSON response.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
IEnumerable<PocketItem> ConvertJsonToList(string itemsJSON);
/// <summary>
/// Retrieves all available tags.
@@ -167,7 +175,7 @@ namespace PocketSharp
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
Task<List<PocketTag>> GetTags(CancellationToken cancellationToken = default(CancellationToken));
Task<IEnumerable<PocketTag>> GetTags(CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Retrieves items by tag
@@ -176,28 +184,33 @@ namespace PocketSharp
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
Task<List<PocketItem>> SearchByTag(string tag, CancellationToken cancellationToken = default(CancellationToken));
Task<IEnumerable<PocketItem>> SearchByTag(string tag, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Retrieves items which match the specified search string in title and URI
/// </summary>
/// <param name="searchString">The search string.</param>
/// <param name="searchInUri">if set to <c>true</c> [search in URI].</param>
/// <param name="tag">Filter by tag.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns>
/// <exception cref="System.ArgumentOutOfRangeException">Search string length has to be a minimum of 2 chars</exception>
/// <exception cref="PocketException"></exception>
Task<List<PocketItem>> Search(string searchString, bool searchInUri = true, CancellationToken cancellationToken = default(CancellationToken));
Task<IEnumerable<PocketItem>> Search(string searchString, string tag = null, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Finds the specified search string in title and URI for an available list of items
/// Retrieves the article content from an URI
/// WARNING:
/// You have to pass the parseUri in the PocketClient ctor for this method to work.
/// This is a private API and can only be used by authenticated users.
/// </summary>
/// <param name="availableItems">The available items.</param>
/// <param name="searchString">The search string.</param>
/// <param name="tag">The article URI.</param>
/// <param name="includeImages">Include images into content or use placeholder.</param>
/// <param name="includeVideos">Include videos into content or use placeholder.</param>
/// <param name="forceRefresh">Force refresh of the content (don't use cache).</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns>
/// <exception cref="System.ArgumentOutOfRangeException">Search string length has to be a minimum of 2 chars</exception>
/// <exception cref="PocketException"></exception>
List<PocketItem> Search(List<PocketItem> availableItems, string searchString);
Task<PocketArticle> GetArticle(Uri uri, bool includeImages = true, bool includeVideos = true, bool forceRefresh = false, CancellationToken cancellationToken = default(CancellationToken));
#endregion
#region modify methods
@@ -209,7 +222,7 @@ namespace PocketSharp
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
Task<bool> SendActions(List<PocketAction> actions, CancellationToken cancellationToken = default(CancellationToken));
Task<bool> SendActions(IEnumerable<PocketAction> actions, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Archives the specified item.
@@ -442,5 +455,10 @@ namespace PocketSharp
/// <exception cref="PocketException"></exception>
Task<PocketLimits> GetUsageLimits(CancellationToken cancellationToken = default(CancellationToken));
#endregion
/// <summary>
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
/// </summary>
void Dispose();
}
}
@@ -16,6 +16,6 @@ namespace PocketSharp.Models
/// The actions.
/// </value>
[DataMember(Name = "actions")]
public List<Dictionary<string, string>> Actions { get; set; }
public IEnumerable<Dictionary<string, string>> Actions { get; set; }
}
}
+17 -7
View File
@@ -23,16 +23,26 @@ namespace PocketSharp.Models
Dictionary<string, string> parameterDict = new Dictionary<string, string>();
// get object properties
IEnumerable<PropertyInfo> properties = this.GetType()
.GetProperties(BindingFlags.Instance | BindingFlags.Public)
.Where(p => Attribute.IsDefined(p, typeof(DataMemberAttribute)));
IEnumerable<MemberInfo> properties = this.GetType()
.GetTypeInfo()
.DeclaredMembers
.Where(p => p.CustomAttributes.FirstOrDefault(a => a.AttributeType == typeof(DataMemberAttribute)) != null);
// gather attributes of object
foreach (PropertyInfo propertyInfo in properties)
foreach (MemberInfo memberInfo in properties)
{
DataMemberAttribute attribute = (DataMemberAttribute)propertyInfo.GetCustomAttributes(typeof(DataMemberAttribute), false).FirstOrDefault();
string name = attribute.Name ?? propertyInfo.Name.ToLower();
object value = propertyInfo.GetValue(this, null);
DataMemberAttribute attribute = (DataMemberAttribute)memberInfo.GetCustomAttributes(typeof(DataMemberAttribute), false).FirstOrDefault();
string name = attribute.Name ?? memberInfo.Name.ToLower();
object value = null;
if (memberInfo is FieldInfo)
{
value = ((FieldInfo)memberInfo).GetValue(this);
}
else
{
value = ((PropertyInfo)memberInfo).GetValue(this, null);
}
// invalid parameter
if (value == null)
@@ -1,39 +0,0 @@
using System.Runtime.Serialization;
namespace PocketSharp.Models
{
/// <summary>
/// All parameters which can be passed to register a user
/// </summary>
[DataContract]
internal class RegisterParameters : Parameters
{
/// <summary>
/// Gets or sets the username.
/// </summary>
/// <value>
/// The username.
/// </value>
[DataMember(Name = "username")]
public string Username { get; set; }
/// <summary>
/// Gets or sets the E-Mail.
/// </summary>
/// <value>
/// The E-Mail.
/// </value>
[DataMember(Name = "email")]
public string Email { get; set; }
/// <summary>
/// Gets or sets the password.
/// </summary>
/// <value>
/// The password.
/// </value>
[DataMember(Name = "password")]
public string Password { get; set; }
}
}
+3 -2
View File
@@ -1,4 +1,5 @@
using System;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
@@ -120,7 +121,7 @@ namespace PocketSharp.Models
if (!String.IsNullOrEmpty(TweetID))
parameters.Add("ref_id", TweetID);
if (Uri != null)
parameters.Add("uri", Uri.ToString());
parameters.Add("url", Uri.OriginalString);
return parameters;
}
+165
View File
@@ -0,0 +1,165 @@
using Newtonsoft.Json;
using PropertyChanged;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PocketSharp.Models
{
/// <summary>
/// Article
/// </summary>
[JsonObject]
[ImplementPropertyChanged]
public class PocketArticle
{
/// <summary>
/// Gets or sets the response Code (200 = OK).
/// </summary>
/// <value>
/// The response Code.
/// </value>
[JsonProperty("responseCode")]
public string ResponseCode { get; set; }
/// <summary>
/// Gets or sets the ID.
/// </summary>
/// <value>
/// The ID.
/// </value>
[JsonProperty("resolved_id")]
public string ID { get; set; }
/// <summary>
/// Gets or sets the URI.
/// </summary>
/// <value>
/// The URI.
/// </value>
[JsonProperty("resolvedUrl")]
public Uri Uri { get; set; }
/// <summary>
/// Gets or sets the URI.
/// </summary>
/// <value>
/// The URI.
/// </value>
[JsonProperty("timePublished")]
public DateTime? PublishedTime { get; set; }
/// <summary>
/// Gets or sets the word count.
/// </summary>
/// <value>
/// The word count.
/// </value>
[JsonProperty("wordCount")]
public int WordCount { get; set; }
/// <summary>
/// Gets or sets a value indicating whether this instance is article.
/// </summary>
/// <value>
/// <c>true</c> if this instance is article; otherwise, <c>false</c>.
/// </value>
[JsonProperty("isArticle")]
public bool IsArticle { get; set; }
/// <summary>
/// Gets or sets a value indicating whether this instance is video.
/// </summary>
/// <value>
/// <c>true</c> if this instance is video; otherwise, <c>false</c>.
/// </value>
[JsonProperty("isVideo")]
public bool IsVideo { get; set; }
/// <summary>
/// Gets or sets a value indicating whether this instance is index.
/// </summary>
/// <value>
/// <c>true</c> if this instance is index; otherwise, <c>false</c>.
/// </value>
[JsonProperty("isIndex")]
public bool IsIndex { get; set; }
/// <summary>
/// Gets or sets a value indicating whether this instance used fallback.
/// </summary>
/// <value>
/// <c>true</c> if this instance used fallback; otherwise, <c>false</c>.
/// </value>
[JsonProperty("usedFallback")]
public bool UsedFallback { get; set; }
/// <summary>
/// Gets or sets a value indicating whether this instance requires login.
/// </summary>
/// <value>
/// <c>true</c> if this instance requires login; otherwise, <c>false</c>.
/// </value>
[JsonProperty("requiresLogin")]
public bool RequiresLogin { get; set; }
/// <summary>
/// Gets or sets the images.
/// </summary>
/// <value>
/// The images.
/// </value>
[JsonProperty("images")]
[JsonConverter(typeof(ObjectToArrayConverter<PocketImage>))]
public IEnumerable<PocketImage> Images { get; set; }
/// <summary>
/// Gets or sets the videos.
/// </summary>
/// <value>
/// The videos.
/// </value>
[JsonProperty("videos")]
[JsonConverter(typeof(ObjectToArrayConverter<PocketVideo>))]
public IEnumerable<PocketVideo> Videos { get; set; }
/// <summary>
/// Gets or sets the authors.
/// </summary>
/// <value>
/// The authors.
/// </value>
[JsonProperty("authors")]
[JsonConverter(typeof(ObjectToArrayConverter<PocketAuthor>))]
public IEnumerable<PocketAuthor> Authors { get; set; }
/// <summary>
/// Gets or sets the article title.
/// </summary>
/// <value>
/// The Title.
/// </value>
[JsonProperty("title")]
public string Title { get; set; }
/// <summary>
/// Gets or sets the Excerpt.
/// </summary>
/// <value>
/// The Excerpt.
/// </value>
[JsonProperty("excerpt")]
public string Excerpt { get; set; }
/// <summary>
/// Gets or sets the Content.
/// </summary>
/// <value>
/// The Content.
/// </value>
[JsonProperty("article")]
public string Content { get; set; }
}
}
+127 -7
View File
@@ -3,6 +3,7 @@ using PropertyChanged;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
namespace PocketSharp.Models
{
@@ -13,8 +14,7 @@ namespace PocketSharp.Models
[JsonObject]
[ImplementPropertyChanged]
[DebuggerDisplay("Uri = {Uri}, Title = {Title}")]
public class PocketItem
public class PocketItem : IComparable
{
/// <summary>
/// Gets or sets the ID.
@@ -301,6 +301,17 @@ namespace PocketSharp.Models
[JsonProperty("time_favorited")]
public DateTime? FavoriteTime { get; set; }
/// <summary>
/// Gets or sets the tags as comma-separated strings.
/// </summary>
/// <value>
/// The tags.
/// </value>
[JsonIgnore]
public string TagsString
{
get { return Tags != null ? String.Join(",", Tags.Select(tag => tag.Name)) : ""; }
}
/// <summary>
/// Gets or sets the tags.
@@ -310,7 +321,7 @@ namespace PocketSharp.Models
/// </value>
[JsonProperty("tags")]
[JsonConverter(typeof(ObjectToArrayConverter<PocketTag>))]
public List<PocketTag> Tags { get; set; }
public IEnumerable<PocketTag> Tags { get; set; }
/// <summary>
/// Gets or sets the images.
@@ -320,7 +331,7 @@ namespace PocketSharp.Models
/// </value>
[JsonProperty("images")]
[JsonConverter(typeof(ObjectToArrayConverter<PocketImage>))]
public List<PocketImage> Images { get; set; }
public IEnumerable<PocketImage> Images { get; set; }
/// <summary>
/// Gets or sets the videos.
@@ -330,7 +341,7 @@ namespace PocketSharp.Models
/// </value>
[JsonProperty("videos")]
[JsonConverter(typeof(ObjectToArrayConverter<PocketVideo>))]
public List<PocketVideo> Videos { get; set; }
public IEnumerable<PocketVideo> Videos { get; set; }
/// <summary>
/// Gets or sets the authors.
@@ -340,7 +351,7 @@ namespace PocketSharp.Models
/// </value>
[JsonProperty("authors")]
[JsonConverter(typeof(ObjectToArrayConverter<PocketAuthor>))]
public List<PocketAuthor> Authors { get; set; }
public IEnumerable<PocketAuthor> Authors { get; set; }
/// <summary>
/// Gets the lead image.
@@ -351,7 +362,7 @@ namespace PocketSharp.Models
[JsonIgnore]
public PocketImage LeadImage
{
get { return Images != null && Images.Count > 0 ? Images[0] : null; }
get { return Images != null && Images.Count() > 0 ? Images.First() : null; }
}
/// <summary>
@@ -362,5 +373,114 @@ namespace PocketSharp.Models
/// </value>
[JsonIgnore]
public string Json { get; set; }
/// <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.
/// </summary>
/// <param name="obj">An object to compare with this instance.</param>
/// <returns>
/// A value that indicates the relative order of the objects being compared. The return value has these meanings: Value Meaning Less than zero This instance precedes <paramref name="obj" /> in the sort order. Zero This instance occurs in the same position in the sort order as <paramref name="obj" />. Greater than zero This instance follows <paramref name="obj" /> in the sort order.
/// </returns>
int IComparable.CompareTo(object obj)
{
PocketItem item = (PocketItem)obj;
if (!AddTime.HasValue)
{
return 1;
}
if (!item.AddTime.HasValue)
{
return -1;
}
return DateTime.Compare(AddTime.Value, item.AddTime.Value);
}
/// <summary>
/// Determines whether the specified <see cref="System.Object" />, is equal to this instance.
/// </summary>
/// <param name="obj">The <see cref="System.Object" /> to compare with this instance.</param>
/// <returns>
/// <c>true</c> if the specified <see cref="System.Object" /> is equal to this instance; otherwise, <c>false</c>.
/// </returns>
public override bool Equals(object obj)
{
if (obj == null)
{
return false;
}
PocketItem item = (PocketItem)obj;
if ((Object)item == null)
{
return false;
}
return ID == item.ID;
}
/// <summary>
/// Implements the operator ==.
/// </summary>
/// <param name="a">A.</param>
/// <param name="b">The b.</param>
/// <returns>
/// The result of the operator.
/// </returns>
public static bool operator ==(PocketItem a, PocketItem b)
{
if (a == null || b == null)
{
return false;
}
PocketItem itemA = (PocketItem)a;
PocketItem itemB = (PocketItem)b;
if ((Object)itemA == null || (Object)itemB == null)
{
return false;
}
return itemA.ID == itemB.ID;
}
/// <summary>
/// Implements the operator !=.
/// </summary>
/// <param name="a">A.</param>
/// <param name="b">The b.</param>
/// <returns>
/// The result of the operator.
/// </returns>
public static bool operator !=(PocketItem a, PocketItem b)
{
return !(a == b);
}
/// <summary>
/// Returns a hash code for this instance.
/// </summary>
/// <returns>
/// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
/// </returns>
public override int GetHashCode()
{
return ID.GetHashCode();
}
/// <summary>
/// Returns a <see cref="System.String" /> that represents this instance.
/// </summary>
/// <returns>
/// A <see cref="System.String" /> that represents this instance.
/// </returns>
public override string ToString()
{
return ID;
}
}
}
+9
View File
@@ -18,5 +18,14 @@ namespace PocketSharp.Models
/// </value>
[JsonProperty("tag")]
public string Name { get; set; }
/// <summary>
/// Gets or sets the item iD.
/// </summary>
/// <value>
/// The name.
/// </value>
[JsonProperty("item_id")]
public string ItemID { get; set; }
}
}
+1 -1
View File
@@ -36,6 +36,6 @@ namespace PocketSharp.Models
/// </value>
[JsonProperty("list")]
[JsonConverter(typeof(ObjectToArrayConverter<PocketItem>))]
public List<PocketItem> Items { get; set; }
public IEnumerable<PocketItem> Items { get; set; }
}
}
+99 -28
View File
@@ -8,19 +8,25 @@ using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading;
using System.Threading.Tasks;
using System.Linq;
namespace PocketSharp
{
/// <summary>
/// PocketClient
/// </summary>
public partial class PocketClient : IPocketClient
public partial class PocketClient : IPocketClient, IDisposable
{
/// <summary>
/// REST client used for the API communication
/// </summary>
protected readonly HttpClient _restClient;
/// <summary>
/// REST client used for the API communication with the Text Parser API
/// </summary>
protected readonly HttpClient _restParserClient;
/// <summary>
/// Caches HTTP headers from last response
/// </summary>
@@ -97,13 +103,15 @@ namespace PocketSharp
/// <param name="handler">The HttpMessage handler.</param>
/// <param name="timeout">Request timeout (in seconds).</param>
/// <param name="isMobileClient">Indicates, whether this client is used for mobile or desktop</param>
/// <param name="parserUri">Enables the wrapper for the private Text Parser API</param>
public PocketClient(
string consumerKey,
string accessCode = null,
string callbackUri = null,
HttpMessageHandler handler = null,
int? timeout = null,
bool isMobileClient = true)
bool isMobileClient = true,
Uri parserUri = null)
{
// assign public properties
ConsumerKey = consumerKey;
@@ -122,6 +130,23 @@ namespace PocketSharp
CallbackUri = Uri.EscapeUriString(callbackUri.ToString());
}
// assign text parser if parserUri submitted
if (parserUri != null)
{
_restParserClient = new HttpClient(handler ?? new HttpClientHandler()
{
AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip
});
_restParserClient.BaseAddress = parserUri;
_restParserClient.DefaultRequestHeaders.Add("Accept", "*/*");
_restParserClient.DefaultRequestHeaders.Add("X-Accept", "application/json");
if (timeout.HasValue)
{
_restParserClient.Timeout = TimeSpan.FromSeconds(timeout.Value);
}
}
// initialize REST client
_restClient = new HttpClient(handler ?? new HttpClientHandler()
{
@@ -158,16 +183,27 @@ namespace PocketSharp
string method,
CancellationToken cancellationToken,
Dictionary<string, string> parameters = null,
bool requireAuth = true) where T : class, new()
bool requireAuth = true,
bool isReaderRequest = false) where T : class, new()
{
if (requireAuth && AccessCode == null)
{
throw new PocketException("SDK error: No access token available. Use authentication first.");
}
// rewrite base if it is a request to the Parser API
if (isReaderRequest)
{
if (_restParserClient == null)
{
throw new PocketException("Please pass the parserUri in the PocketClient ctor.");
}
}
// every single Pocket API endpoint requires HTTP POST data
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, method);
HttpResponseMessage response = null;
string responseString = null;
if (parameters == null)
{
@@ -178,7 +214,7 @@ namespace PocketSharp
parameters.Add("consumer_key", ConsumerKey);
// add access token (necessary for all requests except authentification)
if (AccessCode != null)
if (AccessCode != null && requireAuth)
{
parameters.Add("access_token", AccessCode);
}
@@ -195,30 +231,59 @@ namespace PocketSharp
// make async request
try
{
response = await _restClient.SendAsync(request, cancellationToken);
if (isReaderRequest)
{
response = await _restParserClient.SendAsync(request, cancellationToken);
}
else
{
response = await _restClient.SendAsync(request, cancellationToken);
}
// validate HTTP response
ValidateResponse(response);
// cache headers
lastHeaders = response.Headers;
// read response
responseString = await response.Content.ReadAsStringAsync();
}
catch (HttpRequestException exc)
{
throw new PocketException(exc.Message, exc);
}
// validate HTTP response
ValidateResponse(response);
// cache headers
lastHeaders = response.Headers;
// read response
var responseString = await response.Content.ReadAsStringAsync();
catch (PocketException exc)
{
throw exc;
}
finally
{
request.Dispose();
response.Dispose();
}
// cache response
lastResponseData = responseString;
responseString = responseString.Replace("[]", "{}");
return DeserializeJson<T>(responseString);
}
/// <summary>
/// Converts JSON to Pocket objects
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="json">Raw JSON response</param>
/// <returns></returns>
/// <exception cref="PocketException">Parse error.</exception>
protected T DeserializeJson<T>(string json) where T : class, new()
{
json = json.Replace("[]", "{}");
// deserialize object
T parsedResponse = JsonConvert.DeserializeObject<T>(
responseString,
json,
new JsonSerializerSettings
{
Error = (object sender, ErrorEventArgs args) =>
@@ -245,22 +310,13 @@ namespace PocketSharp
/// </summary>
/// <param name="actionParameters">The action parameters.</param>
/// <returns></returns>
internal async Task<bool> Send(List<PocketAction> actionParameters, CancellationToken cancellationToken)
internal async Task<bool> Send(IEnumerable<PocketAction> actionParameters, CancellationToken cancellationToken)
{
List<Dictionary<string, object>> actionParamList = new List<Dictionary<string, object>>();
foreach (var action in actionParameters)
{
actionParamList.Add(action.Convert());
}
Dictionary<string, string> parameters = new Dictionary<string, string>() {{
"actions", JsonConvert.SerializeObject(actionParamList)
"actions", JsonConvert.SerializeObject(actionParameters.Select(action => action.Convert()))
}};
Modify response = await Request<Modify>("send", cancellationToken, parameters);
return response.Status;
return (await Request<Modify>("send", cancellationToken, parameters)).Status;
}
@@ -355,5 +411,20 @@ namespace PocketSharp
return result;
}
/// <summary>
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
/// </summary>
public void Dispose()
{
_restClient.Dispose();
lastHeaders = null;
if (_restParserClient != null)
{
_restParserClient.Dispose();
}
}
}
}
+48 -30
View File
@@ -2,7 +2,7 @@
<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>
<MinimumVisualStudioVersion>11.0</MinimumVisualStudioVersion>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{817200C3-A327-4E35-9B5F-63A51C088577}</ProjectGuid>
@@ -10,13 +10,33 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>PocketSharp</RootNamespace>
<AssemblyName>PocketSharp</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Profile96</TargetFrameworkProfile>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkProfile>Profile259</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>
<FodyPath>..\packages\Fody.1.20.0.0</FodyPath>
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>4.0</OldToolsVersion>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<NuGetPackageImportStamp>10f8a946</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -37,13 +57,13 @@
</PropertyGroup>
<ItemGroup>
<!-- A reference to the entire .NET Framework is automatically included -->
<None Include="Fody.targets" />
<None Include="app.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Compile Include="Components\Statistics.cs" />
<Compile Include="IPocketClient.cs" />
<Compile Include="Models\Parameters\RegisterParameters.cs" />
<Compile Include="Models\PocketArticle.cs" />
<Compile Include="Models\PocketBoolean.cs" />
<Compile Include="Models\PocketLimits.cs" />
<Compile Include="Models\PocketStatistics.cs" />
@@ -78,41 +98,38 @@
<Compile Include="Utilities\Utilities.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.Threading.Tasks">
<HintPath>..\packages\Microsoft.Bcl.Async.1.0.165\lib\portable-net40+sl4+win8+wp71\Microsoft.Threading.Tasks.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Threading.Tasks.Extensions">
<HintPath>..\packages\Microsoft.Bcl.Async.1.0.165\lib\portable-net40+sl4+win8+wp71\Microsoft.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>..\packages\Newtonsoft.Json.5.0.8\lib\portable-net40+sl4+wp7+win8\Newtonsoft.Json.dll</HintPath>
<HintPath>..\packages\Newtonsoft.Json.6.0.2\lib\portable-net40+sl5+wp80+win8+monotouch+monoandroid\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="PropertyChanged">
<HintPath>..\packages\PropertyChanged.Fody.1.45.0.0\Lib\portable-net4+sl4+wp7+win8+MonoAndroid16+MonoTouch40\PropertyChanged.dll</HintPath>
<HintPath>..\packages\PropertyChanged.Fody.1.48.0.0\Lib\portable-net4+sl4+wp7+win8+MonoAndroid16+MonoTouch40\PropertyChanged.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System.IO">
<HintPath>..\packages\Microsoft.Bcl.1.1.6\lib\portable-net40+sl4+win8+wp71\System.IO.dll</HintPath>
</Reference>
<Reference Include="System.Net.Http">
<HintPath>..\packages\Microsoft.Net.Http.2.2.18\lib\portable-net40+sl4+win8+wp71\System.Net.Http.dll</HintPath>
<HintPath>..\packages\Microsoft.Net.Http.2.2.19\lib\portable-net40+sl4+win8+wp71+wpa81\System.Net.Http.dll</HintPath>
</Reference>
<Reference Include="System.Net.Http.Extensions">
<HintPath>..\packages\Microsoft.Net.Http.2.2.18\lib\portable-net40+sl4+win8+wp71\System.Net.Http.Extensions.dll</HintPath>
<HintPath>..\packages\Microsoft.Net.Http.2.2.19\lib\portable-net40+sl4+win8+wp71+wpa81\System.Net.Http.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.Net.Http.Primitives">
<HintPath>..\packages\Microsoft.Net.Http.2.2.18\lib\portable-net40+sl4+win8+wp71\System.Net.Http.Primitives.dll</HintPath>
</Reference>
<Reference Include="System.Runtime">
<HintPath>..\packages\Microsoft.Bcl.1.1.6\lib\portable-net40+sl4+win8+wp71\System.Runtime.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Tasks">
<HintPath>..\packages\Microsoft.Bcl.1.1.6\lib\portable-net40+sl4+win8+wp71\System.Threading.Tasks.dll</HintPath>
<HintPath>..\packages\Microsoft.Net.Http.2.2.19\lib\portable-net40+sl4+win8+wp71+wpa81\System.Net.Http.Primitives.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Content Include="FodyWeavers.xml" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</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">
@@ -120,13 +137,14 @@
<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'))" />
<Error Condition="!Exists('..\packages\Fody.1.22.1\build\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Fody.1.22.1\build\Fody.targets'))" />
</Target>
<Import Project="..\packages\Microsoft.Bcl.Build.1.0.13\tools\Microsoft.Bcl.Build.targets" Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.13\tools\Microsoft.Bcl.Build.targets')" />
<Import Project="..\packages\Fody.1.22.1\build\Fody.targets" Condition="Exists('..\packages\Fody.1.22.1\build\Fody.targets')" />
<Import Project="..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets" Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" />
<Target Name="EnsureBclBuildImported" BeforeTargets="BeforeBuild" Condition="'$(BclBuildImported)' == ''">
<Error Condition="!Exists('..\packages\Microsoft.Bcl.Build.1.0.13\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.13\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" />
<Error Condition="!Exists('..\packages\Microsoft.Bcl.Build.1.0.14\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.14\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>
<Import Project="Fody.targets" />
<!-- 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">
+2 -2
View File
@@ -22,5 +22,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("3.2.0")]
[assembly: AssemblyFileVersion("3.2.0")]
[assembly: AssemblyVersion("4.1.1")]
[assembly: AssemblyFileVersion("4.1.1")]
+18 -9
View File
@@ -45,6 +45,11 @@ namespace PocketSharp
return null;
}
if (reader.Value.ToString().StartsWith("-"))
{
return null;
}
return new DateTime(1970, 1, 1, 0, 0, 0, 0).AddSeconds(Convert.ToDouble(reader.Value)).ToLocalTime();
}
}
@@ -123,22 +128,26 @@ namespace PocketSharp
public class ObjectToArrayConverter<T> : CustomCreationConverter<List<T>> where T : new()
public class ObjectToArrayConverter<T> : CustomCreationConverter<IEnumerable<T>> where T : new()
{
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
JObject jObject;
List<T> result = new List<T>();
T target;
List<T> results = new List<T>();
// object is an array
if (reader.TokenType == JsonToken.StartArray)
{
return serializer.Deserialize<List<T>>(reader);
return serializer.Deserialize<IEnumerable<T>>(reader);
}
else if (reader.TokenType == JsonToken.Null)
{
return null;
}
else if (reader.TokenType == JsonToken.String)
{
return null;
}
try
{
@@ -152,11 +161,12 @@ namespace PocketSharp
// Populate the object properties
foreach (KeyValuePair<string, JToken> item in jObject)
{
target = serializer.Deserialize<T>(item.Value.CreateReader());
result.Add(target);
results.Add(
serializer.Deserialize<T>(item.Value.CreateReader())
);
}
return result;
return results;
}
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
@@ -164,11 +174,10 @@ namespace PocketSharp
throw new NotImplementedException();
}
public override List<T> Create(Type objectType)
public override IEnumerable<T> Create(Type objectType)
{
return new List<T>();
}
}
+15
View File
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.6.7.0" newVersion="2.6.7.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.6.7.0" newVersion="2.6.7.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
+6 -7
View File
@@ -1,10 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Fody" version="1.20.0.0" targetFramework="portable-win+net403+sl40+wp71" developmentDependency="true" />
<package id="Microsoft.Bcl" version="1.1.6" targetFramework="portable-win+net403+sl40+wp71" />
<package id="Microsoft.Bcl.Async" version="1.0.165" targetFramework="portable-win+net403+sl40+wp71" />
<package id="Microsoft.Bcl.Build" version="1.0.13" targetFramework="portable-win+net403+sl40+wp71" />
<package id="Microsoft.Net.Http" version="2.2.18" targetFramework="portable-win+net403+sl40+wp71" />
<package id="Newtonsoft.Json" version="5.0.8" targetFramework="portable-net45+sl40+wp71+win" />
<package id="PropertyChanged.Fody" version="1.45.0.0" targetFramework="portable-win+net403+sl40+wp71" developmentDependency="true" />
<package id="Fody" version="1.22.1" targetFramework="portable-net403+sl50+win+wp80" developmentDependency="true" />
<package id="Microsoft.Bcl" version="1.1.7" targetFramework="portable-net403+sl50+win+wpa81+wp80" requireReinstallation="True" />
<package id="Microsoft.Bcl.Build" version="1.0.14" targetFramework="portable-net403+sl50+win+wpa81+wp80" />
<package id="Microsoft.Net.Http" version="2.2.19" targetFramework="portable-net403+sl50+win+wpa81+wp80" />
<package id="Newtonsoft.Json" version="6.0.2" targetFramework="portable-net403+sl50+win+wp80" requireReinstallation="True" />
<package id="PropertyChanged.Fody" version="1.48.0.0" targetFramework="portable-net403+sl50+win+wp80" developmentDependency="true" requireReinstallation="True" />
</packages>
+9 -8
View File
@@ -49,14 +49,15 @@ Which will output:
## Supported platforms
PocketSharp is a **Portable Class Library**, therefore it's compatible with multiple platforms:
PocketSharp is a **Portable Class Library**, therefore it's compatible with multiple platforms and Universal Apps:
- **.NET** >= 4.5 (including WPF)
- **Silverlight** >= 4
- **Windows Phone** >= 7.5
- **Windows Store**
- **Windows Phone** (Silverlight + WinPRT) >= 8
- **Windows Store** >= 8
- **Xamarin** iOS + Android
- _WP7 and Silverlight are dropped in 4.0, use PocketSharp < 4.0, if you want to support them_
You can find examples for Silverlight 5, WP8 and WPF in the `PocketSharp.Examples` ([@github](https://github.com/ceee/PocketSharp/tree/master/PocketSharp.Examples)) folder.
You can find examples for WP8 and WPF in the `PocketSharp.Examples` ([@github](https://github.com/ceee/PocketSharp/tree/master/PocketSharp.Examples)) folder.
## Dependencies
@@ -67,9 +68,9 @@ You can find examples for Silverlight 5, WP8 and WPF in the `PocketSharp.Example
## Contributors
| [![ceee](http://gravatar.com/avatar/9c61b1f4307425f12f05d3adb930ba66?s=70)](https://github.com/ceee "Tobias Klika") | [![ScottIsAFool](http://gravatar.com/avatar/6df656872a87b09a7470feb4867ed927?s=70)](https://github.com/ScottIsAFool "Scott Lovegrove") |
|---|---|
| [ceee](https://github.com/ceee) | [ScottIsAFool](https://github.com/ScottIsAFool) |
| [![ceee](http://gravatar.com/avatar/9c61b1f4307425f12f05d3adb930ba66?s=70)](https://github.com/ceee "Tobias Klika") | [![ScottIsAFool](http://gravatar.com/avatar/6df656872a87b09a7470feb4867ed927?s=70)](https://github.com/ScottIsAFool "Scott Lovegrove") | [![StephenErstad](http://gravatar.com/avatar/3cfe2c5dbc5bc26697e0fe2c428e46e7?s=70)](https://github.com/StephenErstad "Stephen Erstad") |
|---|---|---|
| [ceee](https://github.com/ceee) | [ScottIsAFool](https://github.com/ScottIsAFool) | [StephenErstad](https://github.com/StephenErstad) |
## License