22 Commits

Author SHA1 Message Date
swcs 79184d194e fix tag parameter conversion; lead image generation; add complex item test; 2013-09-17 22:48:35 +02:00
swcs 9d0fb6484f fix modification requests 2013-09-17 21:43:31 +02:00
swcs e45414bd51 remove depr. classes 2013-09-16 23:34:26 +02:00
swcs e522c8e30a simplify parameter creation; fix several deserialization issues 2013-09-16 23:34:13 +02:00
swcs 6cf9892f78 disposable base for tests; classes for other tests 2013-09-15 21:52:28 +02:00
swcs d3c40c1a76 add tests for Retrieve methods 2013-09-15 21:44:09 +02:00
swcs c01098af04 update website and docs 2013-09-15 15:46:13 +02:00
swcs 813b1ab5b0 update assembly info; create new nuspec file 2013-09-15 15:19:33 +02:00
swcs 91b18e1eab add silverlight example 2013-09-15 12:38:41 +02:00
swcs b6bd02a5cc add WP8 example 2013-09-14 19:33:38 +02:00
swcs 25a3f4ef2f add WPF example 2013-09-14 15:47:51 +02:00
swcs 6114c3af9a exception handling / validation for requests and parsing 2013-09-14 15:12:28 +02:00
swcs a507cf6d0a add custom deserializers; update data-attributes for json.net 2013-09-14 13:40:20 +02:00
swcs 25321ee107 update tests 2013-09-12 11:40:25 +02:00
swcs f9268ea6be start async + pcl implementation 2013-09-12 11:39:48 +02:00
swcs f2134b8c80 prepare Models for PCL 2013-09-11 22:31:32 +02:00
swcs c7565d7684 make components async (won't work yet) 2013-09-11 22:31:01 +02:00
swcs a4666f843c update readme 2013-09-09 20:51:50 +02:00
swcs c545152957 update readme 2013-09-06 11:36:41 +02:00
swcs 490b005002 update readme 2013-09-05 21:58:13 +02:00
swcs a07a509042 update history listing for website 2013-08-19 09:06:54 +02:00
swcs 5c7f398b51 bump version; 2013-08-16 14:02:12 +02:00
93 changed files with 3286 additions and 674 deletions
+1 -1
View File
@@ -165,4 +165,4 @@ $RECYCLE.BIN/
# =========================
PocketSharp.Console/
!PocketSharp.Website/Release/
!PocketSharp.Website/Release/
BIN
View File
Binary file not shown.
+8 -5
View File
@@ -18,9 +18,9 @@
<ItemGroup Condition=" '$(PackageSources)' == '' ">
<!-- Package sources used to restore packages. By default, registered sources under %APPDATA%\NuGet\NuGet.Config will be used -->
<!-- The official NuGet package source (https://nuget.org/api/v2/) will be excluded if package sources are specified and it does not appear in the list -->
<!-- The official NuGet package source (https://www.nuget.org/api/v2/) will be excluded if package sources are specified and it does not appear in the list -->
<!--
<PackageSource Include="https://nuget.org/api/v2/" />
<PackageSource Include="https://www.nuget.org/api/v2/" />
<PackageSource Include="https://my-nuget-source/nuget/" />
-->
</ItemGroup>
@@ -50,9 +50,12 @@
<RequireConsentSwitch Condition=" $(RequireRestoreConsent) == 'true' ">-RequireConsent</RequireConsentSwitch>
<NonInteractiveSwitch Condition=" '$(VisualStudioVersion)' != '' AND '$(OS)' == 'Windows_NT' ">-NonInteractive</NonInteractiveSwitch>
<PaddedSolutionDir Condition=" '$(OS)' == 'Windows_NT'">"$(SolutionDir) "</PaddedSolutionDir>
<PaddedSolutionDir Condition=" '$(OS)' != 'Windows_NT' ">"$(SolutionDir)"</PaddedSolutionDir>
<!-- Commands -->
<RestoreCommand>$(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir "$(SolutionDir) " </RestoreCommand>
<BuildCommand>$(NuGetCommand) pack "$(ProjectPath)" -Properties Configuration=$(Configuration) $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -symbols</BuildCommand>
<RestoreCommand>$(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir $(PaddedSolutionDir)</RestoreCommand>
<BuildCommand>$(NuGetCommand) pack "$(ProjectPath)" -Properties "Configuration=$(Configuration);Platform=$(Platform)" $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -symbols</BuildCommand>
<!-- We need to ensure packages are restored prior to assembly resolve -->
<BuildDependsOn Condition="$(RestorePackages) == 'true'">
@@ -118,7 +121,7 @@
Log.LogMessage("Downloading latest version of NuGet.exe...");
WebClient webClient = new WebClient();
webClient.DownloadFile("https://nuget.org/nuget.exe", OutputFilename);
webClient.DownloadFile("https://www.nuget.org/nuget.exe", OutputFilename);
return true;
}
@@ -0,0 +1,8 @@
<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>
@@ -0,0 +1,68 @@
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)
{
}
}
}
}
@@ -0,0 +1,16 @@
<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>
@@ -0,0 +1,68 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
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 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: "2c62cd50-b78a-5558-918b-65adae"
);
List<PocketSharp.Models.PocketItem> items = null;
try
{
items = await client.Retrieve();
items.ForEach(item =>
{
Sites.Add(new Site()
{
Content = item.Title,
Url = item.Uri.ToString()
});
});
Content.ItemsSource = Sites;
}
catch (PocketException ex)
{
Debug.WriteLine(ex.Message);
}
}
}
}
@@ -0,0 +1,151 @@
<?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">
<HintPath>..\..\packages\Microsoft.Bcl.Async.1.0.16\lib\sl4\Microsoft.Threading.Tasks.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Threading.Tasks.Extensions">
<HintPath>..\..\packages\Microsoft.Bcl.Async.1.0.16\lib\sl4\Microsoft.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Threading.Tasks.Extensions.Silverlight">
<HintPath>..\..\packages\Microsoft.Bcl.Async.1.0.16\lib\sl4\Microsoft.Threading.Tasks.Extensions.Silverlight.dll</HintPath>
</Reference>
<Reference Include="mscorlib" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Runtime">
<HintPath>..\..\packages\Microsoft.Bcl.1.0.19\lib\sl5\System.Runtime.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Tasks">
<HintPath>..\..\packages\Microsoft.Bcl.1.0.19\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="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.10\tools\Microsoft.Bcl.Build.targets" Condition="Exists('..\..\packages\Microsoft.Bcl.Build.1.0.10\tools\Microsoft.Bcl.Build.targets')" />
<Target Name="EnsureBclBuildImported" BeforeTargets="BeforeBuild" Condition="'$(BclBuildImported)' == ''">
<Error Condition="!Exists('..\..\packages\Microsoft.Bcl.Build.1.0.10\tools\Microsoft.Bcl.Build.targets')" Text="This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=317567." HelpKeyword="BCLBUILD2001" />
<Error Condition="Exists('..\..\packages\Microsoft.Bcl.Build.1.0.10\tools\Microsoft.Bcl.Build.targets')" Text="The build restored NuGet packages. Build the project again to include these packages in the build. For more information, see http://go.microsoft.com/fwlink/?LinkID=317568." HelpKeyword="BCLBUILD2002" />
</Target>
</Project>
@@ -0,0 +1,6 @@
<Deployment xmlns="http://schemas.microsoft.com/client/2007/deployment"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
>
<Deployment.Parts>
</Deployment.Parts>
</Deployment>
@@ -0,0 +1,35 @@
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")]
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Bcl" version="1.0.19" targetFramework="sl50" />
<package id="Microsoft.Bcl.Async" version="1.0.16" targetFramework="sl50" />
<package id="Microsoft.Bcl.Build" version="1.0.10" targetFramework="sl50" />
</packages>
@@ -0,0 +1,20 @@
<Application
x:Class="PocketSharp.WP8.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>
<local:LocalizedStrings xmlns:local="clr-namespace:PocketSharp.WP8" x:Key="LocalizedStrings"/>
</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>
@@ -0,0 +1,247 @@
using System;
using System.Diagnostics;
using System.Resources;
using System.Windows;
using System.Windows.Markup;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using PocketSharp.WP8.Resources;
using PocketSharp.WP8.ViewModels;
namespace PocketSharp.WP8
{
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 static PhoneApplicationFrame RootFrame { get; private set; }
/// <summary>
/// Constructor for the Application object.
/// </summary>
public App()
{
// Global handler for uncaught exceptions.
UnhandledException += Application_UnhandledException;
// Standard XAML initialization
InitializeComponent();
// Phone-specific initialization
InitializePhoneApplication();
// Language display initialization
InitializeLanguage();
// Show graphics profiling information while debugging.
if (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 GPU with a colored overlay.
//Application.Current.Host.Settings.EnableCacheVisualization = true;
// Prevent the screen from turning off while under the debugger by disabling
// the application's idle detection.
// 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)
{
// Ensure that application state is restored appropriately
if (!App.ViewModel.IsDataLoaded)
{
App.ViewModel.LoadData();
}
}
// 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)
{
// Ensure that required application state is persisted here.
}
// 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 (Debugger.IsAttached)
{
// A navigation has failed; break into the debugger
Debugger.Break();
}
}
// Code to execute on Unhandled Exceptions
private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
{
if (Debugger.IsAttached)
{
// An unhandled exception has occurred; break into the debugger
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;
// Handle reset requests for clearing the backstack
RootFrame.Navigated += CheckForResetNavigation;
// 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;
}
private void CheckForResetNavigation(object sender, NavigationEventArgs e)
{
// If the app has received a 'reset' navigation, then we need to check
// on the next navigation to see if the page stack should be reset
if (e.NavigationMode == NavigationMode.Reset)
RootFrame.Navigated += ClearBackStackAfterReset;
}
private void ClearBackStackAfterReset(object sender, NavigationEventArgs e)
{
// Unregister the event so it doesn't get called again
RootFrame.Navigated -= ClearBackStackAfterReset;
// Only clear the stack for 'new' (forward) and 'refresh' navigations
if (e.NavigationMode != NavigationMode.New && e.NavigationMode != NavigationMode.Refresh)
return;
// For UI consistency, clear the entire page stack
while (RootFrame.RemoveBackEntry() != null)
{
; // do nothing
}
}
#endregion
// Initialize the app's font and flow direction as defined in its localized resource strings.
//
// To ensure that the font of your application is aligned with its supported languages and that the
// FlowDirection for each of those languages follows its traditional direction, ResourceLanguage
// and ResourceFlowDirection should be initialized in each resx file to match these values with that
// file's culture. For example:
//
// AppResources.es-ES.resx
// ResourceLanguage's value should be "es-ES"
// ResourceFlowDirection's value should be "LeftToRight"
//
// AppResources.ar-SA.resx
// ResourceLanguage's value should be "ar-SA"
// ResourceFlowDirection's value should be "RightToLeft"
//
// For more info on localizing Windows Phone apps see http://go.microsoft.com/fwlink/?LinkId=262072.
//
private void InitializeLanguage()
{
try
{
// Set the font to match the display language defined by the
// ResourceLanguage resource string for each supported language.
//
// Fall back to the font of the neutral language if the Display
// language of the phone is not supported.
//
// If a compiler error is hit then ResourceLanguage is missing from
// the resource file.
RootFrame.Language = XmlLanguage.GetLanguage(AppResources.ResourceLanguage);
// Set the FlowDirection of all elements under the root frame based
// on the ResourceFlowDirection resource string for each
// supported language.
//
// If a compiler error is hit then ResourceFlowDirection is missing from
// the resource file.
FlowDirection flow = (FlowDirection)Enum.Parse(typeof(FlowDirection), AppResources.ResourceFlowDirection);
RootFrame.FlowDirection = flow;
}
catch
{
// If an exception is caught here it is most likely due to either
// ResourceLangauge not being correctly set to a supported language
// code or ResourceFlowDirection is set to a value other than LeftToRight
// or RightToLeft.
if (Debugger.IsAttached)
{
Debugger.Break();
}
throw;
}
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

@@ -0,0 +1,44 @@
<phone:PhoneApplicationPage
x:Class="PocketSharp.WP8.DetailsPage"
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"
d:DataContext="{d:DesignData SampleData/MainViewModelSampleData.xaml}"
mc:Ignorable="d"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
shell:SystemTray.IsVisible="True">
<!--Data context is set to sample data above and first item in sample data collection below and LayoutRoot contains the root grid where all other page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent" d:DataContext="{Binding Items[0]}">
<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 Text="MY APPLICATION" Style="{StaticResource PhoneTextNormalStyle}"/>
<TextBlock Text="{Binding LineOne}" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
</StackPanel>
<!--ContentPanel contains details text. Place additional content here-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<TextBlock Text="{Binding LineThree}" TextWrapping="Wrap" Style="{StaticResource PhoneTextNormalStyle}"/>
</Grid>
<!--Uncomment to see an alignment grid to help ensure your controls are
aligned on common boundaries. The image has a top margin of -32px to
account for the System Tray. Set this to 0 (or remove the margin altogether)
if the System Tray is hidden.
Before shipping remove this XAML and the image itself.-->
<!--<Image Source="/Assets/AlignmentGrid.png" VerticalAlignment="Top" Height="800" Width="480" Margin="0,-32,0,0" Grid.Row="0" Grid.RowSpan="2" IsHitTestVisible="False" />-->
</Grid>
</phone:PhoneApplicationPage>
@@ -0,0 +1,55 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using PocketSharp.WP8.Resources;
namespace PocketSharp.WP8
{
public partial class DetailsPage : PhoneApplicationPage
{
// Constructor
public DetailsPage()
{
InitializeComponent();
// Sample code to localize the ApplicationBar
//BuildLocalizedApplicationBar();
}
// When page is navigated to set data context to selected item in list
protected override void OnNavigatedTo(NavigationEventArgs e)
{
if (DataContext == null)
{
string selectedIndex = "";
if (NavigationContext.QueryString.TryGetValue("selectedItem", out selectedIndex))
{
int index = int.Parse(selectedIndex);
DataContext = App.ViewModel.Items[index];
}
}
}
// Sample code for building a localized ApplicationBar
//private void BuildLocalizedApplicationBar()
//{
// // Set the page's ApplicationBar to a new instance of ApplicationBar.
// ApplicationBar = new ApplicationBar();
// // Create a new button and set the text value to the localized string from AppResources.
// ApplicationBarIconButton appBarButton = new ApplicationBarIconButton(new Uri("/Assets/AppBar/appbar.add.rest.png", UriKind.Relative));
// appBarButton.Text = AppResources.AppBarButtonText;
// ApplicationBar.Buttons.Add(appBarButton);
// // Create a new menu item with the localized string from AppResources.
// ApplicationBarMenuItem appBarMenuItem = new ApplicationBarMenuItem(AppResources.AppBarMenuItemText);
// ApplicationBar.MenuItems.Add(appBarMenuItem);
//}
}
}
@@ -0,0 +1,14 @@
using PocketSharp.WP8.Resources;
namespace PocketSharp.WP8
{
/// <summary>
/// Provides access to string resources.
/// </summary>
public class LocalizedStrings
{
private static AppResources _localizedResources = new AppResources();
public AppResources LocalizedResources { get { return _localizedResources; } }
}
}
@@ -0,0 +1,72 @@
<phone:PhoneApplicationPage
x:Class="PocketSharp.WP8.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:DataContext="{d:DesignData SampleData/MainViewModelSampleData.xaml}"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
shell:SystemTray.IsVisible="True">
<!--Data context is set to sample data above and LayoutRoot contains the root grid where all other page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!-- LOCALIZATION NOTE:
To localize the displayed strings copy their values to appropriately named
keys in the app's neutral language resource file (AppResources.resx) then
replace the hard-coded text value between the attributes' quotation marks
with the binding clause whose path points to that string name.
For example:
Text="{Binding Path=LocalizedResources.ApplicationTitle, Source={StaticResource LocalizedStrings}}"
This binding points to the template's string resource named "ApplicationTitle".
Adding supported languages in the Project Properties tab will create a
new resx file per language that can carry the translated values of your
UI strings. The binding in these examples will cause the value of the
attributes to be drawn from the .resx file that matches the
CurrentUICulture of the app at run time.
-->
<!--TitlePanel contains the name of the application and page title-->
<StackPanel Grid.Row="0" Margin="12,17,0,28">
<TextBlock Text="MY APPLICATION" Style="{StaticResource PhoneTextNormalStyle}"/>
<TextBlock Text="page name" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
</StackPanel>
<!--ContentPanel contains LongListSelector and LongListSelector ItemTemplate. Place additional content here-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<phone:LongListSelector x:Name="MainLongListSelector" Margin="0,0,-12,0" ItemsSource="{Binding Items}" SelectionChanged="MainLongListSelector_SelectionChanged">
<phone:LongListSelector.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>
</phone:LongListSelector.ItemTemplate>
</phone:LongListSelector>
</Grid>
<!--Uncomment to see an alignment grid to help ensure your controls are
aligned on common boundaries. The image has a top margin of -32px to
account for the System Tray. Set this to 0 (or remove the margin altogether)
if the System Tray is hidden.
Before shipping remove this XAML and the image itself.-->
<!--<Image Source="/Assets/AlignmentGrid.png" VerticalAlignment="Top" Height="800" Width="480" Margin="0,-32,0,0" Grid.Row="0" Grid.RowSpan="2" IsHitTestVisible="False" />-->
</Grid>
</phone:PhoneApplicationPage>
@@ -0,0 +1,69 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using PocketSharp.WP8.Resources;
using PocketSharp.WP8.ViewModels;
using System.Threading.Tasks;
namespace PocketSharp.WP8
{
public partial class MainPage : PhoneApplicationPage
{
// Constructor
public MainPage()
{
InitializeComponent();
// Set the data context of the LongListSelector control to the sample data
DataContext = App.ViewModel;
// Sample code to localize the ApplicationBar
//BuildLocalizedApplicationBar();
}
// Load data for the ViewModel Items
protected async override void OnNavigatedTo(NavigationEventArgs e)
{
if (!App.ViewModel.IsDataLoaded)
{
await App.ViewModel.LoadData();
}
}
// Handle selection changed on LongListSelector
private void MainLongListSelector_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
// If selected item is null (no selection) do nothing
if (MainLongListSelector.SelectedItem == null)
return;
// Navigate to the new page
NavigationService.Navigate(new Uri("/DetailsPage.xaml?selectedItem=" + (MainLongListSelector.SelectedItem as ItemViewModel).ID, UriKind.Relative));
// Reset selected item to null (no selection)
MainLongListSelector.SelectedItem = null;
}
// Sample code for building a localized ApplicationBar
//private void BuildLocalizedApplicationBar()
//{
// // Set the page's ApplicationBar to a new instance of ApplicationBar.
// ApplicationBar = new ApplicationBar();
// // Create a new button and set the text value to the localized string from AppResources.
// ApplicationBarIconButton appBarButton = new ApplicationBarIconButton(new Uri("/Assets/AppBar/appbar.add.rest.png", UriKind.Relative));
// appBarButton.Text = AppResources.AppBarButtonText;
// ApplicationBar.Buttons.Add(appBarButton);
// // Create a new menu item with the localized string from AppResources.
// ApplicationBarMenuItem appBarMenuItem = new ApplicationBarMenuItem(AppResources.AppBarMenuItemText);
// ApplicationBar.MenuItems.Add(appBarMenuItem);
//}
}
}
@@ -0,0 +1,199 @@
<?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>{47721A56-2128-4C5A-8B92-995FFC353304}</ProjectGuid>
<ProjectTypeGuids>{C089C8C0-30E0-4E22-80C0-CE093F111A43};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>PocketSharp.WP8</RootNamespace>
<AssemblyName>PocketSharp.WP8</AssemblyName>
<TargetFrameworkIdentifier>WindowsPhone</TargetFrameworkIdentifier>
<TargetFrameworkVersion>v8.0</TargetFrameworkVersion>
<SilverlightVersion>$(TargetFrameworkVersion)</SilverlightVersion>
<SilverlightApplication>true</SilverlightApplication>
<SupportedCultures>
</SupportedCultures>
<XapOutputs>true</XapOutputs>
<GenerateSilverlightManifest>true</GenerateSilverlightManifest>
<XapFilename>PocketSharp.WP8_$(Configuration)_$(Platform).xap</XapFilename>
<SilverlightManifestTemplate>Properties\AppManifest.xml</SilverlightManifestTemplate>
<SilverlightAppEntry>PocketSharp.WP8.App</SilverlightAppEntry>
<ValidateXaml>true</ValidateXaml>
<MinimumVisualStudioVersion>11.0</MinimumVisualStudioVersion>
<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>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>Bin\x86\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|x86' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>Bin\x86\Release</OutputPath>
<DefineConstants>TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
<NoStdLib>true</NoStdLib>
<NoConfig>true</NoConfig>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|ARM' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>Bin\ARM\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|ARM' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>Bin\ARM\Release</OutputPath>
<DefineConstants>TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
<NoStdLib>true</NoStdLib>
<NoConfig>true</NoConfig>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
</Compile>
<Compile Include="LocalizedStrings.cs" />
<Compile Include="DetailsPage.xaml.cs">
<DependentUpon>DetailsPage.xaml</DependentUpon>
</Compile>
<Compile Include="MainPage.xaml.cs">
<DependentUpon>MainPage.xaml</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Resources\AppResources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>AppResources.resx</DependentUpon>
</Compile>
<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="DetailsPage.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="MainPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<DesignData Include="SampleData\MainViewModelSampleData.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</DesignData>
</ItemGroup>
<ItemGroup>
<None Include="Properties\AppManifest.xml" />
<None Include="Properties\WMAppManifest.xml">
<SubType>Designer</SubType>
</None>
</ItemGroup>
<ItemGroup>
<Content Include="Assets\AlignmentGrid.png" />
<Content Include="Assets\ApplicationIcon.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Assets\Tiles\FlipCycleTileLarge.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Assets\Tiles\FlipCycleTileMedium.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Assets\Tiles\FlipCycleTileSmall.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Assets\Tiles\IconicTileMediumLarge.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Assets\Tiles\IconicTileSmall.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Resources\AppResources.resx">
<Generator>PublicResXFileCodeGenerator</Generator>
<LastGenOutput>AppResources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\PocketSharp\PocketSharp.csproj">
<Project>{817200C3-A327-4E35-9B5F-63A51C088577}</Project>
<Name>PocketSharp</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.Threading.Tasks">
<HintPath>..\..\packages\Microsoft.Bcl.Async.1.0.16\lib\wp8\Microsoft.Threading.Tasks.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Threading.Tasks.Extensions">
<HintPath>..\..\packages\Microsoft.Bcl.Async.1.0.16\lib\wp8\Microsoft.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Threading.Tasks.Extensions.Phone">
<HintPath>..\..\packages\Microsoft.Bcl.Async.1.0.16\lib\wp8\Microsoft.Threading.Tasks.Extensions.Phone.dll</HintPath>
</Reference>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\$(TargetFrameworkIdentifier)\$(TargetFrameworkVersion)\Microsoft.$(TargetFrameworkIdentifier).$(TargetFrameworkVersion).Overrides.targets" />
<Import Project="$(MSBuildExtensionsPath)\Microsoft\$(TargetFrameworkIdentifier)\$(TargetFrameworkVersion)\Microsoft.$(TargetFrameworkIdentifier).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>
</Project>
@@ -0,0 +1,6 @@
<Deployment xmlns="http://schemas.microsoft.com/client/2007/deployment"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
>
<Deployment.Parts>
</Deployment.Parts>
</Deployment>
@@ -0,0 +1,37 @@
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.WP8")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("PocketSharp.WP8")]
[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("d4c30306-fbff-4433-8299-ecb70af9cfb6")]
// 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")]
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<Deployment xmlns="http://schemas.microsoft.com/windowsphone/2012/deployment" AppPlatformVersion="8.0">
<DefaultLanguage xmlns="" code="en-US"/>
<App xmlns="" ProductID="{47721a56-2128-4c5a-8b92-995ffc353304}" Title="PocketSharp.WP8" RuntimeType="Silverlight" Version="1.0.0.0" Genre="apps.normal" Author="PocketSharp.WP8 author" Description="Sample description" Publisher="PocketSharp.WP8" PublisherID="{d8449fc0-02fe-4be1-b0a5-3fd20d58264c}">
<IconPath IsRelative="true" IsResource="false">Assets\ApplicationIcon.png</IconPath>
<Capabilities>
<Capability Name="ID_CAP_NETWORKING"/>
<Capability Name="ID_CAP_MEDIALIB_AUDIO"/>
<Capability Name="ID_CAP_MEDIALIB_PLAYBACK"/>
<Capability Name="ID_CAP_SENSORS"/>
<Capability Name="ID_CAP_WEBBROWSERCOMPONENT"/>
</Capabilities>
<Tasks>
<DefaultTask Name ="_default" NavigationPage="MainPage.xaml"/>
</Tasks>
<Tokens>
<PrimaryToken TokenID="PocketSharp.WP8Token" TaskName="_default">
<TemplateFlip>
<SmallImageURI IsRelative="true" IsResource="false">Assets\Tiles\FlipCycleTileSmall.png</SmallImageURI>
<Count>0</Count>
<BackgroundImageURI IsRelative="true" IsResource="false">Assets\Tiles\FlipCycleTileMedium.png</BackgroundImageURI>
<Title>PocketSharp.WP8</Title>
<BackContent></BackContent>
<BackBackgroundImageURI></BackBackgroundImageURI>
<BackTitle></BackTitle>
<DeviceLockImageURI></DeviceLockImageURI>
<HasLarge></HasLarge>
</TemplateFlip>
</PrimaryToken>
</Tokens>
<ScreenResolutions>
<ScreenResolution Name="ID_RESOLUTION_WVGA"/>
<ScreenResolution Name="ID_RESOLUTION_WXGA"/>
<ScreenResolution Name="ID_RESOLUTION_HD720P"/>
</ScreenResolutions>
</App>
</Deployment>
@@ -0,0 +1,138 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.17626
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace PocketSharp.WP8.Resources
{
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
public class AppResources
{
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal AppResources()
{
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
public static global::System.Resources.ResourceManager ResourceManager
{
get
{
if (object.ReferenceEquals(resourceMan, null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("PocketSharp.WP8.Resources.AppResources", typeof(AppResources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
public static global::System.Globalization.CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
/// <summary>
/// Looks up a localized string similar to LeftToRight.
/// </summary>
public static string ResourceFlowDirection
{
get
{
return ResourceManager.GetString("ResourceFlowDirection", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to us-EN.
/// </summary>
public static string ResourceLanguage
{
get
{
return ResourceManager.GetString("ResourceLanguage", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to MY APPLICATION.
/// </summary>
public static string ApplicationTitle
{
get
{
return ResourceManager.GetString("ApplicationTitle", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Sample Runtime Property Value.
/// </summary>
public static string SampleProperty
{
get
{
return ResourceManager.GetString("SampleProperty", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to button text.
/// </summary>
public static string AppBarButtonText
{
get
{
return ResourceManager.GetString("AppBarButtonText", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to menu item.
/// </summary>
public static string AppBarMenuItemText
{
get
{
return ResourceManager.GetString("AppBarMenuItemText", resourceCulture);
}
}
}
}
@@ -0,0 +1,140 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="ResourceFlowDirection" xml:space="preserve">
<value>LeftToRight</value>
<comment>Controls the FlowDirection for all elements in the RootFrame. Set to the traditional direction of this resource file's language</comment>
</data>
<data name="ResourceLanguage" xml:space="preserve">
<value>en-US</value>
<comment>Controls the Language and ensures that the font for all elements in the RootFrame aligns with the app's language. Set to the language code of this resource file's language.</comment>
</data>
<data name="ApplicationTitle" xml:space="preserve">
<value>MY APPLICATION</value>
</data>
<data name="SampleProperty" xml:space="preserve">
<value>Sample Runtime Property Value</value>
</data>
<data name="AppBarButtonText" xml:space="preserve">
<value>add</value>
</data>
<data name="AppBarMenuItemText" xml:space="preserve">
<value>Menu Item</value>
</data>
</root>
@@ -0,0 +1,16 @@
<vm:MainViewModel
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="clr-namespace:PocketSharp.WP8.ViewModels"
SampleProperty="Sample Text Property Value">
<vm:MainViewModel.Items>
<vm:ItemViewModel ID="0" LineOne="design one" LineTwo="Maecenas praesent accumsan bibendum" LineThree="Maecenas praesent accumsan bibendum dictumst eleifend facilisi faucibus habitant inceptos interdum lobortis nascetur"/>
<vm:ItemViewModel ID="1" LineOne="design two" LineTwo="Dictumst eleifend facilisi faucibus" LineThree="Pharetra placerat pulvinar sagittis senectus sociosqu suscipit torquent ultrices vehicula volutpat maecenas praesent"/>
<vm:ItemViewModel ID="2" LineOne="design three" LineTwo="Habitant inceptos interdum lobortis" LineThree="Accumsan bibendum dictumst eleifend facilisi faucibus habitant inceptos interdum lobortis nascetur pharetra placerat"/>
<vm:ItemViewModel ID="3" LineOne="design four" LineTwo="Nascetur pharetra placerat pulvinar" LineThree="Pulvinar sagittis senectus sociosqu suscipit torquent ultrices vehicula volutpat maecenas praesent accumsan bibendum"/>
<vm:ItemViewModel ID="4" LineOne="design five" LineTwo="Sagittis senectus sociosqu suscipit" LineThree="Dictumst eleifend facilisi faucibus habitant inceptos interdum lobortis nascetur pharetra placerat pulvinar sagittis"/>
<vm:ItemViewModel ID="5" LineOne="design six" LineTwo="Torquent ultrices vehicula volutpat" LineThree="Senectus sociosqu suscipit torquent ultrices vehicula volutpat maecenas praesent accumsan bibendum dictumst eleifend"/>
</vm:MainViewModel.Items>
</vm:MainViewModel>
@@ -0,0 +1,109 @@
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
namespace PocketSharp.WP8.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));
}
}
}
}
@@ -0,0 +1,108 @@
using System;
using System.Collections.ObjectModel;
using System.ComponentModel;
using PocketSharp.WP8.Resources;
using PocketSharp;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Diagnostics;
namespace PocketSharp.WP8.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 AppResources.SampleProperty;
}
}
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: "2c62cd50-b78a-5558-918b-65adae"
);
List<PocketSharp.Models.PocketItem> items = null;
try
{
items = await client.Retrieve().ConfigureAwait(false);
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));
}
}
}
}
@@ -0,0 +1,8 @@
<Application x:Class="PocketSharp.Wpf.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Windows;
namespace PocketSharp.Wpf
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}
@@ -0,0 +1,18 @@
<Window x:Class="PocketSharp.Wpf.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
DataContext="{Binding RelativeSource={RelativeSource Self}}"
Title="MainWindow" Height="443" Width="591">
<Grid>
<Button Content="Button" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Width="75" Click="Button_Click" RenderTransformOrigin="0.547,0.566"/>
<ListView ItemsSource="{Binding Sites}" HorizontalAlignment="Left" Height="349" Margin="10,51,0,0" VerticalAlignment="Top" Width="561">
<ListView.View>
<GridView>
<GridViewColumn Width="160" Header="URL" DisplayMemberBinding="{Binding Url}" />
<GridViewColumn Width="401" Header="Content" DisplayMemberBinding="{Binding Content}" />
</GridView>
</ListView.View>
</ListView>
</Grid>
</Window>
@@ -0,0 +1,62 @@
using System.Windows;
using System.Windows.Controls;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Collections.Generic;
using System;
namespace PocketSharp.Wpf
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
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 MainWindow()
{
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: "2c62cd50-b78a-5558-918b-65adae"
);
List<PocketSharp.Models.PocketItem> items = null;
try
{
items = await client.Retrieve();
items.ForEach(item =>
{
Sites.Add(new Site()
{
Content = item.Title,
Url = item.Uri.ToString()
});
});
}
catch (PocketException ex)
{
Debug.Write(ex.Message);
}
}
}
}
@@ -0,0 +1,143 @@
<?xml version="1.0" encoding="utf-8"?>
<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>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{775569C2-987F-4AC4-8BA5-A315A21ED1B7}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>PocketSharp.Wpf</RootNamespace>
<AssemblyName>PocketSharp.Wpf</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<TargetFrameworkProfile />
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
<RestorePackages>true</RestorePackages>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Threading.Tasks">
<HintPath>..\..\packages\Microsoft.Bcl.Async.1.0.16\lib\net45\Microsoft.Threading.Tasks.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Threading.Tasks.Extensions">
<HintPath>..\..\packages\Microsoft.Bcl.Async.1.0.16\lib\net45\Microsoft.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Net" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Net.Http.Extensions">
<HintPath>..\..\packages\Microsoft.Net.Http.2.2.13\lib\net45\System.Net.Http.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.Net.Http.Primitives, Version=4.2.13.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\Microsoft.Net.Http.2.2.13\lib\net45\System.Net.Http.Primitives.dll</HintPath>
</Reference>
<Reference Include="System.Net.Http.WebRequest" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="Site.cs" />
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="app.config" />
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<AppDesigner Include="Properties\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\PocketSharp\PocketSharp.csproj">
<Project>{817200c3-a327-4e35-9b5f-63a51c088577}</Project>
<Name>PocketSharp</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
</Target>
<Import Project="..\..\packages\Microsoft.Bcl.Build.1.0.10\tools\Microsoft.Bcl.Build.targets" Condition="Exists('..\..\packages\Microsoft.Bcl.Build.1.0.10\tools\Microsoft.Bcl.Build.targets')" />
<Target Name="EnsureBclBuildImported" BeforeTargets="BeforeBuild" Condition="'$(BclBuildImported)' == ''">
<Error Condition="!Exists('..\..\packages\Microsoft.Bcl.Build.1.0.10\tools\Microsoft.Bcl.Build.targets')" Text="This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=317567." HelpKeyword="BCLBUILD2001" />
<Error Condition="Exists('..\..\packages\Microsoft.Bcl.Build.1.0.10\tools\Microsoft.Bcl.Build.targets')" Text="The build restored NuGet packages. Build the project again to include these packages in the build. For more information, see http://go.microsoft.com/fwlink/?LinkID=317568." HelpKeyword="BCLBUILD2002" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
@@ -0,0 +1,55 @@
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;
// 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.Wpf")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("PocketSharp.Wpf")]
[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)]
//In order to begin building localizable applications, set
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
//inside a <PropertyGroup>. For example, if you are using US english
//in your source files, set the <UICulture> to en-US. Then uncomment
//the NeutralResourceLanguage attribute below. Update the "en-US" in
//the line below to match the UICulture setting in the project file.
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]
// 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 Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
@@ -0,0 +1,63 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.18213
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace PocketSharp.Wpf.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("PocketSharp.Wpf.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}
@@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
@@ -0,0 +1,26 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.18213
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace PocketSharp.Wpf.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
}
}
@@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PocketSharp.Wpf
{
public class Site
{
public string Url { get; set; }
public string Content { get; set; }
}
}
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /></startup>
<runtime>
<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.13.0" newVersion="4.2.13.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Bcl" version="1.1.3" targetFramework="net45" />
<package id="Microsoft.Bcl.Async" version="1.0.16" targetFramework="net45" />
<package id="Microsoft.Bcl.Build" version="1.0.10" targetFramework="net45" />
<package id="Microsoft.Net.Http" version="2.2.13" targetFramework="net45" />
</packages>
+55
View File
@@ -0,0 +1,55 @@
using System;
using System.Threading.Tasks;
using System.Collections.Generic;
using Xunit;
using PocketSharp.Models;
namespace PocketSharp.Tests
{
public class AddTests : TestsBase
{
public AddTests() : base() { }
[Fact]
public async Task AddSimpleItemWithUriOnly()
{
var uri = new Uri("http://frontendplay.com");
PocketItem item = await client.Add(uri);
Assert.Equal<Uri>(uri, item.Uri);
itemsToDelete.Add(item.ID);
}
[Fact]
public async Task AddComplexItem()
{
PocketItem item = await client.Add(
uri: new Uri("http://frontendplay.com"),
tags: new string[] { "blog", "frontend", "cee" },
title: "ignored title",
tweetID: "380051788172632065"
);
List<PocketItem> items = await client.Retrieve();
PocketItem itemDesired = null;
items.ForEach(itm =>
{
if(itm.ID == item.ID)
{
itemDesired = itm;
}
});
Assert.NotNull(itemDesired);
Assert.Equal(itemDesired.ID, item.ID);
Assert.Equal(itemDesired.Tags.Count, 3);
itemsToDelete.Add(item.ID);
}
}
}
+13
View File
@@ -0,0 +1,13 @@
using System;
using System.Threading.Tasks;
using System.Collections.Generic;
using Xunit;
using PocketSharp.Models;
namespace PocketSharp.Tests
{
class AuthenticationTests : TestsBase
{
public AuthenticationTests() : base() { }
}
}
+13
View File
@@ -0,0 +1,13 @@
using System;
using System.Threading.Tasks;
using System.Collections.Generic;
using Xunit;
using PocketSharp.Models;
namespace PocketSharp.Tests
{
class ModifyTagsTests : TestsBase
{
public ModifyTagsTests() : base() { }
}
}
+13
View File
@@ -0,0 +1,13 @@
using System;
using System.Threading.Tasks;
using System.Collections.Generic;
using Xunit;
using PocketSharp.Models;
namespace PocketSharp.Tests
{
class ModifyTests : TestsBase
{
public ModifyTests() : base() { }
}
}
+50 -10
View File
@@ -3,12 +3,12 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{F1CEA363-7039-40BA-9744-0071F46BB90C}</ProjectGuid>
<ProjectGuid>{CA3C491B-A8CA-426C-A0BB-E91636767467}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>PocketSharp.Tests</RootNamespace>
<AssemblyName>PocketSharp.Tests</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
@@ -16,6 +16,8 @@
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
<IsCodedUITest>False</IsCodedUITest>
<TestProjectType>UnitTest</TestProjectType>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<RestorePackages>true</RestorePackages>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -35,9 +37,24 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Threading.Tasks">
<HintPath>..\packages\Microsoft.Bcl.Async.1.0.16\lib\net45\Microsoft.Threading.Tasks.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Threading.Tasks.Extensions">
<HintPath>..\packages\Microsoft.Bcl.Async.1.0.16\lib\net45\Microsoft.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
<Reference Include="System.Net" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Net.Http.Extensions">
<HintPath>..\packages\Microsoft.Net.Http.2.2.13\lib\net45\System.Net.Http.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.Net.Http.Primitives">
<HintPath>..\packages\Microsoft.Net.Http.2.2.13\lib\net45\System.Net.Http.Primitives.dll</HintPath>
</Reference>
<Reference Include="System.Net.Http.WebRequest" />
<Reference Include="xunit">
<HintPath>..\packages\xunit.1.9.2\lib\net20\xunit.dll</HintPath>
</Reference>
</ItemGroup>
<Choose>
@@ -46,15 +63,26 @@
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
</ItemGroup>
</When>
<Otherwise>
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework" />
</ItemGroup>
</Otherwise>
<Otherwise />
</Choose>
<ItemGroup>
<Compile Include="UnitTest1.cs" />
<Compile Include="AddTests.cs" />
<Compile Include="AuthenticationTests.cs" />
<Compile Include="ModifyTagsTests.cs" />
<Compile Include="ModifyTests.cs" />
<Compile Include="RetrieveTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TestsBase.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\PocketSharp\PocketSharp.csproj">
<Project>{817200c3-a327-4e35-9b5f-63a51c088577}</Project>
<Name>PocketSharp</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
</ItemGroup>
<Choose>
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
@@ -76,6 +104,18 @@
</Choose>
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
</Target>
<Import Project="..\packages\Microsoft.Bcl.Build.1.0.10\tools\Microsoft.Bcl.Build.targets" Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.10\tools\Microsoft.Bcl.Build.targets')" />
<Target Name="EnsureBclBuildImported" BeforeTargets="BeforeBuild" Condition="'$(BclBuildImported)' == ''">
<Error Condition="!Exists('..\packages\Microsoft.Bcl.Build.1.0.10\tools\Microsoft.Bcl.Build.targets')" Text="This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=317567." HelpKeyword="BCLBUILD2001" />
<Error Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.10\tools\Microsoft.Bcl.Build.targets')" Text="The build restored NuGet packages. Build the project again to include these packages in the build. For more information, see http://go.microsoft.com/fwlink/?LinkID=317568." HelpKeyword="BCLBUILD2002" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
+1 -1
View File
@@ -20,7 +20,7 @@ using System.Runtime.InteropServices;
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("fbe5a0d2-d0de-44b1-8b8a-cf8cd3ac2230")]
[assembly: Guid("87fcf138-5e6e-4584-ac3b-58c8ee6fccaa")]
// Version information for an assembly consists of the following four values:
//
+69
View File
@@ -0,0 +1,69 @@
using System;
using System.Threading.Tasks;
using System.Collections.Generic;
using Xunit;
using PocketSharp.Models;
namespace PocketSharp.Tests
{
public class RetrieveTests : TestsBase
{
public RetrieveTests() : base() { }
[Fact]
public async Task AreItemsRetrieved()
{
List<PocketItem> items = await client.Retrieve();
Assert.True(items.Count > 0);
}
//[Fact]
//public async Task ItemContainsUri()
//{
// List<PocketItem> items = await client.Retrieve(new RetrieveParameters()
// {
// Count = 1
// });
// Assert.True(items.Count == 1);
// PocketItem item = items[0];
// Assert.True(item.Uri.ToString().StartsWith("http"));
//}
[Fact]
public async Task SearchReturnsResult()
{
List<PocketItem> items = await client.Search("pocket");
Assert.True(items.Count > 0);
Assert.True(items[0].FullTitle.ToLower().Contains("pocket"));
}
[Fact]
public async Task SearchByTagsReturnsResult()
{
List<PocketItem> items = await client.SearchByTag("pocket");
Assert.True(items.Count == 1);
bool found = false;
items[0].Tags.ForEach(tag =>
{
if (tag.Name.Contains("pocket"))
{
found = true;
}
});
Assert.True(found);
}
}
}
+37
View File
@@ -0,0 +1,37 @@
using System;
using System.Threading.Tasks;
using System.Collections.Generic;
using Xunit;
using PocketSharp.Models;
namespace PocketSharp.Tests
{
public class TestsBase : IDisposable
{
protected PocketClient client;
protected List<int> itemsToDelete = new List<int>();
// setup
public TestsBase()
{
// !! please don't misuse this account !!
client = new PocketClient(
consumerKey: "15396-f6f92101d72c8e270a6c9bb3",
callbackUri: "http://frontendplay.com",
accessCode: "2c62cd50-b78a-5558-918b-65adae"
);
}
// teardown
public void Dispose()
{
itemsToDelete.ForEach(async id =>
{
await client.Delete(id);
});
}
}
}
-14
View File
@@ -1,14 +0,0 @@
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace PocketSharp.Tests
{
[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
}
}
}
+11
View File
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<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.13.0" newVersion="4.2.13.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
+8
View File
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Bcl" version="1.1.3" targetFramework="net45" />
<package id="Microsoft.Bcl.Async" version="1.0.16" targetFramework="net45" />
<package id="Microsoft.Bcl.Build" version="1.0.10" targetFramework="net45" />
<package id="Microsoft.Net.Http" version="2.2.13" targetFramework="net45" />
<package id="xunit" version="1.9.2" targetFramework="net45" />
</packages>
Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

+45 -29
View File
@@ -53,6 +53,19 @@
<article class="article">
<div data-part="gettingstarted">
<h2>Supported platforms</h2>
<p>PocketSharp is a <strong>Portable Class Library</strong> (since 1.0.0), therefore it's compatible with multiple platforms:</p>
<ul>
<li><strong>.NET</strong> &gt;= 4.0.3 (including WPF)</li>
<li><strong>Silverlight</strong> &gt;= 4</li>
<li><strong>Windows Phone</strong> &gt;= 7.5</li>
<li><strong>Windows Store</strong></li>
</ul>
<p>You can find examples for Silverlight 5, WP8 and WPF in the <code>PocketSharp.Examples</code> folder.</p>
<h2>Async Support</h2>
<p>All public methods, which communicate with the Pocket servers are asynchronous. So they should be called with the preceding <code>await</code> keyword, and the encapsulated method marked with <code>async</code>.</p>
<p><em>In PocketSharp versions &lt; 1.0.0 all methods lacked async support and were blocking.</em></p>
<h2>Getting Started</h2>
<p>Request a <a href="http://getpocket.com/developer/apps/">Consumer Key on Pocket.</a></p>
<p>Include the PocketSharp namespace and it's associated models (you will need them later):</p>
@@ -66,8 +79,8 @@ using PocketSharp.Models;</code></pre>
<p>Do a simple request - e.g. a search for <code>CSS</code>:</p>
<pre class="language-clike"><code>_client.Search(&quot;css&quot;).ForEach(
item =&gt; Console.WriteLine(item.ID + &quot; | &quot; + item.Title)
<pre class="language-clike"><code>await _client.Search(&quot;css&quot;).ForEach(
item =&gt; Debug.WriteLine(item.ID + &quot; | &quot; + item.Title)
);</code></pre>
<p>Which will output:</p>
@@ -109,6 +122,8 @@ using PocketSharp.Models;</code></pre>
<h2>Release History</h2>
<ul>
<li>2013-09-15 v1.0.0 convert to PCL &amp; implement async</li>
<li>2013-08-16 v0.3.2 tag modification fixed and full retrieval of items for Retrieve method</li>
<li>2013-07-07 v0.3.1 authentication fixes</li>
<li>2013-07-02 v0.3.0 update authentication process </li>
<li>2013-06-27 v0.2.0 add, modify item &amp; modify tags</li>
@@ -116,8 +131,9 @@ using PocketSharp.Models;</code></pre>
</ul>
<h2>Used Packages</h2>
<ul>
<li><a href="http://restsharp.org/">RestSharp</a></li>
<li><a href="https://github.com/ServiceStack/ServiceStack.Text">ServiceStack.Text</a></li>
<li><a href="https://www.nuget.org/packages/Microsoft.Bcl.Async/">Microsoft.Bcl.Async</a></li>
<li><a href="https://www.nuget.org/packages/Microsoft.Net.Http/">Microsoft.Net.Http</a></li>
<li><a href="https://www.nuget.org/packages/Newtonsoft.Json/">Newtonsoft.Json</a></li>
</ul>
<h2>Contributors</h2>
<p>
@@ -137,7 +153,7 @@ using PocketSharp.Models;</code></pre>
<h4>1) Generate authentication URI</h4>
<p>Receive the <strong>request code</strong> and <strong>authentication URI</strong> from the library by calling <code>string GetRequestCode()</code>:</p>
<pre class="language-clike"><code>string requestCode = _client.GetRequestCode();
<pre class="language-clike"><code>string requestCode = await _client.GetRequestCode();
// 0f453f2d-1605-8584-28fd-39af8e
Uri authenticationUri = _client.GenerateAuthenticationUri();
// https://getpocket.com/auth/authorize?request_token=0f453f2d-1605-8584-28fd-39af8e&amp;redirect_uri=http%253a%252f%252fceecore.com</code></pre>
@@ -148,9 +164,9 @@ Uri authenticationUri = _client.GenerateAuthenticationUri();
<p>
<img src="https://raw.github.com/ceee/PocketSharp/master/PocketSharp/authentication-screen.png" alt="authentication screen" /></p>
<h4>3) Get Access Code</h4>
<p>Call <code>string GetAccessCode(string requestCode = null)</code></p>
<p>Call <code>Task&lt;string&gt; GetAccessCode(string requestCode = null)</code></p>
<pre class="language-clike"><code>string accessCode = _client.GetAccessCode();
<pre class="language-clike"><code>string accessCode = await _client.GetAccessCode();
// fa8bfc16-69b3-4d22-7db7-84a58d</code></pre>
<p>
@@ -163,29 +179,29 @@ Note that <code>GetAccessCode</code> can only be called with an existing <em>req
<br>
Without it you would always have to redo the authentication process.
</p>
</div>
<div data-part="retrieve">
<h2>Retrieve</h2>
<p>Get list of all items:</p>
<pre class="language-clike"><code>List&lt;PocketItem&gt; items = _client.Retrieve();
// equivalent to: _client.Retrieve(RetrieveFilter.All)</code></pre>
<pre class="language-clike"><code>List&lt;PocketItem&gt; items = await _client.Retrieve();
// equivalent to: await _client.Retrieve(RetrieveFilter.All)</code></pre>
<p>Find items by a tag:</p>
<pre class="language-clike"><code>List&lt;PocketItem&gt; items = _client.SearchByTag(&quot;tutorial&quot;);</code></pre>
<pre class="language-clike"><code>List&lt;PocketItem&gt; items = await _client.SearchByTag(&quot;tutorial&quot;);</code></pre>
<p>Find items by a search string:</p>
<pre class="language-clike"><code>List&lt;PocketItem&gt; items = _client.Search(&quot;css&quot;);</code></pre>
<pre class="language-clike"><code>List&lt;PocketItem&gt; items = await _client.Search(&quot;css&quot;);</code></pre>
<p>Find items by a filter:</p>
<pre class="language-clike"><code>List&lt;PocketItem&gt; items = _client.Retrieve(RetrieveFilter.Favorite); // only favorites</code></pre>
<pre class="language-clike"><code>List&lt;PocketItem&gt; items = await _client.Retrieve(RetrieveFilter.Favorite); // only favorites</code></pre>
<p>The RetrieveFilter Enum is specified as follows:</p>
@@ -202,7 +218,7 @@ var parameters = new RetrieveParameters()
Sort = SortEnum.oldest
...
};
List&lt;pocketitem&gt; items = _client.Retrieve(parameters);
List&lt;pocketitem&gt; items = await _client.Retrieve(parameters);
</code></pre>
@@ -216,63 +232,63 @@ List&lt;pocketitem&gt; items = _client.Retrieve(parameters);
Accepts four parameters, with <code>uri</code> being required.
</p>
<pre class="language-clike"><code>PocketItem Add(Uri uri, string[] tags = null, string title = null, string tweetID = null)</code></pre>
<pre class="language-clike"><code>Task&lt;PocketItem&gt; Add(Uri uri, string[] tags = null, string title = null, string tweetID = null)</code></pre>
<p>Example:</p>
<pre class="language-clike"><code>PocketItem newItem = _client.Add(
<pre class="language-clike"><code>PocketItem newItem = await _client.Add(
new Uri(&quot;http:&frasl;&frasl;www.neowin.net/news/full-build-2013-conference-sessions-listing-revealed&quot;),
new string[] { &quot;microsoft&quot;, &quot;neowin&quot;, &quot;build&quot; }
);</code></pre>
<p>The title can be included for cases where an item does not have a title, which is typical for image or PDF URLs. If Pocket detects a title from the content of the page, this parameter will be ignored.</p>
<p>If you are adding Pocket support to a Twitter client, please send along a reference to the tweet status id (with the tweetID). This allows Pocket to show the original tweet alongside the article.</p>
</div>
<div data-part="modify">
<h2>Modify</h2>
<p>All Modify methods accept either the itemID (as int) or a <code>PocketItem</code> as parameter.</p>
<p>Archive the specified item:</p>
<pre class="language-clike"><code>bool isSuccess = _client.Archive(myPocketItem);
<pre class="language-clike"><code>bool isSuccess = await _client.Archive(myPocketItem);
</code></pre>
<p>Un-archive the specified item:</p>
<pre class="language-clike"><code>bool isSuccess = _client.Unarchive(myPocketItem);
<pre class="language-clike"><code>bool isSuccess = await _client.Unarchive(myPocketItem);
</code></pre>
<p>Favorites the specified item:</p>
<pre class="language-clike"><code>bool isSuccess = _client.Favorite(myPocketItem);
<pre class="language-clike"><code>bool isSuccess = await _client.Favorite(myPocketItem);
</code></pre>
<p>Un-favorites the specified item:</p>
<pre class="language-clike"><code>bool isSuccess = _client.Unfavorite(myPocketItem);
<pre class="language-clike"><code>bool isSuccess = await _client.Unfavorite(myPocketItem);
</code></pre>
<p>Deletes the specified item:</p>
<pre class="language-clike"><code>bool isSuccess = _client.Delete(myPocketItem);
<pre class="language-clike"><code>bool isSuccess = await _client.Delete(myPocketItem);
</code></pre>
<h4>Modify tags</h4>
<p>Add tags to the specified item:</p>
<pre class="language-clike"><code>bool isSuccess = _client.AddTags(myPocketItem, new string[] { &quot;css&quot;, &quot;2013&quot; });
<pre class="language-clike"><code>bool isSuccess = await _client.AddTags(myPocketItem, new string[] { &quot;css&quot;, &quot;2013&quot; });
</code></pre>
<p>Remove tags from the specified item:</p>
<pre class="language-clike"><code>bool isSuccess = _client.RemoveTags(myPocketItem, new string[] { &quot;css&quot;, &quot;2013&quot; });
<pre class="language-clike"><code>bool isSuccess = await _client.RemoveTags(myPocketItem, new string[] { &quot;css&quot;, &quot;2013&quot; });
</code></pre>
<p>Remove all tags from the specified item:</p>
<pre class="language-clike"><code>bool isSuccess = _client.RemoveTags(myPocketItem);
<pre class="language-clike"><code>bool isSuccess = await _client.RemoveTags(myPocketItem);
</code></pre>
<p>Replaces all existing tags with new ones for the specified item:</p>
<pre class="language-clike"><code>bool isSuccess = _client.ReplaceTags(myPocketItem, new string[] { &quot;css&quot;, &quot;2013&quot; });
<pre class="language-clike"><code>bool isSuccess = await _client.ReplaceTags(myPocketItem, new string[] { &quot;css&quot;, &quot;2013&quot; });
</code></pre>
<p>Renames a tag for the specified item:</p>
<pre class="language-clike"><code>bool isSuccess = _client.RenameTag(myPocketItem, &quot;oldTagName&quot;, &quot;newTagName&quot;);
<pre class="language-clike"><code>bool isSuccess = await _client.RenameTag(myPocketItem, &quot;oldTagName&quot;, &quot;newTagName&quot;);
</code></pre>
</div>
-41
View File
@@ -1,41 +0,0 @@
<?xml version="1.0"?>
<package >
<metadata>
<id>PocketSharp</id>
<version>0.3.1</version>
<title>PocketSharp</title>
<authors>Tobias Klika</authors>
<owners>Tobias Klika</owners>
<licenseUrl>https://raw.github.com/ceee/PocketSharp/master/LICENSE-MIT</licenseUrl>
<projectUrl>http://pocketsharp.frontendplay.com</projectUrl>
<iconUrl>http://pocketsharp.frontendplay.com/Assets/Images/pocketsharp.png</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>PocketSharp is a .NET class library, that integrates the Pocket API v3</description>
<language>en-US</language>
<releaseNotes>
<![CDATA[
For full release notes see https://github.com/ceee/PocketSharp#release-history
]]>
</releaseNotes>
<copyright>Copyright by cee, 2013</copyright>
<tags>PocketAPI Pocket API PocketSharp Tobias Klika cee RestSharp</tags>
<dependencies>
<dependency id="ServiceStack.Text" version="3.9.49" />
<dependency id="RestSharp" version="104.1" />
</dependencies>
<frameworkAssemblies>
<frameworkAssembly assemblyName="System" targetFramework="net40" />
<frameworkAssembly assemblyName="System.Core" targetFramework="net40" />
<frameworkAssembly assemblyName="System.Data" targetFramework="net40" />
<frameworkAssembly assemblyName="System.Data.DataSetExtensions" targetFramework="net40" />
<frameworkAssembly assemblyName="System.Runtime.Serialization" targetFramework="net40" />
<frameworkAssembly assemblyName="System.Xml" targetFramework="net40" />
<frameworkAssembly assemblyName="System.Xml.Linq" targetFramework="net40" />
<frameworkAssembly assemblyName="Microsoft.CSharp" targetFramework="net40" />
</frameworkAssemblies>
</metadata>
<files>
<file src="PocketSharp\bin\Release\PocketSharp.dll" target="lib/net40" />
<file src="PocketSharp\bin\Release\PocketSharp.pdb" target="lib/net40" />
</files>
</package>
+78 -16
View File
@@ -1,32 +1,94 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PocketSharp", "PocketSharp\PocketSharp.csproj", "{1A291041-ADD8-467C-A6E4-0ACA26328CDF}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PocketSharp", "PocketSharp\PocketSharp.csproj", "{817200C3-A327-4E35-9B5F-63A51C088577}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PocketSharp.Console", "PocketSharp.Console\PocketSharp.Console.csproj", "{81B7D587-A189-4785-BDFE-CA8A9ABA0760}"
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.Tests", "PocketSharp.Tests\PocketSharp.Tests.csproj", "{F1CEA363-7039-40BA-9744-0071F46BB90C}"
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
.nuget\NuGet.exe = .nuget\NuGet.exe
.nuget\NuGet.targets = .nuget\NuGet.targets
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|ARM = Debug|ARM
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|ARM = Release|ARM
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{1A291041-ADD8-467C-A6E4-0ACA26328CDF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1A291041-ADD8-467C-A6E4-0ACA26328CDF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1A291041-ADD8-467C-A6E4-0ACA26328CDF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1A291041-ADD8-467C-A6E4-0ACA26328CDF}.Release|Any CPU.Build.0 = Release|Any CPU
{81B7D587-A189-4785-BDFE-CA8A9ABA0760}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{81B7D587-A189-4785-BDFE-CA8A9ABA0760}.Debug|Any CPU.Build.0 = Debug|Any CPU
{81B7D587-A189-4785-BDFE-CA8A9ABA0760}.Release|Any CPU.ActiveCfg = Release|Any CPU
{81B7D587-A189-4785-BDFE-CA8A9ABA0760}.Release|Any CPU.Build.0 = Release|Any CPU
{F1CEA363-7039-40BA-9744-0071F46BB90C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F1CEA363-7039-40BA-9744-0071F46BB90C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F1CEA363-7039-40BA-9744-0071F46BB90C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F1CEA363-7039-40BA-9744-0071F46BB90C}.Release|Any CPU.Build.0 = Release|Any CPU
{817200C3-A327-4E35-9B5F-63A51C088577}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{817200C3-A327-4E35-9B5F-63A51C088577}.Debug|Any CPU.Build.0 = Debug|Any CPU
{817200C3-A327-4E35-9B5F-63A51C088577}.Debug|ARM.ActiveCfg = Debug|Any CPU
{817200C3-A327-4E35-9B5F-63A51C088577}.Debug|x86.ActiveCfg = Debug|Any CPU
{817200C3-A327-4E35-9B5F-63A51C088577}.Release|Any CPU.ActiveCfg = Release|Any CPU
{817200C3-A327-4E35-9B5F-63A51C088577}.Release|Any CPU.Build.0 = Release|Any CPU
{817200C3-A327-4E35-9B5F-63A51C088577}.Release|ARM.ActiveCfg = Release|Any CPU
{817200C3-A327-4E35-9B5F-63A51C088577}.Release|x86.ActiveCfg = Release|Any CPU
{775569C2-987F-4AC4-8BA5-A315A21ED1B7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{775569C2-987F-4AC4-8BA5-A315A21ED1B7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{775569C2-987F-4AC4-8BA5-A315A21ED1B7}.Debug|ARM.ActiveCfg = Debug|Any CPU
{775569C2-987F-4AC4-8BA5-A315A21ED1B7}.Debug|x86.ActiveCfg = Debug|Any CPU
{775569C2-987F-4AC4-8BA5-A315A21ED1B7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{775569C2-987F-4AC4-8BA5-A315A21ED1B7}.Release|Any CPU.Build.0 = Release|Any CPU
{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
{47721A56-2128-4C5A-8B92-995FFC353304}.Debug|ARM.ActiveCfg = Debug|ARM
{47721A56-2128-4C5A-8B92-995FFC353304}.Debug|ARM.Build.0 = Debug|ARM
{47721A56-2128-4C5A-8B92-995FFC353304}.Debug|ARM.Deploy.0 = Debug|ARM
{47721A56-2128-4C5A-8B92-995FFC353304}.Debug|x86.ActiveCfg = Debug|x86
{47721A56-2128-4C5A-8B92-995FFC353304}.Debug|x86.Build.0 = Debug|x86
{47721A56-2128-4C5A-8B92-995FFC353304}.Debug|x86.Deploy.0 = Debug|x86
{47721A56-2128-4C5A-8B92-995FFC353304}.Release|Any CPU.ActiveCfg = Release|Any CPU
{47721A56-2128-4C5A-8B92-995FFC353304}.Release|Any CPU.Build.0 = Release|Any CPU
{47721A56-2128-4C5A-8B92-995FFC353304}.Release|Any CPU.Deploy.0 = Release|Any CPU
{47721A56-2128-4C5A-8B92-995FFC353304}.Release|ARM.ActiveCfg = Release|ARM
{47721A56-2128-4C5A-8B92-995FFC353304}.Release|ARM.Build.0 = Release|ARM
{47721A56-2128-4C5A-8B92-995FFC353304}.Release|ARM.Deploy.0 = Release|ARM
{47721A56-2128-4C5A-8B92-995FFC353304}.Release|x86.ActiveCfg = Release|x86
{47721A56-2128-4C5A-8B92-995FFC353304}.Release|x86.Build.0 = Release|x86
{47721A56-2128-4C5A-8B92-995FFC353304}.Release|x86.Deploy.0 = Release|x86
{CA3C491B-A8CA-426C-A0BB-E91636767467}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CA3C491B-A8CA-426C-A0BB-E91636767467}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CA3C491B-A8CA-426C-A0BB-E91636767467}.Debug|ARM.ActiveCfg = Debug|Any CPU
{CA3C491B-A8CA-426C-A0BB-E91636767467}.Debug|x86.ActiveCfg = Debug|Any CPU
{CA3C491B-A8CA-426C-A0BB-E91636767467}.Release|Any CPU.ActiveCfg = Release|Any CPU
{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
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}
EndGlobalSection
EndGlobal
+8 -4
View File
@@ -1,5 +1,6 @@
using PocketSharp.Models;
using System;
using System.Threading.Tasks;
namespace PocketSharp
{
@@ -16,7 +17,7 @@ namespace PocketSharp
/// <param name="title">This can be included for cases where an item does not have a title, which is typical for image or PDF URLs. If Pocket detects a title from the content of the page, this parameter will be ignored.</param>
/// <param name="tweetID">If you are adding Pocket support to a Twitter client, please send along a reference to the tweet status id. This allows Pocket to show the original tweet alongside the article.</param>
/// <returns></returns>
public PocketItem Add(Uri uri, string[] tags = null, string title = null, string tweetID = null)
public async Task<PocketItem> Add(Uri uri, string[] tags = null, string title = null, string tweetID = null)
{
AddParameters parameters = new AddParameters()
{
@@ -25,7 +26,10 @@ namespace PocketSharp
Title = title,
TweetID = tweetID
};
return Get<Add>("add", parameters.Convert(), true).Item;
Add response = await Request<Add>("add", parameters.Convert());
return response.Item;
}
@@ -34,9 +38,9 @@ namespace PocketSharp
/// </summary>
/// <param name="uri">The URL of the item you want to save</param>
/// <returns></returns>
public PocketItem Add(Uri uri)
public async Task<PocketItem> Add(Uri uri)
{
return Add(uri, null, null, null);
return await Add(uri, null);
}
}
}
+15 -7
View File
@@ -1,5 +1,7 @@
using PocketSharp.Models;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace PocketSharp
{
@@ -12,16 +14,19 @@ namespace PocketSharp
/// Retrieves the requestCode from Pocket.
/// </summary>
/// <returns></returns>
public string GetRequestCode()
public async Task<string> GetRequestCode()
{
// check if request code is available
if (CallbackUri == null)
{
throw new APIException("Authentication methods need a callbackUri on initialization of the PocketClient class");
throw new PocketException("Authentication methods need a callbackUri on initialization of the PocketClient class");
}
// do request
RequestCode response = Get<RequestCode>("oauth/request", Utilities.CreateParamInList("redirect_uri", CallbackUri));
RequestCode response = await Request<RequestCode>("oauth/request", new Dictionary<string, string>()
{
{ "redirect_uri", CallbackUri }
}, false);
// save code to client
RequestCode = response.Code;
@@ -41,7 +46,7 @@ namespace PocketSharp
// check if request code is available
if(RequestCode == null && requestCode == null)
{
throw new APIException("Call GetRequestCode() first to receive a request_code");
throw new PocketException("Call GetRequestCode() first to receive a request_code");
}
// override property with given param if available
@@ -58,12 +63,12 @@ namespace PocketSharp
/// Requests the access code after authentification
/// </summary>
/// <returns></returns>
public string GetAccessCode(string requestCode = null)
public async Task<string> GetAccessCode(string requestCode = null)
{
// check if request code is available
if(RequestCode == null && requestCode == null)
{
throw new APIException("Call GetRequestCode() first to receive a request_code");
throw new PocketException("Call GetRequestCode() first to receive a request_code");
}
// override property with given param if available
@@ -73,7 +78,10 @@ namespace PocketSharp
}
// do request
AccessCode response = Get<AccessCode>("oauth/authorize", Utilities.CreateParamInList("code", RequestCode));
AccessCode response = await Request<AccessCode>("oauth/authorize", new Dictionary<string, string>()
{
{ "code", RequestCode }
}, false);
// save code to client
AccessCode = response.Code;
+24 -22
View File
@@ -1,4 +1,6 @@
using PocketSharp.Models;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace PocketSharp
{
@@ -12,9 +14,9 @@ namespace PocketSharp
/// </summary>
/// <param name="itemID">The item ID.</param>
/// <returns></returns>
public bool Archive(int itemID)
public async Task<bool> Archive(int itemID)
{
return PutSendActionDefault(itemID, "archive");
return await SendDefault(itemID, "archive");
}
@@ -23,9 +25,9 @@ namespace PocketSharp
/// </summary>
/// <param name="item">The item.</param>
/// <returns></returns>
public bool Archive(PocketItem item)
public async Task<bool> Archive(PocketItem item)
{
return Archive(item.ID);
return await Archive(item.ID);
}
@@ -34,9 +36,9 @@ namespace PocketSharp
/// </summary>
/// <param name="itemID">The item ID.</param>
/// <returns></returns>
public bool Unarchive(int itemID)
public async Task<bool> Unarchive(int itemID)
{
return PutSendActionDefault(itemID, "readd");
return await SendDefault(itemID, "readd");
}
@@ -45,9 +47,9 @@ namespace PocketSharp
/// </summary>
/// <param name="item">The item.</param>
/// <returns></returns>
public bool Unarchive(PocketItem item)
public async Task<bool> Unarchive(PocketItem item)
{
return Unarchive(item.ID);
return await Unarchive(item.ID);
}
@@ -56,9 +58,9 @@ namespace PocketSharp
/// </summary>
/// <param name="itemID">The item ID.</param>
/// <returns></returns>
public bool Favorite(int itemID)
public async Task<bool> Favorite(int itemID)
{
return PutSendActionDefault(itemID, "favorite");
return await SendDefault(itemID, "favorite");
}
@@ -67,9 +69,9 @@ namespace PocketSharp
/// </summary>
/// <param name="item">The item.</param>
/// <returns></returns>
public bool Favorite(PocketItem item)
public async Task<bool> Favorite(PocketItem item)
{
return Favorite(item.ID);
return await Favorite(item.ID);
}
@@ -78,9 +80,9 @@ namespace PocketSharp
/// </summary>
/// <param name="itemID">The item ID.</param>
/// <returns></returns>
public bool Unfavorite(int itemID)
public async Task<bool> Unfavorite(int itemID)
{
return PutSendActionDefault(itemID, "unfavorite");
return await SendDefault(itemID, "unfavorite");
}
@@ -89,9 +91,9 @@ namespace PocketSharp
/// </summary>
/// <param name="item">The item.</param>
/// <returns></returns>
public bool Unfavorite(PocketItem item)
public async Task<bool> Unfavorite(PocketItem item)
{
return Unfavorite(item.ID);
return await Unfavorite(item.ID);
}
@@ -100,9 +102,9 @@ namespace PocketSharp
/// </summary>
/// <param name="itemID">The item ID.</param>
/// <returns></returns>
public bool Delete(int itemID)
public async Task<bool> Delete(int itemID)
{
return PutSendActionDefault(itemID, "delete");
return await SendDefault(itemID, "delete");
}
@@ -111,9 +113,9 @@ namespace PocketSharp
/// </summary>
/// <param name="item">The item.</param>
/// <returns></returns>
public bool Delete(PocketItem item)
public async Task<bool> Delete(PocketItem item)
{
return Delete(item.ID);
return await Delete(item.ID);
}
@@ -123,9 +125,9 @@ namespace PocketSharp
/// <param name="itemID">The item ID.</param>
/// <param name="action">The action.</param>
/// <returns></returns>
protected bool PutSendActionDefault(int itemID, string action)
protected async Task<bool> SendDefault(int itemID, string action)
{
return PutSendAction(new ActionParameter()
return await Send(new ActionParameter()
{
Action = action,
ID = itemID
+23 -22
View File
@@ -1,4 +1,5 @@
using PocketSharp.Models;
using System.Threading.Tasks;
namespace PocketSharp
{
@@ -13,9 +14,9 @@ namespace PocketSharp
/// <param name="itemID">The item ID.</param>
/// <param name="tags">The tags.</param>
/// <returns></returns>
public bool AddTags(int itemID, string[] tags)
public async Task<bool> AddTags(int itemID, string[] tags)
{
return PutSendActionForTags(itemID, "tags_add", tags);
return await SendTags(itemID, "tags_add", tags);
}
@@ -25,9 +26,9 @@ namespace PocketSharp
/// <param name="item">The item.</param>
/// <param name="tags">The tags.</param>
/// <returns></returns>
public bool AddTags(PocketItem item, string[] tags)
public async Task<bool> AddTags(PocketItem item, string[] tags)
{
return AddTags(item.ID, tags);
return await AddTags(item.ID, tags);
}
@@ -37,9 +38,9 @@ namespace PocketSharp
/// <param name="itemID">The item ID.</param>
/// <param name="tags">The tags.</param>
/// <returns></returns>
public bool RemoveTags(int itemID, string[] tags)
public async Task<bool> RemoveTags(int itemID, string[] tags)
{
return PutSendActionForTags(itemID, "tags_remove", tags);
return await SendTags(itemID, "tags_remove", tags);
}
@@ -49,9 +50,9 @@ namespace PocketSharp
/// <param name="item">The item.</param>
/// <param name="tags">The tags.</param>
/// <returns></returns>
public bool RemoveTags(PocketItem item, string[] tags)
public async Task<bool> RemoveTags(PocketItem item, string[] tags)
{
return RemoveTags(item.ID, tags);
return await RemoveTags(item.ID, tags);
}
@@ -60,9 +61,9 @@ namespace PocketSharp
/// </summary>
/// <param name="itemID">The item ID.</param>
/// <returns></returns>
public bool RemoveTags(int itemID)
public async Task<bool> RemoveTags(int itemID)
{
return PutSendActionDefault(itemID, "tags_clear");
return await SendDefault(itemID, "tags_clear");
}
@@ -71,9 +72,9 @@ namespace PocketSharp
/// </summary>
/// <param name="item">The item.</param>
/// <returns></returns>
public bool RemoveTags(PocketItem item)
public async Task<bool> RemoveTags(PocketItem item)
{
return RemoveTags(item.ID);
return await RemoveTags(item.ID);
}
@@ -83,9 +84,9 @@ namespace PocketSharp
/// <param name="itemID">The item ID.</param>
/// <param name="tags">The tags.</param>
/// <returns></returns>
public bool ReplaceTags(int itemID, string[] tags)
public async Task<bool> ReplaceTags(int itemID, string[] tags)
{
return PutSendActionForTags(itemID, "tags_replace", tags);
return await SendTags(itemID, "tags_replace", tags);
}
@@ -95,9 +96,9 @@ namespace PocketSharp
/// <param name="item">The item.</param>
/// <param name="tags">The tags.</param>
/// <returns></returns>
public bool ReplaceTags(PocketItem item, string[] tags)
public async Task<bool> ReplaceTags(PocketItem item, string[] tags)
{
return ReplaceTags(item.ID, tags);
return await ReplaceTags(item.ID, tags);
}
@@ -108,9 +109,9 @@ namespace PocketSharp
/// <param name="oldTag">The old tag.</param>
/// <param name="newTag">The new tag name.</param>
/// <returns></returns>
public bool RenameTag(int itemID, string oldTag, string newTag)
public async Task<bool> RenameTag(int itemID, string oldTag, string newTag)
{
return PutSendAction(new ActionParameter()
return await Send(new ActionParameter()
{
Action = "tag_rename",
ID = itemID,
@@ -127,9 +128,9 @@ namespace PocketSharp
/// <param name="oldTag">The old tag.</param>
/// <param name="newTag">The new tag name.</param>
/// <returns></returns>
public bool RenameTag(PocketItem item, string oldTag, string newTag)
public async Task<bool> RenameTag(PocketItem item, string oldTag, string newTag)
{
return RenameTag(item.ID, oldTag, newTag);
return await RenameTag(item.ID, oldTag, newTag);
}
@@ -140,9 +141,9 @@ namespace PocketSharp
/// <param name="action">The action.</param>
/// <param name="tags">The tags.</param>
/// <returns></returns>
protected bool PutSendActionForTags(int itemID, string action, string[] tags)
protected async Task<bool> SendTags(int itemID, string action, string[] tags)
{
return PutSendAction(new ActionParameter()
return await Send(new ActionParameter()
{
Action = action,
ID = itemID,
+19 -8
View File
@@ -1,5 +1,6 @@
using PocketSharp.Models;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace PocketSharp
{
@@ -13,9 +14,11 @@ namespace PocketSharp
/// </summary>
/// <param name="parameters">parameters, which are mapped to the officials from http://getpocket.com/developer/docs/v3/retrieve </param>
/// <returns></returns>
public List<PocketItem> Retrieve(RetrieveParameters parameters)
internal async Task<List<PocketItem>> Retrieve(RetrieveParameters parameters)
{
return Get<Retrieve>("get", parameters.Convert(), true).Items;
Retrieve response = await Request<Retrieve>("get", parameters.Convert());
return response.Items;
}
@@ -24,7 +27,7 @@ namespace PocketSharp
/// </summary>
/// <param name="filter">The filter.</param>
/// <returns></returns>
public List<PocketItem> Retrieve(RetrieveFilter filter = RetrieveFilter.All)
public async Task<List<PocketItem>> Retrieve(RetrieveFilter filter = RetrieveFilter.All)
{
RetrieveParameters parameters = new RetrieveParameters();
@@ -52,7 +55,9 @@ namespace PocketSharp
parameters.DetailType = DetailType.complete;
return Get<Retrieve>("get", parameters.Convert(), true).Items;
Retrieve response = await Request<Retrieve>("get", parameters.Convert());
return response.Items;
}
@@ -61,14 +66,17 @@ namespace PocketSharp
/// </summary>
/// <param name="tag">The tag.</param>
/// <returns></returns>
public List<PocketItem> SearchByTag(string tag)
public async Task<List<PocketItem>> SearchByTag(string tag)
{
RetrieveParameters parameters = new RetrieveParameters()
{
Tag = tag,
DetailType = DetailType.complete
};
return Get<Retrieve>("get", parameters.Convert(), true).Items;
Retrieve response = await Request<Retrieve>("get", parameters.Convert());
return response.Items;
}
@@ -77,14 +85,17 @@ namespace PocketSharp
/// </summary>
/// <param name="searchString">The search string.</param>
/// <returns></returns>
public List<PocketItem> Search(string searchString)
public async Task<List<PocketItem>> Search(string searchString)
{
RetrieveParameters parameters = new RetrieveParameters()
{
Search = searchString,
DetailType = DetailType.complete
};
return Get<Retrieve>("get", parameters.Convert(), true).Items;
Retrieve response = await Request<Retrieve>("get", parameters.Convert());
return response.Items;
}
}
-90
View File
@@ -1,90 +0,0 @@
using RestSharp;
using RestSharp.Deserializers;
using ServiceStack.Text;
using System;
namespace PocketSharp
{
/// <summary>
/// Custom JSON Deserializer which implements ServiceStack.Text
/// </summary>
internal class JsonDeserializer : IDeserializer
{
public const string JsonContentType = "application/json";
/// <summary>
/// Deserializes the specified response.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="response">The response.</param>
/// <returns></returns>
public T Deserialize<T>(IRestResponse response)
{
return JsonSerializer.DeserializeFromString<T>(response.Content);
}
/// <summary>
/// Adds custom deserialization for specific types.
/// </summary>
public static void AddCustomDeserialization()
{
// generate correct Uri format
JsConfig<Uri>.DeSerializeFn = value =>
{
Uri result = null;
try
{
result = new Uri(value);
}
catch(ArgumentNullException e) {}
catch(UriFormatException e) {}
return result;
};
// create DateTime from UNIX timestamp input
JsConfig<DateTime?>.DeSerializeFn = value =>
{
if (value == "0") return null;
return new DateTime(1970, 1, 1, 0, 0, 0, 0).AddSeconds(Convert.ToDouble(value)).ToLocalTime();
};
}
/// <summary>
/// Gets or sets the date format.
/// </summary>
/// <value>
/// The date format.
/// </value>
public string DateFormat { get; set; }
/// <summary>
/// Gets or sets the namespace.
/// </summary>
/// <value>
/// The namespace.
/// </value>
public string Namespace { get; set; }
/// <summary>
/// Gets or sets the root element.
/// </summary>
/// <value>
/// The root element.
/// </value>
public string RootElement { get; set; }
/// <summary>
/// Gets the type of the content.
/// </summary>
/// <value>
/// The type of the content.
/// </value>
public string ContentType
{
get { return JsonContentType; }
}
}
}
+51
View File
@@ -0,0 +1,51 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace PocketSharp
{
public class BoolConverter : JsonConverter
{
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
writer.WriteValue(((bool)value) ? 1 : 0);
}
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
return reader.Value.ToString() == "1";
}
public override bool CanConvert(Type objectType)
{
return objectType == typeof(bool);
}
}
public class UnixDateTimeConverter : DateTimeConverterBase
{
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
DateTime epoc = new DateTime(1970, 1, 1);
var delta = (DateTime)value - epoc;
writer.WriteValue((long)delta.TotalSeconds);
}
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
if(reader.Value.ToString() == "0")
{
return null;
}
return new DateTime(1970, 1, 1, 0, 0, 0, 0).AddSeconds(Convert.ToDouble(reader.Value)).ToLocalTime();
}
}
}
@@ -1,12 +1,14 @@
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
namespace PocketSharp.Models
{
/// <summary>
/// All parameters which can be passed for a modify action
/// </summary>
public class ActionParameter
[DataContract]
internal class ActionParameter : Parameters
{
/// <summary>
/// Gets or sets the action.
@@ -14,6 +16,7 @@ namespace PocketSharp.Models
/// <value>
/// The action.
/// </value>
[DataMember(Name = "action")]
public string Action { get; set; }
/// <summary>
@@ -22,6 +25,7 @@ namespace PocketSharp.Models
/// <value>
/// The ID.
/// </value>
[DataMember(Name = "item_id")]
public int ID { get; set; }
/// <summary>
@@ -30,6 +34,7 @@ namespace PocketSharp.Models
/// <value>
/// The time.
/// </value>
[DataMember(Name = "time")]
public DateTime? Time { get; set; }
// specific params
@@ -40,6 +45,7 @@ namespace PocketSharp.Models
/// <value>
/// The tags.
/// </value>
[DataMember(Name = "tags")]
public string[] Tags { get; set; }
/// <summary>
@@ -48,6 +54,7 @@ namespace PocketSharp.Models
/// <value>
/// The old tag.
/// </value>
[DataMember(Name = "old_tag")]
public string OldTag { get; set; }
/// <summary>
@@ -56,31 +63,32 @@ namespace PocketSharp.Models
/// <value>
/// The new tag.
/// </value>
[DataMember(Name = "new_tag")]
public string NewTag { get; set; }
/// <summary>
/// Converts this instance to a parameter list.
/// </summary>
/// <returns></returns>
public object Convert()
{
Dictionary<string, object> parameters = new Dictionary<string, object>
{
{ "item_id", ID },
{ "action", Action }
};
///// <summary>
///// Converts this instance to a parameter list.
///// </summary>
///// <returns></returns>
//public Dictionary<string, object> Convert()
//{
// Dictionary<string, object> parameters = new Dictionary<string, object>
// {
// { "item_id", ID },
// { "action", Action }
// };
if (Time != null)
parameters.Add("time", Utilities.GetUnixTimestamp(Time));
if (Tags != null)
parameters.Add("tags", Tags);
if (OldTag != null)
parameters.Add("old_tag", OldTag);
if (NewTag != null)
parameters.Add("new_tag", NewTag);
// if (Time != null)
// parameters.Add("time", Utilities.GetUnixTimestamp(Time));
// if (Tags != null)
// parameters.Add("tags", Tags);
// if (OldTag != null)
// parameters.Add("old_tag", OldTag);
// if (NewTag != null)
// parameters.Add("new_tag", NewTag);
return parameters;
}
// return parameters;
//}
}
}
+10 -18
View File
@@ -1,13 +1,16 @@
using RestSharp;
using System;
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.Serialization;
using System.Linq;
namespace PocketSharp.Models
{
/// <summary>
/// All parameters which can be passed to add a new item
/// </summary>
public class AddParameters
[DataContract]
internal class AddParameters : Parameters
{
/// <summary>
/// Gets or sets the URI.
@@ -15,6 +18,7 @@ namespace PocketSharp.Models
/// <value>
/// The URI.
/// </value>
[DataMember(Name="url")]
public Uri Uri { get; set; }
/// <summary>
@@ -23,6 +27,7 @@ namespace PocketSharp.Models
/// <value>
/// The title.
/// </value>
[DataMember(Name="title")]
public string Title { get; set; }
/// <summary>
@@ -31,6 +36,7 @@ namespace PocketSharp.Models
/// <value>
/// The tags.
/// </value>
[DataMember(Name="tags")]
public string[] Tags { get; set; }
/// <summary>
@@ -39,21 +45,7 @@ namespace PocketSharp.Models
/// <value>
/// The tweet ID.
/// </value>
[DataMember(Name="tweet_id")]
public string TweetID { get; set; }
/// <summary>
/// Converts this instance to a parameter list.
/// </summary>
/// <returns></returns>
public List<Parameter> Convert()
{
return new List<Parameter>()
{
Utilities.CreateParam("url", Uri.ToString() ),
Utilities.CreateParam("title", Title),
Utilities.CreateParam("tags", String.Join(",", Tags)),
Utilities.CreateParam("tweet_id", TweetID)
};
}
}
}
@@ -1,13 +1,13 @@
using RestSharp;
using ServiceStack.Text;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Runtime.Serialization;
namespace PocketSharp.Models
{
/// <summary>
/// All parameters which can be passed to modify an item
/// </summary>
public class ModifyParameters
[DataContract]
internal class ModifyParameters : Parameters
{
/// <summary>
/// Gets or sets the actions.
@@ -15,23 +15,7 @@ namespace PocketSharp.Models
/// <value>
/// The actions.
/// </value>
public List<ActionParameter> Actions { get; set; }
/// <summary>
/// Converts this instance to a parameter list.
/// </summary>
/// <returns></returns>
public List<Parameter> Convert()
{
List<object> actions = new List<object>();
Actions.ForEach(action => actions.Add(action.Convert()));
return new List<Parameter>()
{
Utilities.CreateParam("actions", JsonSerializer.SerializeToString(actions))
};
}
[DataMember(Name = "actions")]
public List<Dictionary<string, string>> Actions { get; set; }
}
}
@@ -0,0 +1,54 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.Serialization;
using System.Linq;
using System.Collections;
using Newtonsoft.Json;
namespace PocketSharp.Models
{
/// <summary>
/// Parameter
/// </summary>
internal class Parameters
{
/// <summary>
/// Converts an object to a list of HTTP Post parameters.
/// </summary>
/// <returns></returns>
public Dictionary<string, string> Convert()
{
// store HTTP parameters here
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)));
// gather attributes of object
foreach (PropertyInfo propertyInfo in properties)
{
DataMemberAttribute attribute = (DataMemberAttribute)propertyInfo.GetCustomAttributes(typeof(DataMemberAttribute), false).FirstOrDefault();
string name = attribute.Name ?? propertyInfo.Name.ToLower();
object value = propertyInfo.GetValue(this, null);
if (value == null)
{
continue;
}
if (value is IEnumerable && value.GetType().GetElementType() == typeof(string))
{
value = string.Join(",", ((IEnumerable)value).Cast<object>().Select(x => x.ToString()).ToArray());
}
parameterDict.Add(name, value.ToString());
}
return parameterDict;
}
}
}
@@ -1,13 +1,15 @@
using RestSharp;
using System;
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.Serialization;
namespace PocketSharp.Models
{
/// <summary>
/// All parameters which can be passed for item retrieval
/// </summary>
public class RetrieveParameters
[DataContract]
internal class RetrieveParameters : Parameters
{
/// <summary>
/// Gets or sets the state.
@@ -15,6 +17,7 @@ namespace PocketSharp.Models
/// <value>
/// The state.
/// </value>
[DataMember(Name = "state")]
public State? State { get; set; }
/// <summary>
@@ -23,6 +26,7 @@ namespace PocketSharp.Models
/// <value>
/// The favorite.
/// </value>
[DataMember(Name = "favorite")]
public bool? Favorite { get; set; }
/// <summary>
@@ -31,6 +35,7 @@ namespace PocketSharp.Models
/// <value>
/// The tag.
/// </value>
[DataMember(Name = "tag")]
public string Tag { get; set; }
/// <summary>
@@ -39,6 +44,7 @@ namespace PocketSharp.Models
/// <value>
/// The type of the content.
/// </value>
[DataMember(Name = "contentType")]
public ContentType? ContentType { get; set; }
/// <summary>
@@ -47,6 +53,7 @@ namespace PocketSharp.Models
/// <value>
/// The sort.
/// </value>
[DataMember(Name = "sort")]
public Sort? Sort { get; set; }
/// <summary>
@@ -55,6 +62,7 @@ namespace PocketSharp.Models
/// <value>
/// The type of the detail.
/// </value>
[DataMember(Name="detailType")]
public DetailType? DetailType { get; set; }
/// <summary>
@@ -63,6 +71,7 @@ namespace PocketSharp.Models
/// <value>
/// The search.
/// </value>
[DataMember(Name = "search")]
public string Search { get; set; }
/// <summary>
@@ -71,6 +80,7 @@ namespace PocketSharp.Models
/// <value>
/// The domain.
/// </value>
[DataMember(Name = "domain")]
public string Domain { get; set; }
/// <summary>
@@ -79,6 +89,7 @@ namespace PocketSharp.Models
/// <value>
/// The since.
/// </value>
[DataMember(Name = "since")]
public DateTime? Since { get; set; }
/// <summary>
@@ -87,6 +98,7 @@ namespace PocketSharp.Models
/// <value>
/// The count.
/// </value>
[DataMember(Name = "count")]
public int? Count { get; set; }
/// <summary>
@@ -95,30 +107,8 @@ namespace PocketSharp.Models
/// <value>
/// The offset.
/// </value>
[DataMember(Name = "offset")]
public int? Offset { get; set; }
/// <summary>
/// Converts this instance to a parameter list.
/// </summary>
/// <returns></returns>
public List<Parameter> Convert()
{
return new List<Parameter>()
{
Utilities.CreateParam("state", State != null ? State.ToString() : null ),
Utilities.CreateParam("favorite", Favorite != null ? (bool)Favorite ? "1" : "0" : null),
Utilities.CreateParam("tag", Tag),
Utilities.CreateParam("contentType", ContentType != null ? ContentType.ToString() : null),
Utilities.CreateParam("sort", Sort != null ? Sort.ToString() : null),
Utilities.CreateParam("detailType", DetailType != null ? DetailType.ToString() : null),
Utilities.CreateParam("search", Search),
Utilities.CreateParam("domain", Domain),
Utilities.CreateParam("since", Utilities.GetUnixTimestamp(Since)),
Utilities.CreateParam("count", Count),
Utilities.CreateParam("offset", Offset)
};
}
}
+6 -5
View File
@@ -1,4 +1,5 @@
using System;
using Newtonsoft.Json;
using System;
using System.Runtime.Serialization;
namespace PocketSharp.Models
@@ -6,7 +7,7 @@ namespace PocketSharp.Models
/// <summary>
/// Author
/// </summary>
[DataContract]
[JsonObject]
public class PocketAuthor
{
/// <summary>
@@ -15,7 +16,7 @@ namespace PocketSharp.Models
/// <value>
/// The ID.
/// </value>
[DataMember(Name = "author_id")]
[JsonProperty("author_id")]
public string ID { get; set; }
/// <summary>
@@ -24,7 +25,7 @@ namespace PocketSharp.Models
/// <value>
/// The name.
/// </value>
[DataMember]
[JsonProperty]
public string Name { get; set; }
/// <summary>
@@ -33,7 +34,7 @@ namespace PocketSharp.Models
/// <value>
/// The URI.
/// </value>
[DataMember(Name = "url")]
[JsonProperty("url")]
public Uri Uri { get; set; }
}
}
+7 -6
View File
@@ -1,4 +1,5 @@
using System;
using Newtonsoft.Json;
using System;
using System.Runtime.Serialization;
namespace PocketSharp.Models
@@ -6,7 +7,7 @@ namespace PocketSharp.Models
/// <summary>
/// Image
/// </summary>
[DataContract]
[JsonObject]
public class PocketImage
{
/// <summary>
@@ -15,7 +16,7 @@ namespace PocketSharp.Models
/// <value>
/// The ID.
/// </value>
[DataMember(Name = "image_id")]
[JsonProperty("image_id")]
public string ID { get; set; }
/// <summary>
@@ -24,7 +25,7 @@ namespace PocketSharp.Models
/// <value>
/// The caption.
/// </value>
[DataMember]
[JsonProperty]
public string Caption { get; set; }
/// <summary>
@@ -33,7 +34,7 @@ namespace PocketSharp.Models
/// <value>
/// The credit.
/// </value>
[DataMember]
[JsonProperty]
public string Credit { get; set; }
/// <summary>
@@ -42,7 +43,7 @@ namespace PocketSharp.Models
/// <value>
/// The URI.
/// </value>
[DataMember(Name = "src")]
[JsonProperty("src")]
public Uri Uri { get; set; }
}
}
+62 -39
View File
@@ -1,4 +1,5 @@
using System;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
@@ -8,7 +9,7 @@ namespace PocketSharp.Models
/// Item containing all available data
/// see: http://getpocket.com/developer/docs/v3/retrieve
/// </summary>
[DataContract]
[JsonObject]
public class PocketItem
{
/// <summary>
@@ -17,7 +18,7 @@ namespace PocketSharp.Models
/// <value>
/// The ID.
/// </value>
[DataMember(Name = "item_id")]
[JsonProperty("item_id")]
public int ID { get; set; }
/// <summary>
@@ -26,7 +27,7 @@ namespace PocketSharp.Models
/// <value>
/// The URI.
/// </value>
[DataMember(Name = "resolved_url")]
[JsonProperty("resolved_url")]
public Uri Uri { get; set; }
/// <summary>
@@ -35,8 +36,30 @@ namespace PocketSharp.Models
/// <value>
/// The title.
/// </value>
[DataMember(Name = "resolved_title")]
public string Title { get; set; }
[JsonProperty("resolved_title")]
private string _ResolvedTitle { get; set; }
/// <summary>
/// Gets or sets the title.
/// </summary>
/// <value>
/// The title.
/// </value>
[JsonProperty("title")]
private string _InternalTitle { get; set; }
/// <summary>
/// Gets or sets the title.
/// </summary>
/// <value>
/// The title.
/// </value>
[JsonIgnore]
public string Title
{
get { return _InternalTitle ?? _ResolvedTitle; }
set { _InternalTitle = value; _ResolvedTitle = value; }
}
/// <summary>
/// Gets or sets the full title.
@@ -44,7 +67,7 @@ namespace PocketSharp.Models
/// <value>
/// The full title.
/// </value>
[DataMember(Name = "given_title")]
[JsonProperty("given_title")]
public string FullTitle { get; set; }
/// <summary>
@@ -53,7 +76,7 @@ namespace PocketSharp.Models
/// <value>
/// The excerpt.
/// </value>
[DataMember]
[JsonProperty]
public string Excerpt { get; set; }
/// <summary>
@@ -62,7 +85,7 @@ namespace PocketSharp.Models
/// <value>
/// The status.
/// </value>
[DataMember]
[JsonProperty]
public int Status { get; set; }
/// <summary>
@@ -71,7 +94,7 @@ namespace PocketSharp.Models
/// <value>
/// <c>true</c> if this instance is favorite; otherwise, <c>false</c>.
/// </value>
[DataMember(Name = "favorite")]
[JsonProperty("favorite")]
public bool IsFavorite { get; set; }
/// <summary>
@@ -80,7 +103,7 @@ namespace PocketSharp.Models
/// <value>
/// <c>true</c> if this instance is archive; otherwise, <c>false</c>.
/// </value>
[IgnoreDataMember]
[JsonIgnore]
public bool IsArchive { get { return Status == 1; } }
/// <summary>
@@ -89,7 +112,7 @@ namespace PocketSharp.Models
/// <value>
/// <c>true</c> if this instance is deleted; otherwise, <c>false</c>.
/// </value>
[IgnoreDataMember]
[JsonIgnore]
public bool IsDeleted { get { return Status == 2; } }
/// <summary>
@@ -98,7 +121,7 @@ namespace PocketSharp.Models
/// <value>
/// <c>true</c> if this instance is article; otherwise, <c>false</c>.
/// </value>
[DataMember(Name = "is_article")]
[JsonProperty("is_article")]
public bool IsArticle { get; set; }
/// <summary>
@@ -107,7 +130,7 @@ namespace PocketSharp.Models
/// <value>
/// <c>true</c> if this instance has image; otherwise, <c>false</c>.
/// </value>
[DataMember(Name = "has_image")]
[JsonProperty("has_image")]
public bool HasImage { get; set; }
/// <summary>
@@ -116,7 +139,7 @@ namespace PocketSharp.Models
/// <value>
/// <c>true</c> if this instance has video; otherwise, <c>false</c>.
/// </value>
[DataMember(Name = "has_video")]
[JsonProperty("has_video")]
public bool HasVideo { get; set; }
/// <summary>
@@ -125,7 +148,7 @@ namespace PocketSharp.Models
/// <value>
/// The word count.
/// </value>
[DataMember(Name = "word_count")]
[JsonProperty("word_count")]
public int WordCount { get; set; }
/// <summary>
@@ -134,7 +157,7 @@ namespace PocketSharp.Models
/// <value>
/// The sort.
/// </value>
[DataMember(Name = "sort_id")]
[JsonProperty("sort_id")]
public int Sort { get; set; }
@@ -144,7 +167,7 @@ namespace PocketSharp.Models
/// <value>
/// The add time.
/// </value>
[DataMember(Name = "time_added")]
[JsonProperty("time_added")]
public DateTime? AddTime { get; set; }
/// <summary>
@@ -153,7 +176,7 @@ namespace PocketSharp.Models
/// <value>
/// The update time.
/// </value>
[DataMember(Name = "time_updated")]
[JsonProperty("time_updated")]
public DateTime? UpdateTime { get; set; }
/// <summary>
@@ -162,7 +185,7 @@ namespace PocketSharp.Models
/// <value>
/// The read time.
/// </value>
[DataMember(Name = "time_read")]
[JsonProperty("time_read")]
public DateTime? ReadTime { get; set; }
/// <summary>
@@ -171,7 +194,7 @@ namespace PocketSharp.Models
/// <value>
/// The favorite time.
/// </value>
[DataMember(Name = "time_favorited")]
[JsonProperty("time_favorited")]
public DateTime? FavoriteTime { get; set; }
@@ -181,8 +204,8 @@ namespace PocketSharp.Models
/// <value>
/// The _ tag dictionary.
/// </value>
[DataMember(Name = "tags")]
public Dictionary<string, PocketTag> TagDictionary { get; set; }
[JsonProperty("tags")]
private Dictionary<string, PocketTag> _TagDictionary { get; set; }
/// <summary>
/// Gets or sets the _ image dictionary.
@@ -190,8 +213,8 @@ namespace PocketSharp.Models
/// <value>
/// The _ image dictionary.
/// </value>
[DataMember(Name = "images")]
public Dictionary<string, PocketImage> ImageDictionary { get; set; }
[JsonProperty("images")]
private Dictionary<string, PocketImage> _ImageDictionary { get; set; }
/// <summary>
/// Gets or sets the _ video dictionary.
@@ -199,8 +222,8 @@ namespace PocketSharp.Models
/// <value>
/// The _ video dictionary.
/// </value>
[DataMember(Name = "videos")]
public Dictionary<string, PocketVideo> VideoDictionary { get; set; }
[JsonProperty("videos")]
private Dictionary<string, PocketVideo> _VideoDictionary { get; set; }
/// <summary>
/// Gets or sets the _ author dictionary.
@@ -208,8 +231,8 @@ namespace PocketSharp.Models
/// <value>
/// The _ author dictionary.
/// </value>
[DataMember(Name = "authors")]
public Dictionary<string, PocketAuthor> AuthorDictionary { get; set; }
[JsonProperty("authors")]
private Dictionary<string, PocketAuthor> _AuthorDictionary { get; set; }
/// <summary>
@@ -218,10 +241,10 @@ namespace PocketSharp.Models
/// <value>
/// The tags.
/// </value>
[IgnoreDataMember]
[JsonIgnore]
public List<PocketTag> Tags
{
get { return Utilities.DictionaryToList<PocketTag>(TagDictionary); }
get { return Utilities.DictionaryToList<PocketTag>(_TagDictionary); }
}
/// <summary>
@@ -230,10 +253,10 @@ namespace PocketSharp.Models
/// <value>
/// The images.
/// </value>
[IgnoreDataMember]
[JsonIgnore]
public List<PocketImage> Images
{
get { return Utilities.DictionaryToList<PocketImage>(ImageDictionary); }
get { return Utilities.DictionaryToList<PocketImage>(_ImageDictionary); }
}
/// <summary>
@@ -242,10 +265,10 @@ namespace PocketSharp.Models
/// <value>
/// The lead image.
/// </value>
[IgnoreDataMember]
[JsonIgnore]
public PocketImage LeadImage
{
get { return Images != null ? Images[0] : null; }
get { return Images != null && Images.Count > 0 ? Images[0] : null; }
}
/// <summary>
@@ -254,10 +277,10 @@ namespace PocketSharp.Models
/// <value>
/// The videos.
/// </value>
[IgnoreDataMember]
[JsonIgnore]
public List<PocketVideo> Videos
{
get { return Utilities.DictionaryToList<PocketVideo>(VideoDictionary); }
get { return Utilities.DictionaryToList<PocketVideo>(_VideoDictionary); }
}
/// <summary>
@@ -266,10 +289,10 @@ namespace PocketSharp.Models
/// <value>
/// The authors.
/// </value>
[IgnoreDataMember]
[JsonIgnore]
public List<PocketAuthor> Authors
{
get { return Utilities.DictionaryToList<PocketAuthor>(AuthorDictionary); }
get { return Utilities.DictionaryToList<PocketAuthor>(_AuthorDictionary); }
}
}
}
+4 -3
View File
@@ -1,11 +1,12 @@
using System.Runtime.Serialization;
using Newtonsoft.Json;
using System.Runtime.Serialization;
namespace PocketSharp.Models
{
/// <summary>
/// Tag
/// </summary>
[DataContract]
[JsonObject]
public class PocketTag
{
/// <summary>
@@ -14,7 +15,7 @@ namespace PocketSharp.Models
/// <value>
/// The name.
/// </value>
[DataMember(Name = "tag")]
[JsonProperty("tag")]
public string Name { get; set; }
}
}
+6 -5
View File
@@ -1,4 +1,5 @@
using System;
using Newtonsoft.Json;
using System;
using System.Runtime.Serialization;
namespace PocketSharp.Models
@@ -6,7 +7,7 @@ namespace PocketSharp.Models
/// <summary>
/// Video
/// </summary>
[DataContract]
[JsonObject]
public class PocketVideo
{
/// <summary>
@@ -15,7 +16,7 @@ namespace PocketSharp.Models
/// <value>
/// The ID.
/// </value>
[DataMember(Name = "video_id")]
[JsonProperty("video_id")]
public string ID { get; set; }
/// <summary>
@@ -24,7 +25,7 @@ namespace PocketSharp.Models
/// <value>
/// The external ID.
/// </value>
[DataMember(Name = "vid")]
[JsonProperty("vid")]
public string ExternalID { get; set; }
/// <summary>
@@ -33,7 +34,7 @@ namespace PocketSharp.Models
/// <value>
/// The URI.
/// </value>
[DataMember(Name = "src")]
[JsonProperty("src")]
public Uri Uri { get; set; }
}
}
+5 -4
View File
@@ -1,11 +1,12 @@
using System.Runtime.Serialization;
using Newtonsoft.Json;
using System.Runtime.Serialization;
namespace PocketSharp.Models
{
/// <summary>
/// Access Code
/// </summary>
[DataContract]
[JsonObject]
internal class AccessCode
{
/// <summary>
@@ -14,7 +15,7 @@ namespace PocketSharp.Models
/// <value>
/// The code.
/// </value>
[DataMember(Name = "access_token")]
[JsonProperty("access_token")]
public string Code { get; set; }
/// <summary>
@@ -23,7 +24,7 @@ namespace PocketSharp.Models
/// <value>
/// The username.
/// </value>
[DataMember]
[JsonProperty]
public string Username { get; set; }
}
}
+4 -3
View File
@@ -1,11 +1,12 @@
using System.Runtime.Serialization;
using Newtonsoft.Json;
using System.Runtime.Serialization;
namespace PocketSharp.Models
{
/// <summary>
/// Add Response
/// </summary>
[DataContract]
[JsonObject]
internal class Add : ResponseBase
{
/// <summary>
@@ -14,7 +15,7 @@ namespace PocketSharp.Models
/// <value>
/// The item.
/// </value>
[DataMember]
[JsonProperty]
public PocketItem Item { get; set; }
}
}
+4 -3
View File
@@ -1,11 +1,12 @@
using System.Runtime.Serialization;
using Newtonsoft.Json;
using System.Runtime.Serialization;
namespace PocketSharp.Models
{
/// <summary>
/// Modify Response
/// </summary>
[DataContract]
[JsonObject]
internal class Modify : ResponseBase
{
/// <summary>
@@ -14,7 +15,7 @@ namespace PocketSharp.Models
/// <value>
/// The action results.
/// </value>
[DataMember(Name = "action_results")]
[JsonProperty("action_results")]
public bool[] ActionResults { get; set; }
}
}
+5 -4
View File
@@ -1,11 +1,12 @@
using System.Runtime.Serialization;
using Newtonsoft.Json;
using System.Runtime.Serialization;
namespace PocketSharp.Models
{
/// <summary>
/// Request Code
/// </summary>
[DataContract]
[JsonObject]
internal class RequestCode
{
/// <summary>
@@ -14,7 +15,7 @@ namespace PocketSharp.Models
/// <value>
/// The code.
/// </value>
[DataMember]
[JsonProperty]
public string Code { get; set; }
/// <summary>
@@ -23,7 +24,7 @@ namespace PocketSharp.Models
/// <value>
/// The state.
/// </value>
[DataMember]
[JsonProperty]
public string State { get; set; }
}
}
+4 -3
View File
@@ -1,11 +1,12 @@
using System.Runtime.Serialization;
using Newtonsoft.Json;
using System.Runtime.Serialization;
namespace PocketSharp.Models
{
/// <summary>
/// Base for Responses
/// </summary>
[DataContract]
[JsonObject]
internal class ResponseBase
{
/// <summary>
@@ -14,7 +15,7 @@ namespace PocketSharp.Models
/// <value>
/// <c>true</c> if status is OK; otherwise, <c>false</c>.
/// </value>
[DataMember(Name = "status")]
[JsonProperty("status")]
public bool Status { get; set; }
}
}
+7 -6
View File
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using Newtonsoft.Json;
using System.Collections.Generic;
using System.Runtime.Serialization;
namespace PocketSharp.Models
@@ -6,7 +7,7 @@ namespace PocketSharp.Models
/// <summary>
/// Item Response
/// </summary>
[DataContract]
[JsonObject]
internal class Retrieve : ResponseBase
{
/// <summary>
@@ -15,7 +16,7 @@ namespace PocketSharp.Models
/// <value>
/// The complete.
/// </value>
[DataMember(Name = "complete")]
[JsonProperty("complete")]
public int Complete { get; set; }
/// <summary>
@@ -24,7 +25,7 @@ namespace PocketSharp.Models
/// <value>
/// The since.
/// </value>
[DataMember]
[JsonProperty]
public int Since { get; set; }
/// <summary>
@@ -33,7 +34,7 @@ namespace PocketSharp.Models
/// <value>
/// The _ item dictionary.
/// </value>
[DataMember(Name = "list")]
[JsonProperty("list")]
public Dictionary<string, PocketItem> ItemDictionary { get; set; }
/// <summary>
@@ -42,7 +43,7 @@ namespace PocketSharp.Models
/// <value>
/// The items.
/// </value>
[IgnoreDataMember]
[JsonIgnore]
public List<PocketItem> Items
{
get { return Utilities.DictionaryToList<PocketItem>(ItemDictionary); }
+145 -108
View File
@@ -1,9 +1,14 @@
using PocketSharp.Models;
using RestSharp;
using RestSharp.Contrib;
using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Serialization;
using System.Diagnostics;
using System.Net.Http.Headers;
namespace PocketSharp
{
@@ -15,7 +20,7 @@ namespace PocketSharp
/// <summary>
/// REST client used for the API communication
/// </summary>
protected readonly RestClient _restClient;
protected readonly HttpClient _restClient;
/// <summary>
/// The base URL for the Pocket API
@@ -38,11 +43,6 @@ namespace PocketSharp
/// </summary>
public string ConsumerKey { get; set; }
/// <summary>
/// Returns all associated data from the last request
/// </summary>
public IRestResponse LastRequestData { get; private set; }
/// <summary>
/// Code retrieved on authentification
/// </summary>
@@ -74,58 +74,23 @@ namespace PocketSharp
// assign callback uri if submitted
if (callbackUri != null)
{
CallbackUri = HttpUtility.UrlEncode(callbackUri.ToString());
CallbackUri = Uri.EscapeUriString(callbackUri.ToString());
}
// initialize REST client
_restClient = new RestClient(baseUri.ToString());
_restClient = new HttpClient(new HttpClientHandler()
{
AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip
});
// add default parameters to each request
_restClient.AddDefaultParameter("consumer_key", ConsumerKey);
// set base uri
_restClient.BaseAddress = baseUri;
// Pocket needs this specific Accept header :-S
_restClient.AddDefaultHeader("Accept", "*/*");
_restClient.DefaultRequestHeaders.Add("Accept", "*/*");
// defines the response format (according to the Pocket docs)
_restClient.AddDefaultHeader("X-Accept", "application/json");
// custom JSON deserializer (ServiceStack.Text)
_restClient.AddHandler("application/json", new JsonDeserializer());
// add custom deserialization lambdas
JsonDeserializer.AddCustomDeserialization();
}
/// <summary>
/// Makes a HTTP REST request to the API
/// </summary>
/// <param name="request">The request.</param>
/// <returns></returns>
protected string Request(RestRequest request)
{
IRestResponse response = _restClient.Execute(request);
LastRequestData = response;
ValidateResponse(response);
return response.Content;
}
/// <summary>
/// Makes a typed HTTP REST request to the API
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="request">The request.</param>
/// <returns></returns>
protected T Request<T>(RestRequest request) where T : new()
{
IRestResponse<T> response = _restClient.Execute<T>(request);
LastRequestData = response;
ValidateResponse(response);
return response.Data;
_restClient.DefaultRequestHeaders.Add("X-Accept", "application/json");
}
@@ -137,50 +102,95 @@ namespace PocketSharp
/// <param name="parameters">Additional POST parameters</param>
/// <param name="requireAuth">if set to <c>true</c> [require auth].</param>
/// <returns></returns>
/// <exception cref="APIException">No access token available. Use authentification first.</exception>
protected T Get<T>(string method, List<Parameter> parameters = null, bool requireAuth = false) where T : class, new()
/// <exception cref="PocketException">No access token available. Use authentification first.</exception>
protected async Task<T> Request<T>(string method, Dictionary<string, string> parameters = null, bool requireAuth = true) where T : class, new()
{
if (requireAuth && AccessCode == null)
{
throw new APIException("No access token available. Use authentification first.");
throw new PocketException("SDK error: No access token available. Use authentification first.");
}
// every single Pocket API endpoint requires HTTP POST data
var request = new RestRequest(method, Method.POST);
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, method);
// add consumer key to each request
parameters.Add("consumer_key", ConsumerKey);
// add access token (necessary for all requests except authentification)
if (AccessCode != null)
{
request.AddParameter("access_token", AccessCode);
parameters.Add("access_token", AccessCode);
}
// enumeration for params
if (parameters != null)
{
parameters.ForEach(delegate(Parameter param)
// content of the request
request.Content = new FormUrlEncodedContent(parameters);
// make async request
HttpResponseMessage response = await _restClient.SendAsync(request);
// validate HTTP response
ValidateResponse(response);
// read response
var responseString = await response.Content.ReadAsStringAsync();
responseString = responseString.Replace("[]", "{}");
// deserialize object
T parsedResponse = JsonConvert.DeserializeObject<T>(
responseString,
new JsonSerializerSettings
{
request.AddParameter(param);
});
}
Error = (object sender, ErrorEventArgs args) =>
{
throw new PocketException(String.Format("Parse error: {0}", args.ErrorContext.Error.Message));
args.ErrorContext.Handled = true;
},
Converters =
{
new BoolConverter(),
new UnixDateTimeConverter()
}
}
);
// do the request
return Request<T>(request);
return parsedResponse;
}
/// <summary>
/// Puts an action
/// Sends a list of actions
/// </summary>
/// <param name="actionParameters">The action parameters.</param>
/// <returns></returns>
internal async Task<bool> Send(List<ActionParameter> actionParameters)
{
List<Dictionary<string, string>> actionParamList = new List<Dictionary<string, string>>();
foreach (var action in actionParameters)
{
actionParamList.Add(action.Convert());
}
Dictionary<string, string> parameters = new Dictionary<string, string>() {{
"actions", JsonConvert.SerializeObject(actionParamList)
}};
Modify response = await Request<Modify>("send", parameters);
return response.Status;
}
/// <summary>
/// Sends an action
/// </summary>
/// <param name="actionParameter">The action parameter.</param>
/// <returns></returns>
protected bool PutSendAction(ActionParameter actionParameter)
internal async Task<bool> Send(ActionParameter actionParameter)
{
ModifyParameters parameters = new ModifyParameters()
{
Actions = new List<ActionParameter>() { actionParameter }
};
return Get<Modify>("send", parameters.Convert(), true).Status;
bool response = await Send(new List<ActionParameter>() { actionParameter });
return response;
}
@@ -189,47 +199,74 @@ namespace PocketSharp
/// </summary>
/// <param name="response">The response.</param>
/// <returns></returns>
/// <exception cref="APIException">
/// <exception cref="PocketException">
/// Error retrieving response
/// </exception>
protected void ValidateResponse(IRestResponse response)
protected void ValidateResponse(HttpResponseMessage response)
{
if (response.StatusCode != HttpStatusCode.OK)
// no error found
if (response.StatusCode == HttpStatusCode.OK)
{
// get pocket error headers
Parameter error = response.Headers[1];
Parameter errorCode = response.Headers[2];
string exceptionString = response.Content;
bool isPocketError = error.Name == "X-Error";
// update message to include pocket response data
if (isPocketError)
{
exceptionString = exceptionString + "\nPocketResponse: (" + errorCode.Value + ") " + error.Value;
}
// create exception
APIException exception = new APIException(exceptionString, response.ErrorException);
if (isPocketError)
{
// add custom pocket fields
exception.PocketError = error.Value.ToString();
exception.PocketErrorCode = Convert.ToInt32(errorCode.Value);
// add to generic exception data
exception.Data.Add(error.Name, error.Value);
exception.Data.Add(errorCode.Name, errorCode.Value);
}
throw exception;
return;
}
else if (response.ErrorException != null)
string exceptionString = response.ReasonPhrase;
bool isPocketError = response.Headers.Contains("X-Error");
// fetch custom pocket headers
string error = TryGetHeaderValue(response.Headers, "X-Error");
int errorCode = Convert.ToInt32(TryGetHeaderValue(response.Headers, "X-Error-Code"));
// create exception strings
if (isPocketError)
{
throw new APIException("Error retrieving response", response.ErrorException);
exceptionString = String.Format("Pocket error: {0} ({1}) ", error, errorCode);
}
else
{
exceptionString = String.Format("Request error: {0} ({1})", response.ReasonPhrase, (int)response.StatusCode);
}
// create exception
PocketException exception = new PocketException(exceptionString);
if (isPocketError)
{
// add custom pocket fields
exception.PocketError = error;
exception.PocketErrorCode = errorCode;
// add to generic exception data
exception.Data.Add("X-Error", error);
exception.Data.Add("X-Error-Code", errorCode);
}
throw exception;
}
/// <summary>
/// Tries to fetch a header value.
/// </summary>
/// <param name="headers">The headers.</param>
/// <param name="key">The key.</param>
/// <returns></returns>
protected string TryGetHeaderValue(HttpResponseHeaders headers, string key)
{
string result = null;
foreach (var header in headers)
{
if (header.Key == key)
{
var headerEnumerator = header.Value.GetEnumerator();
headerEnumerator.MoveNext();
result = headerEnumerator.Current;
}
}
return result;
}
}
}
@@ -6,7 +6,7 @@ namespace PocketSharp
/// <summary>
/// custom Pocket API Exceptions
/// </summary>
public class APIException : Exception
public class PocketException : Exception
{
/// <summary>
/// Gets or sets the pocket error code.
@@ -26,35 +26,26 @@ namespace PocketSharp
/// <summary>
/// Initializes a new instance of the <see cref="APIException"/> class.
/// Initializes a new instance of the <see cref="PocketException"/> class.
/// </summary>
public APIException()
public PocketException()
: base() { }
/// <summary>
/// Initializes a new instance of the <see cref="APIException"/> class.
/// Initializes a new instance of the <see cref="PocketException"/> class.
/// </summary>
/// <param name="message">The message that describes the error.</param>
public APIException(string message)
public PocketException(string message)
: base(message) { }
/// <summary>
/// Initializes a new instance of the <see cref="APIException"/> class.
/// Initializes a new instance of the <see cref="PocketException"/> class.
/// </summary>
/// <param name="message">The error message that explains the reason for the exception.</param>
/// <param name="innerException">The exception that is the cause of the current exception, or a null reference (Nothing in Visual Basic) if no inner exception is specified.</param>
public APIException(string message, Exception innerException)
public PocketException(string message, Exception innerException)
: base(message, innerException) { }
/// <summary>
/// Initializes a new instance of the <see cref="APIException"/> class.
/// </summary>
/// <param name="info">The <see cref="T:System.Runtime.Serialization.SerializationInfo" /> that holds the serialized object data about the exception being thrown.</param>
/// <param name="context">The <see cref="T:System.Runtime.Serialization.StreamingContext" /> that contains contextual information about the source or destination.</param>
protected APIException(SerializationInfo info, StreamingContext context)
: base(info, context) { }
}
}
+56 -32
View File
@@ -2,15 +2,18 @@
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<MinimumVisualStudioVersion>10.0</MinimumVisualStudioVersion>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{1A291041-ADD8-467C-A6E4-0ACA26328CDF}</ProjectGuid>
<ProjectGuid>{817200C3-A327-4E35-9B5F-63A51C088577}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>PocketSharp</RootNamespace>
<AssemblyName>PocketSharp</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Profile96</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<RestorePackages>true</RestorePackages>
</PropertyGroup>
@@ -22,7 +25,6 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Debug\PocketSharp.XML</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
@@ -33,43 +35,31 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="RestSharp">
<HintPath>..\packages\RestSharp.104.1\lib\net4\RestSharp.dll</HintPath>
</Reference>
<Reference Include="ServiceStack.Text, Version=3.9.58.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\ServiceStack.Text.3.9.58\lib\net35\ServiceStack.Text.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<!-- A reference to the entire .NET Framework is automatically included -->
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Compile Include="APIException.cs" />
<Compile Include="PocketException.cs" />
<Compile Include="Components\Add.cs" />
<Compile Include="Components\Authentification.cs" />
<Compile Include="Components\Modify.cs" />
<Compile Include="Components\ModifyTags.cs" />
<Compile Include="Components\Retrieve.cs" />
<Compile Include="JsonDeserializer.cs" />
<Compile Include="Models\Response\AccessCode.cs" />
<Compile Include="Models\Response\RequestCode.cs" />
<Compile Include="JsonExtensions.cs" />
<Compile Include="Models\Parameters\ActionParameter.cs" />
<Compile Include="Models\Parameters\AddParameters.cs" />
<Compile Include="Models\Parameters\ModifyParameters.cs" />
<Compile Include="Models\Parameters\Parameters.cs" />
<Compile Include="Models\Parameters\RetrieveParameters.cs" />
<Compile Include="Models\PocketAuthor.cs" />
<Compile Include="Models\PocketImage.cs" />
<Compile Include="Models\PocketVideo.cs" />
<Compile Include="Models\Response\Add.cs" />
<Compile Include="Models\Response\Modify.cs" />
<Compile Include="Models\Parameters\ActionParameter.cs" />
<Compile Include="Models\Parameters\ModifyParameters.cs" />
<Compile Include="Models\Parameters\RetrieveParameters.cs" />
<Compile Include="Models\PocketItem.cs" />
<Compile Include="Models\PocketTag.cs" />
<Compile Include="Models\PocketVideo.cs" />
<Compile Include="Models\Response\AccessCode.cs" />
<Compile Include="Models\Response\Add.cs" />
<Compile Include="Models\Response\Modify.cs" />
<Compile Include="Models\Response\RequestCode.cs" />
<Compile Include="Models\Response\ResponseBase.cs" />
<Compile Include="Models\Response\Retrieve.cs" />
<Compile Include="PocketClient.cs" />
@@ -77,13 +67,47 @@
<Compile Include="Utilities.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="authentication-screen.png" />
<Reference Include="Microsoft.Threading.Tasks">
<HintPath>..\packages\Microsoft.Bcl.Async.1.0.16\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.16\lib\portable-net40+sl4+win8+wp71\Microsoft.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>..\packages\Newtonsoft.Json.5.0.6\lib\portable-net40+sl4+wp7+win8\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System.IO">
<HintPath>..\packages\Microsoft.Bcl.1.1.3\lib\portable-net40+sl4+win8+wp71\System.IO.dll</HintPath>
</Reference>
<Reference Include="System.Net.Http">
<HintPath>..\packages\Microsoft.Net.Http.2.2.13\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.13\lib\portable-net40+sl4+win8+wp71\System.Net.Http.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.Net.Http.Primitives">
<HintPath>..\packages\Microsoft.Net.Http.2.2.13\lib\portable-net40+sl4+win8+wp71\System.Net.Http.Primitives.dll</HintPath>
</Reference>
<Reference Include="System.Runtime">
<HintPath>..\packages\Microsoft.Bcl.1.1.3\lib\portable-net40+sl4+win8+wp71\System.Runtime.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Tasks">
<HintPath>..\packages\Microsoft.Bcl.1.1.3\lib\portable-net40+sl4+win8+wp71\System.Threading.Tasks.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
</Target>
<Import Project="..\packages\Microsoft.Bcl.Build.1.0.10\tools\Microsoft.Bcl.Build.targets" Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.10\tools\Microsoft.Bcl.Build.targets')" />
<Target Name="EnsureBclBuildImported" BeforeTargets="BeforeBuild" Condition="'$(BclBuildImported)' == ''">
<Error Condition="!Exists('..\packages\Microsoft.Bcl.Build.1.0.10\tools\Microsoft.Bcl.Build.targets')" Text="This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=317567." HelpKeyword="BCLBUILD2001" />
<Error Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.10\tools\Microsoft.Bcl.Build.targets')" Text="The build restored NuGet packages. Build the project again to include these packages in the build. For more information, see http://go.microsoft.com/fwlink/?LinkID=317568." HelpKeyword="BCLBUILD2002" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
+23
View File
@@ -0,0 +1,23 @@
<?xml version="1.0"?>
<package >
<metadata>
<id>$id$</id>
<version>$version$</version>
<title>$title$</title>
<authors>$author$</authors>
<owners>$author$</owners>
<licenseUrl>https://raw.github.com/ceee/PocketSharp/master/LICENSE-MIT</licenseUrl>
<projectUrl>http://pocketsharp.frontendplay.com</projectUrl>
<iconUrl>http://pocketsharp.frontendplay.com/Assets/Images/pocketsharp.png</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>$description$</description>
<language>en-US</language>
<releaseNotes>
<![CDATA[
For full release notes see https://github.com/ceee/PocketSharp#release-history
]]>
</releaseNotes>
<copyright>Copyright by cee, 2013</copyright>
<tags>PocketAPI Pocket API PocketSharp Tobias Klika cee RestSharp</tags>
</metadata>
</package>
+9 -16
View File
@@ -1,36 +1,29 @@
using System.Reflection;
using System.Resources;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// 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")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyDescription("PocketSharp is a .NET class library, that integrates the Pocket API v3")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyCompany("cee")]
[assembly: AssemblyProduct("PocketSharp")]
[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("fe3e33ad-074a-44fa-99a5-a8bf13837301")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// 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("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.0.0")]
[assembly: AssemblyFileVersion("1.0.0")]
+3 -29
View File
@@ -1,7 +1,7 @@
using RestSharp;
using System;
using System;
using System.Collections.Generic;
using PocketSharp.Models;
namespace PocketSharp
{
/// <summary>
@@ -25,32 +25,6 @@ namespace PocketSharp
}
/// <summary>
/// Creates a Parameter object.
/// </summary>
/// <param name="name">The name.</param>
/// <param name="value">The value.</param>
/// <param name="type">The type.</param>
/// <returns></returns>
public static Parameter CreateParam(string name, object value, ParameterType type = ParameterType.GetOrPost)
{
return new Parameter() { Name = name, Value = value, Type = type };
}
/// <summary>
/// Creates a Parameter object within a list.
/// </summary>
/// <param name="name">The name.</param>
/// <param name="value">The value.</param>
/// <param name="type">The type.</param>
/// <returns></returns>
public static List<Parameter> CreateParamInList(string name, object value, ParameterType type = ParameterType.GetOrPost)
{
return new List<Parameter>() { CreateParam(name, value, type) };
}
/// <summary>
/// Convert a dictionary to a list
/// </summary>
+5 -2
View File
@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="RestSharp" version="104.1" targetFramework="net40" />
<package id="ServiceStack.Text" version="3.9.58" targetFramework="net40" />
<package id="Microsoft.Bcl" version="1.1.3" targetFramework="portable-net45+sl40+wp71+win" />
<package id="Microsoft.Bcl.Async" version="1.0.16" targetFramework="portable-net45+sl40+wp71+win" />
<package id="Microsoft.Bcl.Build" version="1.0.10" targetFramework="portable-net45+sl40+wp71+win" />
<package id="Microsoft.Net.Http" version="2.2.13" targetFramework="portable-net45+sl40+wp71+win" />
<package id="Newtonsoft.Json" version="5.0.6" targetFramework="portable-net403+sl40+wp71+win" />
</packages>
+48 -32
View File
@@ -1,11 +1,6 @@
# PocketSharp
![PocketSharp](https://raw.github.com/ceee/PocketSharp/master/PocketSharp.Website/Assets/Images/github-header.png)
**PocketSharp** is a C#.NET class library, that integrates the [Pocket API v3](http://getpocket.com/developer) and consists of 4 parts:
- Authentication
- Retrieve
- Modify
- Add
**PocketSharp** is a C#.NET class library, that integrates the [Pocket API v3](http://getpocket.com/developer) and consists of 4 parts: [Authentication](#authentication), [Retrieve](#retrieve), [Modify](#modify) and [Add](#add).
[pocketsharp.frontendplay.com](http://pocketsharp.frontendplay.com/)
@@ -15,6 +10,23 @@
Install-Package PocketSharp
```
## Supported platforms
PocketSharp is a **Portable Class Library** (since 1.0.0), therefore it's compatible with multiple platforms:
- **.NET** >= 4.0.3 (including WPF)
- **Silverlight** >= 4
- **Windows Phone** >= 7.5
- **Windows Store**
You can find examples for Silverlight 5, WP8 and WPF in the `PocketSharp.Examples` folder.
## Async Support
All public methods, which communicate with the Pocket servers are asynchronous. So they should be called with the preceding `await` keyword, and the encapsulated method marked with `async`.
_In PocketSharp versions < 1.0.0 all methods lacked async support and were blocking._
## Usage Example
Request a [Consumer Key on Pocket.](http://getpocket.com/developer/apps/)
@@ -35,8 +47,9 @@ PocketClient _client = new PocketClient("[YOUR_CONSUMER_KEY]", "[YOUR_ACCESS_COD
Do a simple request - e.g. a search for `CSS`:
```csharp
_client.Search("css").ForEach(
item => Console.WriteLine(item.ID + " | " + item.Title)
var items = await _client.Search("css");
items.ForEach(
item => Debug.WriteLine(item.ID + " | " + item.Title)
);
```
@@ -93,7 +106,7 @@ The authentication is a 3-step process:
Receive the **request code** and **authentication URI** from the library by calling `string GetRequestCode()`:
```csharp
string requestCode = _client.GetRequestCode();
string requestCode = await _client.GetRequestCode();
// 0f453f2d-1605-8584-28fd-39af8e
Uri authenticationUri = _client.GenerateAuthenticationUri();
// https://getpocket.com/auth/authorize?request_token=0f453f2d-1605-8584-28fd-39af8e&redirect_uri=http%253a%252f%252fceecore.com
@@ -107,10 +120,10 @@ Next you need to redirect the user to the `authenticationUri`, which displays a
![authentication screen](https://raw.github.com/ceee/PocketSharp/master/PocketSharp/authentication-screen.png)
#### 3) Get Access Code
Call `string GetAccessCode(string requestCode = null)`
Call `Task<string> GetAccessCode(string requestCode = null)`
```csharp
string accessCode = _client.GetAccessCode();
string accessCode = await _client.GetAccessCode();
// fa8bfc16-69b3-4d22-7db7-84a58d
```
@@ -128,26 +141,26 @@ Without it you would always have to redo the authentication process.
Get list of all items:
```csharp
List<PocketItem> items = _client.Retrieve();
// equivalent to: _client.Retrieve(RetrieveFilter.All)
List<PocketItem> items = await _client.Retrieve();
// equivalent to: await _client.Retrieve(RetrieveFilter.All)
```
Find items by a tag:
```csharp
List<PocketItem> items = _client.SearchByTag("tutorial");
List<PocketItem> items = await _client.SearchByTag("tutorial");
```
Find items by a search string:
```csharp
List<PocketItem> items = _client.Search("css");
List<PocketItem> items = await _client.Search("css");
```
Find items by a filter:
```csharp
List<PocketItem> items = _client.Retrieve(RetrieveFilter.Favorite); // only favorites
List<PocketItem> items = await _client.Retrieve(RetrieveFilter.Favorite); // only favorites
```
The RetrieveFilter Enum is specified as follows:
@@ -169,7 +182,7 @@ var parameters = new RetrieveParameters()
...
};
List<PocketItem> items = _client.Retrieve(parameters);
List<PocketItem> items = await _client.Retrieve(parameters);
```
## Add
@@ -178,13 +191,13 @@ Adds a new item to your pocket list.
Accepts four parameters, with `uri` being required.
```csharp
PocketItem Add(Uri uri, string[] tags = null, string title = null, string tweetID = null)
Task<PocketItem> Add(Uri uri, string[] tags = null, string title = null, string tweetID = null)
```
Example:
```csharp
PocketItem newItem = _client.Add(
PocketItem newItem = await _client.Add(
new Uri("http://www.neowin.net/news/full-build-2013-conference-sessions-listing-revealed"),
new string[] { "microsoft", "neowin", "build" }
);
@@ -200,50 +213,52 @@ All Modify methods accept either the itemID (as int) or a `PocketItem` as parame
Archive the specified item:
bool isSuccess = _client.Archive(myPocketItem);
bool isSuccess = await _client.Archive(myPocketItem);
Un-archive the specified item:
bool isSuccess = _client.Unarchive(myPocketItem);
bool isSuccess = await _client.Unarchive(myPocketItem);
Favorites the specified item:
bool isSuccess = _client.Favorite(myPocketItem);
bool isSuccess = await _client.Favorite(myPocketItem);
Un-favorites the specified item:
bool isSuccess = _client.Unfavorite(myPocketItem);
bool isSuccess = await _client.Unfavorite(myPocketItem);
Deletes the specified item:
bool isSuccess = _client.Delete(myPocketItem);
bool isSuccess = await _client.Delete(myPocketItem);
#### Modify tags
Add tags to the specified item:
bool isSuccess = _client.AddTags(myPocketItem, new string[] { "css", "2013" });
bool isSuccess = await _client.AddTags(myPocketItem, new string[] { "css", "2013" });
Remove tags from the specified item:
bool isSuccess = _client.RemoveTags(myPocketItem, new string[] { "css", "2013" });
bool isSuccess = await _client.RemoveTags(myPocketItem, new string[] { "css", "2013" });
Remove all tags from the specified item:
bool isSuccess = _client.RemoveTags(myPocketItem);
bool isSuccess = await _client.RemoveTags(myPocketItem);
Replaces all existing tags with new ones for the specified item:
bool isSuccess = _client.ReplaceTags(myPocketItem, new string[] { "css", "2013" });
bool isSuccess = await _client.ReplaceTags(myPocketItem, new string[] { "css", "2013" });
Renames a tag for the specified item:
bool isSuccess = _client.RenameTag(myPocketItem, "oldTagName", "newTagName");
bool isSuccess = await _client.RenameTag(myPocketItem, "oldTagName", "newTagName");
---
## Release History
- 2013-09-15 v1.0.0 convert to PCL & implement async
- 2013-08-16 v0.3.2 tag modification fixed and full retrieval of items for Retrieve method
- 2013-07-07 v0.3.1 authentication fixes
- 2013-07-02 v0.3.0 update authentication process
- 2013-06-27 v0.2.0 add, modify item & modify tags
@@ -251,8 +266,9 @@ Renames a tag for the specified item:
## Dependencies
- [RestSharp](http://restsharp.org/)
- [ServiceStack.Text](https://github.com/ServiceStack/ServiceStack.Text)
- [Microsoft.Bcl.Async](https://www.nuget.org/packages/Microsoft.Bcl.Async/)
- [Microsoft.Net.Http](https://www.nuget.org/packages/Microsoft.Net.Http/)
- [Newtonsoft.Json](https://www.nuget.org/packages/Newtonsoft.Json/)
## Contributors
| [![twitter/artistandsocial](http://gravatar.com/avatar/9c61b1f4307425f12f05d3adb930ba66?s=70)](http://twitter.com/artistandsocial "Follow @artistandsocial on Twitter") |