diff options
24 files changed, 501 insertions, 43 deletions
diff --git a/.nuspec/Xamarin.Forms.Pages.Azure.nuspec b/.nuspec/Xamarin.Forms.Pages.Azure.nuspec new file mode 100644 index 00000000..7a4532c9 --- /dev/null +++ b/.nuspec/Xamarin.Forms.Pages.Azure.nuspec @@ -0,0 +1,71 @@ +<?xml version="1.0"?> +<package > + <metadata> + <id>Xamarin.Forms.Pages.Azure</id> + <version>$version$</version> + <authors>Xamarin, Inc.</authors> + <owners>Xamarin, Inc.</owners> + <licenseUrl>http://download.xamarin.com/content/licenses/Xamarin.Forms.rtf</licenseUrl> + <iconUrl>http://xamarin.com/content/images/nuget/xamarin.png</iconUrl> + <projectUrl>http://xamarin.com/forms</projectUrl> + <requireLicenseAcceptance>false</requireLicenseAcceptance> + <description>Pre-built themeable pages for Xamarin.Forms</description> + <copyright>Copyright 2013-2016</copyright> + <dependencies> + <group> + <dependency id="Xamarin.Forms.Pages" version="$version$"/> + <dependency id="Newtonsoft.Json" version="6.0.4"/> + <dependency id="modernhttpclient" version="2.4.2"/> + <dependency id="Microsoft.Net.Http" version="2.2.29" /> + <dependency id="Microsoft.Azure.Mobile.Client" version="2.0.1" /> + </group> + </dependencies> + <references> + <group targetFramework="portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10"> + <reference file="Xamarin.Forms.Pages.Azure.dll" /> + </group> + <group targetFramework="Xamarin.iOS10"> + <reference file="Xamarin.Forms.Pages.Azure.dll" /> + </group> + <group targetFramework="MonoTouch10"> + <reference file="Xamarin.Forms.Pages.Azure.dll" /> + </group> + <group targetFramework="MonoAndroid10"> + <reference file="Xamarin.Forms.Pages.Azure.dll" /> + </group> + <group targetFramework="win81"> + <reference file="Xamarin.Forms.Pages.Azure.dll" /> + </group> + <group targetFramework="wpa81"> + <reference file="Xamarin.Forms.Pages.Azure.dll" /> + </group> + <group targetFramework="uap10.0"> + <reference file="Xamarin.Forms.Pages.Azure.dll" /> + </group> + <group targetFramework="WP80"> + <reference file="Xamarin.Forms.Pages.Azure.dll" /> + </group> + </references> + </metadata> + <files> + <file src="..\Xamarin.Forms.Pages.Azure\bin\$Configuration$\Xamarin.Forms.Pages.Azure.dll" target="lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10" /> + + <file src="..\Xamarin.Forms.Pages.Azure\bin\$Configuration$\Xamarin.Forms.Pages.Azure.dll" target="lib\MonoAndroid10" /> + + <file src="..\Xamarin.Forms.Pages.Azure\bin\$Configuration$\Xamarin.Forms.Pages.Azure.dll" target="lib\Xamarin.iOS10" /> + + <file src="..\Xamarin.Forms.Pages.Azure\bin\$Configuration$\Xamarin.Forms.Pages.Azure.dll" target="lib\MonoTouch10" /> + + <file src="..\Xamarin.Forms.Pages.Azure\bin\$Configuration$\Xamarin.Forms.Pages.Azure.dll" target="lib\WP80" /> + + <!--UWP--> + <file src="..\Xamarin.Forms.Pages.Azure\bin\$Configuration$\Xamarin.Forms.Pages.Azure.dll" target="lib\uap10.0" /> + + <!--WinRT Phone--> + <file src="..\Xamarin.Forms.Pages.Azure\bin\$Configuration$\Xamarin.Forms.Pages.Azure.dll" target="lib\wpa81" /> + + <!--WinRT Tablet--> + <file src="..\Xamarin.Forms.Pages.Azure\bin\$Configuration$\Xamarin.Forms.Pages.Azure.dll" target="lib\win81" /> + + </files> +</package> diff --git a/.nuspec/Xamarin.Forms.Pages.nuspec b/.nuspec/Xamarin.Forms.Pages.nuspec index 73bab273..c91b2ab8 100644 --- a/.nuspec/Xamarin.Forms.Pages.nuspec +++ b/.nuspec/Xamarin.Forms.Pages.nuspec @@ -14,7 +14,7 @@ <dependencies> <group> <dependency id="Xamarin.Forms$IdAppend$" version="$version$"/> - <dependency id="Newtonsoft.Json" version="8.0.3"/> + <dependency id="Newtonsoft.Json" version="6.0.4"/> <dependency id="modernhttpclient" version="2.4.2"/> </group> </dependencies> diff --git a/PagesGallery/PagesGallery.Droid/MainActivity.cs b/PagesGallery/PagesGallery.Droid/MainActivity.cs index b991250c..37f4a4ff 100644 --- a/PagesGallery/PagesGallery.Droid/MainActivity.cs +++ b/PagesGallery/PagesGallery.Droid/MainActivity.cs @@ -15,8 +15,10 @@ namespace PagesGallery.Droid ToolbarResource = Resource.Layout.Toolbar; TabLayoutResource = Resource.Layout.Tabbar; - base.OnCreate(bundle); + Microsoft.WindowsAzure.MobileServices.CurrentPlatform.Init(); + base.OnCreate(bundle); + Forms.Init(this, bundle); LoadApplication(new App()); } diff --git a/PagesGallery/PagesGallery.Droid/PagesGallery.Droid.csproj b/PagesGallery/PagesGallery.Droid/PagesGallery.Droid.csproj index 02e1434e..6312a948 100644 --- a/PagesGallery/PagesGallery.Droid/PagesGallery.Droid.csproj +++ b/PagesGallery/PagesGallery.Droid/PagesGallery.Droid.csproj @@ -48,19 +48,31 @@ <AndroidLinkMode>SdkOnly</AndroidLinkMode> </PropertyGroup> <ItemGroup> - <Reference Include="ModernHttpClient, Version=2.4.2.0, Culture=neutral, processorArchitecture=MSIL"> - <HintPath>..\..\packages\modernhttpclient.2.4.2\lib\MonoAndroid\ModernHttpClient.dll</HintPath> + <Reference Include="Microsoft.WindowsAzure.Mobile, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> + <HintPath>..\..\packages\Microsoft.Azure.Mobile.Client.2.0.1\lib\monoandroid\Microsoft.WindowsAzure.Mobile.dll</HintPath> + <Private>True</Private> + </Reference> + <Reference Include="Microsoft.WindowsAzure.Mobile.Ext, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> + <HintPath>..\..\packages\Microsoft.Azure.Mobile.Client.2.0.1\lib\monoandroid\Microsoft.WindowsAzure.Mobile.Ext.dll</HintPath> <Private>True</Private> </Reference> <Reference Include="Mono.Android" /> <Reference Include="mscorlib" /> - <Reference Include="OkHttp, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> - <HintPath>..\..\packages\modernhttpclient.2.4.2\lib\MonoAndroid\OkHttp.dll</HintPath> + <Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> + <HintPath>..\..\packages\Newtonsoft.Json.6.0.4\lib\portable-net45+wp80+win8+wpa81\Newtonsoft.Json.dll</HintPath> <Private>True</Private> </Reference> <Reference Include="System" /> <Reference Include="System.Core" /> - <Reference Include="System.Xml.Linq" /> + <Reference Include="System.Net.Http" /> + <Reference Include="System.Net.Http.Extensions, Version=2.2.29.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> + <HintPath>..\..\packages\Microsoft.Net.Http.2.2.29\lib\monoandroid\System.Net.Http.Extensions.dll</HintPath> + <Private>True</Private> + </Reference> + <Reference Include="System.Net.Http.Primitives, Version=4.2.29.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> + <HintPath>..\..\packages\Microsoft.Net.Http.2.2.29\lib\monoandroid\System.Net.Http.Primitives.dll</HintPath> + <Private>True</Private> + </Reference> <Reference Include="System.Xml" /> <Reference Include="Xamarin.Android.Support.Animated.Vector.Drawable, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\..\packages\Xamarin.Android.Support.Animated.Vector.Drawable.23.3.0\lib\MonoAndroid403\Xamarin.Android.Support.Animated.Vector.Drawable.dll</HintPath> @@ -130,6 +142,10 @@ <Project>{57b8b73d-c3b5-4c42-869e-7b2f17d354ac}</Project> <Name>Xamarin.Forms.Core</Name> </ProjectReference> + <ProjectReference Include="..\..\Xamarin.Forms.Pages.Azure\Xamarin.Forms.Pages.Azure.csproj"> + <Project>{c9696465-7657-4843-872e-3c01891c4a9b}</Project> + <Name>Xamarin.Forms.Pages.Azure</Name> + </ProjectReference> <ProjectReference Include="..\..\Xamarin.Forms.Pages\Xamarin.Forms.Pages.csproj"> <Project>{d6133dbd-6c60-4bd5-bea2-07e0a3927c31}</Project> <Name>Xamarin.Forms.Pages</Name> @@ -161,7 +177,9 @@ <ErrorText>This project references NuGet package(s) that are missing on this computer. Use 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('..\..\packages\Xamarin.Android.Support.Vector.Drawable.23.3.0\build\Xamarin.Android.Support.Vector.Drawable.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Xamarin.Android.Support.Vector.Drawable.23.3.0\build\Xamarin.Android.Support.Vector.Drawable.targets'))" /> + <Error Condition="!Exists('..\..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets'))" /> </Target> + <Import Project="..\..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets" Condition="Exists('..\..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.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"> diff --git a/PagesGallery/PagesGallery.Droid/Properties/AndroidManifest.xml b/PagesGallery/PagesGallery.Droid/Properties/AndroidManifest.xml index 1b619fc0..342b35e8 100644 --- a/PagesGallery/PagesGallery.Droid/Properties/AndroidManifest.xml +++ b/PagesGallery/PagesGallery.Droid/Properties/AndroidManifest.xml @@ -2,4 +2,4 @@ <manifest xmlns:android="http://schemas.android.com/apk/res/android"> <uses-sdk android:minSdkVersion="15" /> <application></application> -</manifest> +</manifest>
\ No newline at end of file diff --git a/PagesGallery/PagesGallery.Droid/app.config b/PagesGallery/PagesGallery.Droid/app.config index 4dd3b43c..d536bee7 100644 --- a/PagesGallery/PagesGallery.Droid/app.config +++ b/PagesGallery/PagesGallery.Droid/app.config @@ -6,6 +6,14 @@ <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-1.5.0.0" newVersion="1.5.0.0" /> </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Net.Http.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.2.29.0" newVersion="4.2.29.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" /> + </dependentAssembly> </assemblyBinding> </runtime> </configuration>
\ No newline at end of file diff --git a/PagesGallery/PagesGallery.Droid/packages.config b/PagesGallery/PagesGallery.Droid/packages.config index b11a3746..06afcedb 100644 --- a/PagesGallery/PagesGallery.Droid/packages.config +++ b/PagesGallery/PagesGallery.Droid/packages.config @@ -1,6 +1,10 @@ <?xml version="1.0" encoding="utf-8"?> <packages> - <package id="modernhttpclient" version="2.4.2" targetFramework="monoandroid60" /> + <package id="Microsoft.Azure.Mobile.Client" version="2.0.1" targetFramework="monoandroid60" /> + <package id="Microsoft.Bcl" version="1.1.10" targetFramework="monoandroid60" /> + <package id="Microsoft.Bcl.Build" version="1.0.21" targetFramework="monoandroid60" /> + <package id="Microsoft.Net.Http" version="2.2.29" targetFramework="monoandroid60" /> + <package id="Newtonsoft.Json" version="6.0.4" targetFramework="monoandroid60" /> <package id="Xamarin.Android.Support.Animated.Vector.Drawable" version="23.3.0" targetFramework="monoandroid60" /> <package id="Xamarin.Android.Support.Design" version="23.3.0" targetFramework="monoandroid60" /> <package id="Xamarin.Android.Support.v4" version="23.3.0" targetFramework="monoandroid60" /> diff --git a/PagesGallery/PagesGallery.UWP/PagesGallery.UWP.csproj b/PagesGallery/PagesGallery.UWP/PagesGallery.UWP.csproj index b72b6705..20760ecf 100644 --- a/PagesGallery/PagesGallery.UWP/PagesGallery.UWP.csproj +++ b/PagesGallery/PagesGallery.UWP/PagesGallery.UWP.csproj @@ -132,6 +132,10 @@ <Project>{57b8b73d-c3b5-4c42-869e-7b2f17d354ac}</Project> <Name>Xamarin.Forms.Core</Name> </ProjectReference> + <ProjectReference Include="..\..\Xamarin.Forms.Pages.Azure\Xamarin.Forms.Pages.Azure.csproj"> + <Project>{c9696465-7657-4843-872e-3c01891c4a9b}</Project> + <Name>Xamarin.Forms.Pages.Azure</Name> + </ProjectReference> <ProjectReference Include="..\..\Xamarin.Forms.Pages\Xamarin.Forms.Pages.csproj"> <Project>{d6133dbd-6c60-4bd5-bea2-07e0a3927c31}</Project> <Name>Xamarin.Forms.Pages</Name> diff --git a/PagesGallery/PagesGallery.UWP/project.json b/PagesGallery/PagesGallery.UWP/project.json index 226a07ce..c5949392 100644 --- a/PagesGallery/PagesGallery.UWP/project.json +++ b/PagesGallery/PagesGallery.UWP/project.json @@ -1,7 +1,6 @@ { "dependencies": { - "Microsoft.NETCore.UniversalWindowsPlatform": "5.0.0", - "modernhttpclient": "2.4.2" + "Microsoft.NETCore.UniversalWindowsPlatform": "5.0.0" }, "frameworks": { "uap10.0": {} diff --git a/PagesGallery/PagesGallery.iOS/PagesGallery.iOS.csproj b/PagesGallery/PagesGallery.iOS/PagesGallery.iOS.csproj index 8607831c..685e8084 100644 --- a/PagesGallery/PagesGallery.iOS/PagesGallery.iOS.csproj +++ b/PagesGallery/PagesGallery.iOS/PagesGallery.iOS.csproj @@ -96,9 +96,6 @@ <Compile Include="Properties\AssemblyInfo.cs" /> <ITunesArtwork Include="iTunesArtwork" /> <ITunesArtwork Include="iTunesArtwork@2x" /> - <None Include="packages.config"> - <SubType>Designer</SubType> - </None> </ItemGroup> <ItemGroup> <ProjectReference Include="..\..\Stubs\Xamarin.Forms.Platform.iOS\Xamarin.Forms.Platform.iOS %28Forwarders%29.csproj"> @@ -109,6 +106,10 @@ <Project>{57b8b73d-c3b5-4c42-869e-7b2f17d354ac}</Project> <Name>Xamarin.Forms.Core</Name> </ProjectReference> + <ProjectReference Include="..\..\Xamarin.Forms.Pages.Azure\Xamarin.Forms.Pages.Azure.csproj"> + <Project>{c9696465-7657-4843-872e-3c01891c4a9b}</Project> + <Name>Xamarin.Forms.Pages.Azure</Name> + </ProjectReference> <ProjectReference Include="..\..\Xamarin.Forms.Pages\Xamarin.Forms.Pages.csproj"> <Project>{d6133dbd-6c60-4bd5-bea2-07e0a3927c31}</Project> <Name>Xamarin.Forms.Pages</Name> @@ -146,10 +147,6 @@ <InterfaceDefinition Include="Resources\LaunchScreen.storyboard" /> </ItemGroup> <ItemGroup> - <Reference Include="ModernHttpClient, Version=2.4.2.0, Culture=neutral, processorArchitecture=MSIL"> - <HintPath>..\..\packages\modernhttpclient.2.4.2\lib\Xamarin.iOS10\ModernHttpClient.dll</HintPath> - <Private>True</Private> - </Reference> <Reference Include="System" /> <Reference Include="System.Xml" /> <Reference Include="System.Core" /> diff --git a/PagesGallery/PagesGallery.iOS/packages.config b/PagesGallery/PagesGallery.iOS/packages.config deleted file mode 100644 index f0eba649..00000000 --- a/PagesGallery/PagesGallery.iOS/packages.config +++ /dev/null @@ -1,4 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<packages> - <package id="modernhttpclient" version="2.4.2" targetFramework="xamarinios10" /> -</packages>
\ No newline at end of file diff --git a/PagesGallery/PagesGallery/EventsPage.xaml b/PagesGallery/PagesGallery/EventsPage.xaml index 2d7abafd..ab1c14b9 100644 --- a/PagesGallery/PagesGallery/EventsPage.xaml +++ b/PagesGallery/PagesGallery/EventsPage.xaml @@ -2,16 +2,21 @@ <p:ListDataPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:p="clr-namespace:Xamarin.Forms.Pages;assembly=Xamarin.Forms.Pages" + xmlns:azure="clr-namespace:Xamarin.Forms.Pages.Azure;assembly=Xamarin.Forms.Pages.Azure" x:Class="PagesGallery.EventsPage" Title="Events" DetailTemplate="{StaticResource EventDetailTemplate}" Style="{StaticResource EventPageStyle}"> <p:DataPage.DataSource> - <p:JsonDataSource Source="http://demo7391822.mockable.io/events" /> + <azure:AzureDataSource> + <azure:AzureDataSource.Source> + <azure:AzureEasyTableSource Uri="http://evolvedemo.azurewebsites.net" TableName="Employee" /> + </azure:AzureDataSource.Source> + </azure:AzureDataSource> </p:DataPage.DataSource> <p:DataPage.DefaultItemTemplate> <DataTemplate> - <TextCell Text="{Binding Value[name]}" Detail="{Binding Value[presenter]}" /> + <TextCell Text="{Binding Value[firstName]}" Detail="{Binding Value[companyName]}" /> </DataTemplate> </p:DataPage.DefaultItemTemplate> </p:ListDataPage>
\ No newline at end of file diff --git a/PagesGallery/PagesGallery/PagesGallery.csproj b/PagesGallery/PagesGallery/PagesGallery.csproj index 19fdfbb6..7b30f828 100644 --- a/PagesGallery/PagesGallery/PagesGallery.csproj +++ b/PagesGallery/PagesGallery/PagesGallery.csproj @@ -49,13 +49,16 @@ </ItemGroup> <ItemGroup> <None Include="GettingStarted.Xamarin" /> - <None Include="packages.config" /> </ItemGroup> <ItemGroup> <ProjectReference Include="..\..\Xamarin.Forms.Core\Xamarin.Forms.Core.csproj"> <Project>{57b8b73d-c3b5-4c42-869e-7b2f17d354ac}</Project> <Name>Xamarin.Forms.Core</Name> </ProjectReference> + <ProjectReference Include="..\..\Xamarin.Forms.Pages.Azure\Xamarin.Forms.Pages.Azure.csproj"> + <Project>{c9696465-7657-4843-872e-3c01891c4a9b}</Project> + <Name>Xamarin.Forms.Pages.Azure</Name> + </ProjectReference> <ProjectReference Include="..\..\Xamarin.Forms.Pages\Xamarin.Forms.Pages.csproj"> <Project>{d6133dbd-6c60-4bd5-bea2-07e0a3927c31}</Project> <Name>Xamarin.Forms.Pages</Name> @@ -87,12 +90,6 @@ <SubType>Designer</SubType> </EmbeddedResource> </ItemGroup> - <ItemGroup> - <Reference Include="ModernHttpClient, Version=2.4.2.0, Culture=neutral, processorArchitecture=MSIL"> - <HintPath>..\..\packages\modernhttpclient.2.4.2\lib\Portable-Net45+WinRT45+WP8+WPA81\ModernHttpClient.dll</HintPath> - <Private>True</Private> - </Reference> - </ItemGroup> <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" /> <Import Project="..\..\.nuspec\Xamarin.Forms.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. diff --git a/PagesGallery/PagesGallery/packages.config b/PagesGallery/PagesGallery/packages.config deleted file mode 100644 index 8f0534f1..00000000 --- a/PagesGallery/PagesGallery/packages.config +++ /dev/null @@ -1,4 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<packages> - <package id="modernhttpclient" version="2.4.2" targetFramework="portable45-net45+win8+wp8+wpa81" /> -</packages>
\ No newline at end of file diff --git a/Xamarin.Forms.Pages.Azure/AzureDataSource.cs b/Xamarin.Forms.Pages.Azure/AzureDataSource.cs new file mode 100644 index 00000000..907421cb --- /dev/null +++ b/Xamarin.Forms.Pages.Azure/AzureDataSource.cs @@ -0,0 +1,149 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Newtonsoft.Json.Linq; + +namespace Xamarin.Forms.Pages.Azure +{ + public class AzureDataSource : BaseDataSource + { + readonly ObservableCollection<IDataItem> _dataItems = new ObservableCollection<IDataItem>(); + Task _currentParseTask; + bool _initialized; + AzureSource _source; + + public AzureDataSource() + { + } + + internal AzureDataSource(JToken rootToken) + { + ParseJsonToken(rootToken); + } + + public AzureSource Source + { + get + { + return _source; + } + set + { + if (_source == value) + return; + _source = value; + + _dataItems.Clear(); + if (value != null && _initialized) + { + _currentParseTask = ParseJson(); + _currentParseTask.ContinueWith(t => { throw t.Exception; }, TaskContinuationOptions.OnlyOnFaulted); + } + } + } + + protected override async Task<IList<IDataItem>> GetRawData() + { + if (!_initialized) + { + Task task = _currentParseTask = ParseJson(); + await task; + } + else if (_currentParseTask != null && _currentParseTask.IsCompleted == false) + await _currentParseTask; + return _dataItems; + } + + protected override object GetValue(string key) + { + IDataItem target = _dataItems.FirstOrDefault(d => d.Name == key); + return target?.Value; + } + + protected override bool SetValue(string key, object value) + { + IDataItem target = _dataItems.FirstOrDefault(d => d.Name == key); + if (target == null) + { + _dataItems.Add(new DataItem(key, value)); + return true; + } + if (target.Value == value) + return false; + target.Value = value; + return true; + } + + object GetValueForJToken(JToken token) + { + switch (token.Type) + { + case JTokenType.Object: + case JTokenType.Array: + return new AzureDataSource(token); + case JTokenType.Constructor: + case JTokenType.Property: + case JTokenType.Comment: + throw new NotImplementedException(); + case JTokenType.Integer: + return (int)token; + case JTokenType.Float: + return (float)token; + case JTokenType.Raw: + case JTokenType.String: + return (string)token; + case JTokenType.Boolean: + return (bool)token; + case JTokenType.Date: + return (DateTime)token; + case JTokenType.Bytes: + return (byte[])token; + case JTokenType.Guid: + return (Guid)token; + case JTokenType.Uri: + return (Uri)token; + case JTokenType.TimeSpan: + return (TimeSpan)token; + default: + return null; + } + } + + async Task ParseJson() + { + _initialized = true; + + if (Source == null) + return; + + IsLoading = true; + var jtoken = await Source.GetJson(); + ParseJsonToken(jtoken); + IsLoading = false; + } + + void ParseJsonToken(JToken token) + { + var jArray = token as JArray; + var jObject = token as JObject; + if (jArray != null) + { + for (var i = 0; i < jArray.Count; i++) + { + JToken obj = jArray[i]; + _dataItems.Add(new DataItem(i.ToString(), GetValueForJToken(obj))); + } + } + else if (jObject != null) + { + foreach (KeyValuePair<string, JToken> kvp in jObject) + { + _dataItems.Add(new DataItem(kvp.Key, GetValueForJToken(kvp.Value))); + } + } + } + } +} diff --git a/Xamarin.Forms.Pages.Azure/AzureEasyTableSource.cs b/Xamarin.Forms.Pages.Azure/AzureEasyTableSource.cs new file mode 100644 index 00000000..1d5a24f0 --- /dev/null +++ b/Xamarin.Forms.Pages.Azure/AzureEasyTableSource.cs @@ -0,0 +1,26 @@ +using System; +using System.Threading.Tasks; +using Microsoft.WindowsAzure.MobileServices; +using Newtonsoft.Json.Linq; + +namespace Xamarin.Forms.Pages.Azure +{ + public class AzureEasyTableSource : AzureSource + { + public static readonly BindableProperty TableNameProperty = + BindableProperty.Create(nameof(TableName), typeof(string), typeof(AzureEasyTableSource), null); + + public string TableName + { + get { return (string)GetValue(TableNameProperty); } + set { SetValue(TableNameProperty, value); } + } + + public override async Task<JToken> GetJson() + { + var mobileServiceClient = new MobileServiceClient(Uri); + var table = mobileServiceClient.GetTable(TableName); + return await table.ReadAsync(string.Empty); + } + } +}
\ No newline at end of file diff --git a/Xamarin.Forms.Pages.Azure/AzureSource.cs b/Xamarin.Forms.Pages.Azure/AzureSource.cs new file mode 100644 index 00000000..ec2b2984 --- /dev/null +++ b/Xamarin.Forms.Pages.Azure/AzureSource.cs @@ -0,0 +1,21 @@ +using System; +using System.Threading.Tasks; +using Newtonsoft.Json.Linq; + +namespace Xamarin.Forms.Pages.Azure +{ + public abstract class AzureSource : Element + { + public static readonly BindableProperty UriProperty = + BindableProperty.Create(nameof(Uri), typeof(Uri), typeof(AzureSource), null); + + [TypeConverter(typeof(UriTypeConverter))] + public Uri Uri + { + get { return (Uri)GetValue(UriProperty); } + set { SetValue(UriProperty, value); } + } + + public abstract Task<JToken> GetJson(); + } +}
\ No newline at end of file diff --git a/Xamarin.Forms.Pages.Azure/Properties/AssemblyInfo.cs b/Xamarin.Forms.Pages.Azure/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..8c6b8dac --- /dev/null +++ b/Xamarin.Forms.Pages.Azure/Properties/AssemblyInfo.cs @@ -0,0 +1,30 @@ +using System.Resources; +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("Xamarin.Forms.Pages.Azure")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Xamarin.Forms.Pages.Azure")] +[assembly: AssemblyCopyright("Copyright © 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +[assembly: NeutralResourcesLanguage("en")] + +// 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")] diff --git a/Xamarin.Forms.Pages.Azure/Xamarin.Forms.Pages.Azure.csproj b/Xamarin.Forms.Pages.Azure/Xamarin.Forms.Pages.Azure.csproj new file mode 100644 index 00000000..c8d47fd8 --- /dev/null +++ b/Xamarin.Forms.Pages.Azure/Xamarin.Forms.Pages.Azure.csproj @@ -0,0 +1,99 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="14.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>{C9696465-7657-4843-872E-3C01891C4A9B}</ProjectGuid> + <OutputType>Library</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>Xamarin.Forms.Pages.Azure</RootNamespace> + <AssemblyName>Xamarin.Forms.Pages.Azure</AssemblyName> + <DefaultLanguage>en-US</DefaultLanguage> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <TargetFrameworkProfile>Profile259</TargetFrameworkProfile> + <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> + <NuGetPackageImportStamp> + </NuGetPackageImportStamp> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>bin\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <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</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <ItemGroup> + <!-- A reference to the entire .NET Framework is automatically included --> + <None Include="packages.config" /> + </ItemGroup> + <ItemGroup> + <Compile Include="AzureDataSource.cs" /> + <Compile Include="AzureEasyTableSource.cs" /> + <Compile Include="AzureSource.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + </ItemGroup> + <ItemGroup> + <Reference Include="Microsoft.WindowsAzure.Mobile, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> + <HintPath>..\packages\Microsoft.Azure.Mobile.Client.2.0.1\lib\portable-win+net45+wp8+wpa81+monotouch+monoandroid\Microsoft.WindowsAzure.Mobile.dll</HintPath> + <Private>True</Private> + </Reference> + <Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> + <HintPath>..\packages\Newtonsoft.Json.6.0.4\lib\portable-net45+wp80+win8+wpa81\Newtonsoft.Json.dll</HintPath> + <Private>True</Private> + </Reference> + <Reference Include="System.Net.Http, Version=1.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> + <HintPath>..\packages\Microsoft.Net.Http.2.2.29\lib\portable-net40+sl4+win8+wp71+wpa81\System.Net.Http.dll</HintPath> + <Private>True</Private> + </Reference> + <Reference Include="System.Net.Http.Extensions, Version=1.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> + <HintPath>..\packages\Microsoft.Net.Http.2.2.29\lib\portable-net40+sl4+win8+wp71+wpa81\System.Net.Http.Extensions.dll</HintPath> + <Private>True</Private> + </Reference> + <Reference Include="System.Net.Http.Primitives, Version=1.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> + <HintPath>..\packages\Microsoft.Net.Http.2.2.29\lib\portable-net40+sl4+win8+wp71+wpa81\System.Net.Http.Primitives.dll</HintPath> + <Private>True</Private> + </Reference> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\Xamarin.Forms.Core\Xamarin.Forms.Core.csproj"> + <Project>{57b8b73d-c3b5-4c42-869e-7b2f17d354ac}</Project> + <Name>Xamarin.Forms.Core</Name> + </ProjectReference> + <ProjectReference Include="..\Xamarin.Forms.Pages\Xamarin.Forms.Pages.csproj"> + <Project>{d6133dbd-6c60-4bd5-bea2-07e0a3927c31}</Project> + <Name>Xamarin.Forms.Pages</Name> + </ProjectReference> + <ProjectReference Include="..\Xamarin.Forms.Xaml\Xamarin.Forms.Xaml.csproj"> + <Project>{9db2f292-8034-4e06-89ad-98bbda4306b9}</Project> + <Name>Xamarin.Forms.Xaml</Name> + </ProjectReference> + </ItemGroup> + <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" /> + <Import Project="..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets" Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets')" /> + <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> + <PropertyGroup> + <ErrorText>This project references NuGet package(s) that are missing on this computer. Use 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('..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets'))" /> + </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>
\ No newline at end of file diff --git a/Xamarin.Forms.Pages.Azure/packages.config b/Xamarin.Forms.Pages.Azure/packages.config new file mode 100644 index 00000000..035d1e5d --- /dev/null +++ b/Xamarin.Forms.Pages.Azure/packages.config @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="utf-8"?> +<packages> + <package id="Microsoft.Azure.Mobile.Client" version="2.0.1" targetFramework="portable45-net45+win8+wp8+wpa81" /> + <package id="Microsoft.Bcl" version="1.1.10" targetFramework="portable45-net45+win8+wp8+wpa81" /> + <package id="Microsoft.Bcl.Build" version="1.0.21" targetFramework="portable45-net45+win8+wp8+wpa81" /> + <package id="Microsoft.Net.Http" version="2.2.29" targetFramework="portable45-net45+win8+wp8+wpa81" /> + <package id="Newtonsoft.Json" version="6.0.4" targetFramework="portable45-net45+win8+wp8+wpa81" /> +</packages>
\ No newline at end of file diff --git a/Xamarin.Forms.Pages/UriJsonSource.cs b/Xamarin.Forms.Pages/UriJsonSource.cs index d732e25c..b8681e9e 100644 --- a/Xamarin.Forms.Pages/UriJsonSource.cs +++ b/Xamarin.Forms.Pages/UriJsonSource.cs @@ -11,6 +11,7 @@ namespace Xamarin.Forms.Pages public static readonly BindableProperty UriProperty = BindableProperty.Create(nameof(Uri), typeof(Uri), typeof(UriJsonSource), null); + [TypeConverter(typeof(UriTypeConverter))] public Uri Uri { get { return (Uri)GetValue(UriProperty); } @@ -19,7 +20,7 @@ namespace Xamarin.Forms.Pages public override async Task<string> GetJson() { - var webClient = new HttpClient(new ModernHttpClient.NativeMessageHandler()); + var webClient = new HttpClient(); try { string json = await webClient.GetStringAsync(Uri); diff --git a/Xamarin.Forms.Pages/Xamarin.Forms.Pages.csproj b/Xamarin.Forms.Pages/Xamarin.Forms.Pages.csproj index 15c8e1cd..82e54923 100644 --- a/Xamarin.Forms.Pages/Xamarin.Forms.Pages.csproj +++ b/Xamarin.Forms.Pages/Xamarin.Forms.Pages.csproj @@ -66,8 +66,8 @@ <Compile Include="UriJsonSource.cs" /> </ItemGroup> <ItemGroup> - <Reference Include="ModernHttpClient, Version=2.4.2.0, Culture=neutral, processorArchitecture=MSIL"> - <HintPath>..\packages\modernhttpclient.2.4.2\lib\Portable-Net45+WinRT45+WP8+WPA81\ModernHttpClient.dll</HintPath> + <Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> + <HintPath>..\packages\Newtonsoft.Json.6.0.4\lib\portable-net45+wp80+win8+wpa81\Newtonsoft.Json.dll</HintPath> <Private>True</Private> </Reference> <Reference Include="System.Net.Http, Version=1.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> @@ -82,9 +82,6 @@ <HintPath>..\packages\Microsoft.Net.Http.2.2.29\lib\portable-net40+sl4+win8+wp71+wpa81\System.Net.Http.Primitives.dll</HintPath> <Private>True</Private> </Reference> - <Reference Include="Newtonsoft.Json"> - <HintPath>..\packages\Newtonsoft.Json.8.0.3\lib\portable-net45+wp80+win8+wpa81+dnxcore50\Newtonsoft.Json.dll</HintPath> - </Reference> </ItemGroup> <ItemGroup> <None Include="packages.config" /> diff --git a/Xamarin.Forms.Pages/packages.config b/Xamarin.Forms.Pages/packages.config index 1861a33d..fc6881e9 100644 --- a/Xamarin.Forms.Pages/packages.config +++ b/Xamarin.Forms.Pages/packages.config @@ -3,6 +3,5 @@ <package id="Microsoft.Bcl" version="1.1.10" targetFramework="portable45-net45+win8+wp8+wpa81" /> <package id="Microsoft.Bcl.Build" version="1.0.14" targetFramework="portable45-net45+win8+wp8+wpa81" /> <package id="Microsoft.Net.Http" version="2.2.29" targetFramework="portable45-net45+win8+wp8+wpa81" /> - <package id="modernhttpclient" version="2.4.2" targetFramework="portable45-net45+win8+wp8+wpa81" /> - <package id="Newtonsoft.Json" version="8.0.3" targetFramework="portable-net45+win+wpa81+wp80+MonoTouch10+MonoAndroid10+xamarinmac20+xamarintvos10+xamarinwatchos10+xamarinios10" /> + <package id="Newtonsoft.Json" version="6.0.4" targetFramework="portable45-net45+win8+wp8+wpa81" /> </packages>
\ No newline at end of file diff --git a/Xamarin.Forms.sln b/Xamarin.Forms.sln index 1dd56212..eefd13ae 100644 --- a/Xamarin.Forms.sln +++ b/Xamarin.Forms.sln @@ -159,6 +159,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PagesGallery.UWP", "PagesGa EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xamarin.Forms.Platform.Android.AppLinks", "Xamarin.Forms.Platform.Android.AppLinks\Xamarin.Forms.Platform.Android.AppLinks.csproj", "{42DB052E-0909-45D2-8240-187F99F393FB}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xamarin.Forms.Pages.Azure", "Xamarin.Forms.Pages.Azure\Xamarin.Forms.Pages.Azure.csproj", "{C9696465-7657-4843-872E-3C01891C4A9B}" +EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution docs\APIDocs.projitems*{dc1f3933-ac99-4887-8b09-e13c2b346d4f}*SharedItemsImports = 13 @@ -1690,6 +1692,34 @@ Global {42DB052E-0909-45D2-8240-187F99F393FB}.Release|x64.Build.0 = Release|Any CPU {42DB052E-0909-45D2-8240-187F99F393FB}.Release|x86.ActiveCfg = Release|Any CPU {42DB052E-0909-45D2-8240-187F99F393FB}.Release|x86.Build.0 = Release|Any CPU + {C9696465-7657-4843-872E-3C01891C4A9B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C9696465-7657-4843-872E-3C01891C4A9B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C9696465-7657-4843-872E-3C01891C4A9B}.Debug|ARM.ActiveCfg = Debug|Any CPU + {C9696465-7657-4843-872E-3C01891C4A9B}.Debug|ARM.Build.0 = Debug|Any CPU + {C9696465-7657-4843-872E-3C01891C4A9B}.Debug|iPhone.ActiveCfg = Debug|Any CPU + {C9696465-7657-4843-872E-3C01891C4A9B}.Debug|iPhone.Build.0 = Debug|Any CPU + {C9696465-7657-4843-872E-3C01891C4A9B}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {C9696465-7657-4843-872E-3C01891C4A9B}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU + {C9696465-7657-4843-872E-3C01891C4A9B}.Debug|Templates.ActiveCfg = Debug|Any CPU + {C9696465-7657-4843-872E-3C01891C4A9B}.Debug|Templates.Build.0 = Debug|Any CPU + {C9696465-7657-4843-872E-3C01891C4A9B}.Debug|x64.ActiveCfg = Debug|Any CPU + {C9696465-7657-4843-872E-3C01891C4A9B}.Debug|x64.Build.0 = Debug|Any CPU + {C9696465-7657-4843-872E-3C01891C4A9B}.Debug|x86.ActiveCfg = Debug|Any CPU + {C9696465-7657-4843-872E-3C01891C4A9B}.Debug|x86.Build.0 = Debug|Any CPU + {C9696465-7657-4843-872E-3C01891C4A9B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C9696465-7657-4843-872E-3C01891C4A9B}.Release|Any CPU.Build.0 = Release|Any CPU + {C9696465-7657-4843-872E-3C01891C4A9B}.Release|ARM.ActiveCfg = Release|Any CPU + {C9696465-7657-4843-872E-3C01891C4A9B}.Release|ARM.Build.0 = Release|Any CPU + {C9696465-7657-4843-872E-3C01891C4A9B}.Release|iPhone.ActiveCfg = Release|Any CPU + {C9696465-7657-4843-872E-3C01891C4A9B}.Release|iPhone.Build.0 = Release|Any CPU + {C9696465-7657-4843-872E-3C01891C4A9B}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU + {C9696465-7657-4843-872E-3C01891C4A9B}.Release|iPhoneSimulator.Build.0 = Release|Any CPU + {C9696465-7657-4843-872E-3C01891C4A9B}.Release|Templates.ActiveCfg = Release|Any CPU + {C9696465-7657-4843-872E-3C01891C4A9B}.Release|Templates.Build.0 = Release|Any CPU + {C9696465-7657-4843-872E-3C01891C4A9B}.Release|x64.ActiveCfg = Release|Any CPU + {C9696465-7657-4843-872E-3C01891C4A9B}.Release|x64.Build.0 = Release|Any CPU + {C9696465-7657-4843-872E-3C01891C4A9B}.Release|x86.ActiveCfg = Release|Any CPU + {C9696465-7657-4843-872E-3C01891C4A9B}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1754,5 +1784,6 @@ Global {392156B2-760A-4EE3-A822-CABD3238A21D} = {80BAC3FB-357A-4D05-A050-9F234DF49C97} {95FEB8D4-D57E-4B96-A8D8-59D241C0501B} = {80BAC3FB-357A-4D05-A050-9F234DF49C97} {42DB052E-0909-45D2-8240-187F99F393FB} = {29AC50BF-B4FB-450B-9386-0C5AD4B84226} + {C9696465-7657-4843-872E-3C01891C4A9B} = {9AD757F5-E57A-459D-A0A7-E0675E045B84} EndGlobalSection EndGlobal |