diff --git a/.gitignore b/.gitignore index 8d2d841..8dd4607 100644 --- a/.gitignore +++ b/.gitignore @@ -1,29 +1,84 @@ -# Build Folders (you can keep bin if you'd like, to store dlls and pdbs) -[Bb]in/ -[Oo]bj/ - -# mstest test results -TestResults - ## Ignore Visual Studio temporary files, build results, and ## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore # User-specific files +*.rsuser *.suo *.user +*.userosscache *.sln.docstates +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + # Build results [Dd]ebug/ +[Dd]ebugPublic/ [Rr]elease/ +[Rr]eleases/ x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio *_i.c *_p.c +*_h.h *.ilk *.meta *.obj +*.iobj *.pch *.pdb +*.ipdb *.pgc *.pgd *.rsp @@ -32,35 +87,84 @@ x64/ *.tli *.tlh *.tmp +*.tmp_proj +*_wpftmp.csproj *.log +*.tlog *.vspscc *.vssscc .builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* # Visual C++ cache files ipch/ *.aps *.ncb +*.opendb *.opensdf *.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb # Visual Studio profiler *.psess *.vsp *.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ # Guidance Automation Toolkit *.gpState # ReSharper is a .NET coding add-in -_ReSharper* +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml # NCrunch -*.ncrunch* +_NCrunch_* .*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ -# Installshield output folder -[Ee]xpress +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ # DocProject is a documentation generator add-in DocProject/buildhelp/ @@ -73,42 +177,222 @@ DocProject/Help/Html2 DocProject/Help/html # Click-Once directory -publish +publish/ # Publish Web Output -*.Publish.xml +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ -# NuGet Packages Directory -packages/ -tmp_nuget/ -vs.bat +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets -# Windows Azure Build Output -csx +# Microsoft Azure Build Output +csx/ *.build.csdef -# Windows Store app package directory +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files AppPackages/ -.nodeCs +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ # Others -[Bb]in -[Oo]bj -sql -TestResults -[Tt]est[Rr]esult* -*.Cache -ClientBin -[Ss]tyle[Cc]op.* +ClientBin/ ~$* +*~ *.dbmdl -Generated_Code #added for RIA/Silverlight projects +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs -# Backup & report files from converting an old project file to a newer -# Visual Studio version. Backup files are not needed, because we have git ;-) +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) _UpgradeReport_Files/ Backup*/ UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio 6 auto-generated project file (contains which files were open etc.) +*.vbp + +# Visual Studio 6 workspace and project file (working project files containing files to include in project) +*.dsw +*.dsp + +# Visual Studio 6 technical files +*.ncb +*.aps + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# Visual Studio History (VSHistory) files +.vshistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd + +# VS Code files for those working on multiple tools +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace + +# Local History for Visual Studio Code +.history/ + +# Windows Installer files from build outputs +*.cab +*.msi +*.msix +*.msm +*.msp -App_Bin/ -PerfMon/ +# JetBrains Rider +*.sln.iml \ No newline at end of file diff --git a/Linq2Rest.Reactive.Tests/Fakes/ChildItem.cs b/Linq2Rest.Reactive.Tests/Fakes/ChildItem.cs deleted file mode 100644 index f7b644c..0000000 --- a/Linq2Rest.Reactive.Tests/Fakes/ChildItem.cs +++ /dev/null @@ -1,23 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright © Reimers.dk 2014 -// This source is subject to the Microsoft Public License (Ms-PL). -// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details. -// All other rights reserved. -// -// -// Defines the ChildItem type. -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace Linq2Rest.Reactive.Tests.Fakes -{ - using System.Collections.Generic; - - public class ChildItem - { - public string Text { get; set; } - - public IList Descendants { get; set; } - } -} \ No newline at end of file diff --git a/Linq2Rest.Reactive.Tests/Fakes/FakeAsyncRestClientFactory.cs b/Linq2Rest.Reactive.Tests/Fakes/FakeAsyncRestClientFactory.cs deleted file mode 100644 index 8ddb2e5..0000000 --- a/Linq2Rest.Reactive.Tests/Fakes/FakeAsyncRestClientFactory.cs +++ /dev/null @@ -1,87 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright © Reimers.dk 2014 -// This source is subject to the Microsoft Public License (Ms-PL). -// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details. -// All other rights reserved. -// -// -// Defines the FakeAsyncRestClientFactory type. -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace Linq2Rest.Reactive.Tests.Fakes -{ - using System; - using System.IO; - using System.Threading; - using System.Threading.Tasks; - - public class FakeAsyncRestClientFactory : IAsyncRestClientFactory - { - private readonly string _response = "[]"; - private readonly int _responseDelay; - - public FakeAsyncRestClientFactory() - : this(-1) - { - } - - public FakeAsyncRestClientFactory(string response) - : this(-1) - { - _response = response; - } - - public FakeAsyncRestClientFactory(int responseDelay) - { - _responseDelay = responseDelay; - } - - public Uri ServiceBase - { - get - { - return new Uri("http://localhost"); - } - } - - public IAsyncRestClient Create(Uri source) - { - return new FakeAsyncResultClient(_responseDelay, _response); - } - - public void SetMethod(HttpMethod method) - { - } - - public void SetInput(Stream input) - { - } - - private class FakeAsyncResultClient : IAsyncRestClient - { - private readonly string _response; - private readonly int _responseDelay; - - public FakeAsyncResultClient(int responseDelay, string response) - { - _responseDelay = responseDelay; - _response = response; - } - - public Task Download() - { - return Task.Factory.StartNew(() => - { - if (_responseDelay > 0) - { - Thread.Sleep(_responseDelay); - } - - return _response.ToStream(); - }); - } - } - } -} \ No newline at end of file diff --git a/Linq2Rest.Reactive.Tests/Fakes/FakeItem.cs b/Linq2Rest.Reactive.Tests/Fakes/FakeItem.cs deleted file mode 100644 index 419446e..0000000 --- a/Linq2Rest.Reactive.Tests/Fakes/FakeItem.cs +++ /dev/null @@ -1,47 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright © Reimers.dk 2014 -// This source is subject to the Microsoft Public License (Ms-PL). -// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details. -// All other rights reserved. -// -// -// Defines the FakeItem type. -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace Linq2Rest.Reactive.Tests.Fakes -{ - using System.Collections.Generic; - using System.Runtime.Serialization; - using System.Xml.Serialization; - - [DataContract] - public class FakeItem - { - [DataMember(Name = "Text")] - private string _stringValue; - - [XmlElement(ElementName = "Number")] - public int IntValue { get; set; } - - public double DoubleValue { get; set; } - - public string StringValue - { - get - { - return _stringValue; - } - - set - { - _stringValue = value; - } - } - - public IList Children { get; set; } - - public IList MoreChildren { get; set; } - } -} diff --git a/Linq2Rest.Reactive.Tests/Fakes/NorthwindCustomer.cs b/Linq2Rest.Reactive.Tests/Fakes/NorthwindCustomer.cs deleted file mode 100644 index 4f8257a..0000000 --- a/Linq2Rest.Reactive.Tests/Fakes/NorthwindCustomer.cs +++ /dev/null @@ -1,37 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright © Reimers.dk 2014 -// This source is subject to the Microsoft Public License (Ms-PL). -// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details. -// All other rights reserved. -// -// -// Defines the NorthwindCustomer type. -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace Linq2Rest.Reactive.Tests.Fakes -{ - public class NorthwindCustomer - { - public string CustomerID { get; set; } - - public string CompanyName { get; set; } - - public string ContactName { get; set; } - - public string ContactTitle { get; set; } - - public string Address { get; set; } - - public string City { get; set; } - - public string Region { get; set; } - - public string PostalCode { get; set; } - - public string Country { get; set; } - - public string Phone { get; set; } - } -} \ No newline at end of file diff --git a/Linq2Rest.Reactive.Tests/Fakes/ODataResponse.cs b/Linq2Rest.Reactive.Tests/Fakes/ODataResponse.cs deleted file mode 100644 index 451da62..0000000 --- a/Linq2Rest.Reactive.Tests/Fakes/ODataResponse.cs +++ /dev/null @@ -1,24 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright © Reimers.dk 2014 -// This source is subject to the Microsoft Public License (Ms-PL). -// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details. -// All other rights reserved. -// -// -// Defines the ODataResponse type. -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace Linq2Rest.Reactive.Tests.Fakes -{ - using System.Collections.Generic; - using System.Runtime.Serialization; - - [DataContract] - public class ODataResponse - { - [DataMember(Name = "value")] - public List Results { get; set; } - } -} \ No newline at end of file diff --git a/Linq2Rest.Reactive.Tests/Fakes/ODataResult.cs b/Linq2Rest.Reactive.Tests/Fakes/ODataResult.cs deleted file mode 100644 index 58eeaf2..0000000 --- a/Linq2Rest.Reactive.Tests/Fakes/ODataResult.cs +++ /dev/null @@ -1,24 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright © Reimers.dk 2014 -// This source is subject to the Microsoft Public License (Ms-PL). -// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details. -// All other rights reserved. -// -// -// Defines the ODataResult type. -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace Linq2Rest.Reactive.Tests.Fakes -{ - using System.Collections.Generic; - using System.Runtime.Serialization; - - [DataContract] - public class ODataResult - { - [DataMember(Name = "value")] - public List Results { get; set; } - } -} \ No newline at end of file diff --git a/Linq2Rest.Reactive.Tests/Fakes/TestComplexSerializer.cs b/Linq2Rest.Reactive.Tests/Fakes/TestComplexSerializer.cs deleted file mode 100644 index b2126d9..0000000 --- a/Linq2Rest.Reactive.Tests/Fakes/TestComplexSerializer.cs +++ /dev/null @@ -1,46 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright © Reimers.dk 2014 -// This source is subject to the Microsoft Public License (Ms-PL). -// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details. -// All other rights reserved. -// -// -// Defines the TestComplexSerializer type. -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace Linq2Rest.Reactive.Tests.Fakes -{ - using System; - using System.Collections.Generic; - using System.IO; - using System.Runtime.Serialization.Json; - using Linq2Rest.Provider; - - public class TestComplexSerializer : ISerializer - { - private readonly DataContractJsonSerializer _innerListSerializer = new DataContractJsonSerializer(typeof(List)); - private readonly DataContractJsonSerializer _innerSerializer = new DataContractJsonSerializer(typeof(FakeItem)); - - public FakeItem Deserialize(Stream input) - { - return (FakeItem)_innerSerializer.ReadObject(input); - } - - public IEnumerable DeserializeList(Stream input) - { - return (List)_innerListSerializer.ReadObject(input); - } - - public Stream Serialize(FakeItem item) - { - var stream = new MemoryStream(); - _innerSerializer.WriteObject(stream, item); - stream.Flush(); - stream.Position = 0; - - return stream; - } - } -} \ No newline at end of file diff --git a/Linq2Rest.Reactive.Tests/Fakes/TestODataSerializer.cs b/Linq2Rest.Reactive.Tests/Fakes/TestODataSerializer.cs deleted file mode 100644 index 6c4334d..0000000 --- a/Linq2Rest.Reactive.Tests/Fakes/TestODataSerializer.cs +++ /dev/null @@ -1,48 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright © Reimers.dk 2014 -// This source is subject to the Microsoft Public License (Ms-PL). -// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details. -// All other rights reserved. -// -// -// Defines the TestODataSerializer type. -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace Linq2Rest.Reactive.Tests.Fakes -{ - using System; - using System.Collections.Generic; - using System.IO; - using System.Linq; - using System.Runtime.Serialization.Json; - using Linq2Rest.Provider; - - public class TestODataSerializer : ISerializer - { - private readonly DataContractJsonSerializer _innerSerializer = new DataContractJsonSerializer(typeof(ODataResponse)); - - public T Deserialize(Stream input) - { - var response = (ODataResponse)_innerSerializer.ReadObject(input); - return response.Results.FirstOrDefault(); - } - - public IEnumerable DeserializeList(Stream input) - { - var response = (ODataResponse)_innerSerializer.ReadObject(input); - return response.Results; - } - - public Stream Serialize(T item) - { - var stream = new MemoryStream(); - _innerSerializer.WriteObject(stream, item); - stream.Flush(); - stream.Position = 0; - - return stream; - } - } -} \ No newline at end of file diff --git a/Linq2Rest.Reactive.Tests/Fakes/TestODataSerializerFactory.cs b/Linq2Rest.Reactive.Tests/Fakes/TestODataSerializerFactory.cs deleted file mode 100644 index a5a3b01..0000000 --- a/Linq2Rest.Reactive.Tests/Fakes/TestODataSerializerFactory.cs +++ /dev/null @@ -1,29 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright © Reimers.dk 2014 -// This source is subject to the Microsoft Public License (Ms-PL). -// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details. -// All other rights reserved. -// -// -// Defines the TestODataSerializerFactory type. -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace Linq2Rest.Reactive.Tests.Fakes -{ - using Linq2Rest.Provider; - - public class TestODataSerializerFactory : ISerializerFactory - { - public ISerializer Create() - { - return new TestODataSerializer(); - } - - public ISerializer Create() - { - return Create(); - } - } -} \ No newline at end of file diff --git a/Linq2Rest.Reactive.Tests/Fakes/TestSerializer.cs b/Linq2Rest.Reactive.Tests/Fakes/TestSerializer.cs deleted file mode 100644 index f7646ad..0000000 --- a/Linq2Rest.Reactive.Tests/Fakes/TestSerializer.cs +++ /dev/null @@ -1,46 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright © Reimers.dk 2014 -// This source is subject to the Microsoft Public License (Ms-PL). -// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details. -// All other rights reserved. -// -// -// Defines the TestSerializer type. -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace Linq2Rest.Reactive.Tests.Fakes -{ - using System; - using System.Collections.Generic; - using System.IO; - using System.Runtime.Serialization.Json; - using Linq2Rest.Provider; - - public class TestSerializer : ISerializer - { - private readonly DataContractJsonSerializer _innerListSerializer = new DataContractJsonSerializer(typeof(List)); - private readonly DataContractJsonSerializer _innerSerializer = new DataContractJsonSerializer(typeof(T)); - - public T Deserialize(Stream input) - { - return (T)_innerSerializer.ReadObject(input); - } - - public IEnumerable DeserializeList(Stream input) - { - return (List)_innerListSerializer.ReadObject(input); - } - - public Stream Serialize(T item) - { - var stream = new MemoryStream(); - _innerSerializer.WriteObject(stream, item); - stream.Flush(); - stream.Position = 0; - - return stream; - } - } -} \ No newline at end of file diff --git a/Linq2Rest.Reactive.Tests/Fakes/TestSerializerFactory.cs b/Linq2Rest.Reactive.Tests/Fakes/TestSerializerFactory.cs deleted file mode 100644 index a47f911..0000000 --- a/Linq2Rest.Reactive.Tests/Fakes/TestSerializerFactory.cs +++ /dev/null @@ -1,205 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright © Reimers.dk 2014 -// This source is subject to the Microsoft Public License (Ms-PL). -// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details. -// All other rights reserved. -// -// -// Defines the TestSerializerFactory type. -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace Linq2Rest.Reactive.Tests.Fakes -{ - using System; - using System.Collections; - using System.Collections.Generic; - using System.Diagnostics.Contracts; - using System.IO; - using System.Linq; - using System.Linq.Expressions; - using System.Reflection; - using System.Web.Script.Serialization; - using Linq2Rest.Provider; - - public class TestSerializerFactory : ISerializerFactory - { - private readonly IMemberNameResolver _memberNameResolver; - - public TestSerializerFactory() - { - _memberNameResolver = new MemberNameResolver(); - } - - public ISerializer Create() - { - if (typeof(T) == typeof(FakeItem)) - { - return new TestComplexSerializer() as ISerializer; - } - - return new TestSerializer(); - } - - public ISerializer Create() - { - if (typeof(T).IsAnonymousType()) - { - return new RuntimeAnonymousTypeSerializer(_memberNameResolver); - } - return Create(); - } - } - - /// - /// Serializes simples annymous type structures. - /// - /// The to serialize. - /// The to load alias data from. - public class RuntimeAnonymousTypeSerializer : ISerializer - { - private readonly IMemberNameResolver _nameResolver; - private readonly Type _sourceType = typeof(TSource); - private readonly Type _elementType = typeof(T); - private readonly Type _deserializedType = typeof(Dictionary); - private readonly JavaScriptSerializer _innerSerializer = new JavaScriptSerializer(); - - /// - /// a - /// - /// The used to resolve name aliasing. - public RuntimeAnonymousTypeSerializer(IMemberNameResolver nameResolver) - { - _nameResolver = nameResolver; - } - - /// - /// Deserializes a single item. - /// - /// The serialized item. - /// An instance of the serialized item. - public T Deserialize(Stream input) - { - var content = new StreamReader(input).ReadToEnd(); - - var dictionary = (Dictionary)_innerSerializer.DeserializeObject(content); - var selectorFunction = CreateSelector(dictionary); - return selectorFunction(dictionary); - } - - /// - /// Deserializes a list of items. - /// - /// The serialized items. - /// An list of the serialized items. - public IEnumerable DeserializeList(Stream input) - { - var content = new StreamReader(input).ReadToEnd(); - return ReadToAnonymousType(content); - } - - /// - /// Serializes the passed item into a . - /// - /// The item to serialize. - /// A representation of the item. - public Stream Serialize(T item) - { - var ms = new MemoryStream(); - var writer = new StreamWriter(ms); - writer.Write(_innerSerializer.Serialize(item)); - writer.Flush(); - ms.Position = 0; - return ms; - } - - private static Type GetMemberType(MemberInfo member) - { - switch (member.MemberType) - { - case MemberTypes.Field: - return ((FieldInfo)member).FieldType; - case MemberTypes.Method: - return ((MethodInfo)member).ReturnType; - case MemberTypes.Property: - return ((PropertyInfo)member).PropertyType; - default: - throw new ArgumentOutOfRangeException(); - } - } - - private IEnumerable ReadToAnonymousType(string response) - { - var deserializeObject = _innerSerializer.DeserializeObject(response); - var enumerable = deserializeObject as IEnumerable; - - if (enumerable == null) - { - return new List(); - } - - var objectEnumerable = enumerable.OfType>().ToArray(); - - if (objectEnumerable.Length == 0) - { - return new List(); - } - - var first = objectEnumerable[0]; - - var selectorFunction = CreateSelector(first); - - Contract.Assume(selectorFunction != null, "Compiled above."); - - return objectEnumerable.Select(selectorFunction).ToList(); - } - - private Func CreateSelector(IDictionary deserializedObject) - { - var objectParameter = Expression.Parameter(typeof(object), "x"); - var keys = deserializedObject.Keys; - - var properties = typeof(T).GetProperties(); - - var bindings = (from key in keys - let alias = _nameResolver.ResolveAlias(_sourceType, key) - where properties.Any(p => p.Name == alias.Name) - let member = _nameResolver.ResolveName(alias) - let memberType = GetMemberType(alias) - let arguments = new[] { Expression.Constant(member) } - let indexExpression = Expression.MakeIndex( - Expression.Convert(objectParameter, _deserializedType), - _deserializedType.GetProperty("Item"), - arguments) - select Expression.Convert( - Expression.Call( - AnonymousTypeSerializerHelper.InnerChangeTypeMethod, - indexExpression, - Expression.Constant(memberType)), - memberType)) - .ToArray(); - - var constructorInfo = _elementType.GetConstructors().FirstOrDefault(); - - var selector = - Expression.Lambda>( - Expression.New(constructorInfo, bindings), objectParameter); - var selectorFunction = selector.Compile(); - - return selectorFunction; - } - - [ContractInvariantMethod] - private void Invariants() - { - Contract.Invariant(_innerSerializer != null); - Contract.Invariant(_elementType != null); - } - } - - internal static class AnonymousTypeSerializerHelper - { - public static readonly MethodInfo InnerChangeTypeMethod = typeof(Convert).GetMethod("ChangeType", new[] { typeof(object), typeof(Type) }); - } -} \ No newline at end of file diff --git a/Linq2Rest.Reactive.Tests/Linq2Rest.Reactive.Tests.Net45.csproj b/Linq2Rest.Reactive.Tests/Linq2Rest.Reactive.Tests.Net45.csproj deleted file mode 100644 index 406ed4c..0000000 --- a/Linq2Rest.Reactive.Tests/Linq2Rest.Reactive.Tests.Net45.csproj +++ /dev/null @@ -1,197 +0,0 @@ - - - - Debug - AnyCPU - 8.0.30703 - 2.0 - {388C7FD1-1BB7-426C-9DCC-44949BA804E2} - Library - Properties - Linq2Rest.Reactive.Tests - Linq2Rest.Reactive.Tests - v4.5 - 512 - 1 - ..\ - true - - - - true - full - false - bin\v4.5\Debug\ - obj\v4.5 - DEBUG;TRACE - prompt - 4 - False - True - True - False - False - False - False - False - False - False - False - False - False - False - False - True - False - False - False - True - False - False - False - - - - - - - False - Full - DoNotBuild - 0 - false - - - pdbonly - true - bin\v4.5\Release\ - obj\v4.5 - TRACE - prompt - 4 - True - True - True - False - False - False - False - False - False - False - False - False - False - False - False - True - False - False - False - True - False - False - False - - - - - - - False - None - DoNotBuild - 0 - false - True - True - True - False - True - False - True - True - - False - False - True - - - false - - - false - - - ..\Linq2Rest.snk - - - - ..\packages\Moq.4.2.1402.2112\lib\net40\Moq.dll - - - ..\packages\NUnit.2.6.3\lib\nunit.framework.dll - - - - - - ..\packages\Rx-Core.2.2.4\lib\net45\System.Reactive.Core.dll - - - ..\packages\Rx-Interfaces.2.2.4\lib\net45\System.Reactive.Interfaces.dll - - - ..\packages\Rx-Linq.2.2.4\lib\net45\System.Reactive.Linq.dll - - - ..\packages\Rx-PlatformServices.2.2.4\lib\net45\System.Reactive.PlatformServices.dll - - - ..\packages\Rx-Providers.2.2.4\lib\net45\System.Reactive.Providers.dll - - - - - - - - Code - - - - - - - - - - - - - - - - - - - - - - - - - {f7d2a74e-5a11-4fc9-8aa4-d0d3431bbf40} - Linq2Rest.Net45 - - - - - - \ No newline at end of file diff --git a/Linq2Rest.Reactive.Tests/Linq2Rest.Reactive.Tests.csproj b/Linq2Rest.Reactive.Tests/Linq2Rest.Reactive.Tests.csproj deleted file mode 100644 index ae5da12..0000000 --- a/Linq2Rest.Reactive.Tests/Linq2Rest.Reactive.Tests.csproj +++ /dev/null @@ -1,204 +0,0 @@ - - - - Debug - AnyCPU - 8.0.30703 - 2.0 - {8D19958C-1F14-436E-AE2C-ECD8E58998EB} - Library - Properties - Linq2Rest.Reactive.Tests - Linq2Rest.Reactive.Tests - v4.0 - 512 - 1 - ..\ - true - - - true - full - false - bin\v4.0\Debug\ - obj\v4.0 - DEBUG;TRACE - prompt - 4 - False - True - True - False - False - False - False - False - False - False - False - False - False - False - False - True - False - False - False - True - False - False - False - - - - - - - False - Full - DoNotBuild - 0 - - - pdbonly - true - bin\v4.0\Release\ - obj\v4.0 - TRACE - prompt - 4 - True - True - True - False - False - False - False - False - False - False - False - False - False - False - False - True - False - False - False - True - False - False - False - - - - - - - False - None - DoNotBuild - 0 - True - True - True - False - True - False - True - True - - False - False - True - - - false - - - ..\Linq2Rest.snk - - - false - - - - ..\packages\Moq.4.2.1402.2112\lib\net40\Moq.dll - True - - - ..\packages\NUnit.2.6.3\lib\nunit.framework.dll - True - - - - - - ..\packages\Rx-Core.2.2.4\lib\net40\System.Reactive.Core.dll - True - - - ..\packages\Rx-Interfaces.2.2.4\lib\net40\System.Reactive.Interfaces.dll - True - - - ..\packages\Rx-Linq.2.2.4\lib\net40\System.Reactive.Linq.dll - True - - - ..\packages\Rx-PlatformServices.2.2.4\lib\net40\System.Reactive.PlatformServices.dll - True - - - ..\packages\Rx-Providers.2.2.4\lib\net40\System.Reactive.Providers.dll - True - - - - - - - - Code - - - - - - - - - - - - - - - - - - - - - - - - {B0AF1230-AF6C-4305-B4D1-7172A3BE9715} - Linq2Rest.Reactive - - - {FEF6620A-87C8-43B4-92BD-5FAAD183CBC7} - Linq2Rest - - - - - - \ No newline at end of file diff --git a/Linq2Rest.Reactive.Tests/ODataCustomerServiceTests.cs b/Linq2Rest.Reactive.Tests/ODataCustomerServiceTests.cs deleted file mode 100644 index 91d56c1..0000000 --- a/Linq2Rest.Reactive.Tests/ODataCustomerServiceTests.cs +++ /dev/null @@ -1,99 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright © Reimers.dk 2014 -// This source is subject to the Microsoft Public License (Ms-PL). -// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details. -// All other rights reserved. -// -// -// Defines the ODataCustomerServiceTests type. -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace Linq2Rest.Reactive.Tests -{ - using System; - using System.Reactive.Linq; - using System.Threading; - using Linq2Rest.Reactive.Implementations; - using Linq2Rest.Reactive.Tests.Fakes; - using NUnit.Framework; - - [TestFixture] - public class ODataCustomerServiceTests - { - private RestObservable _customerContext; - - [TestFixtureSetUp] - public void FixtureSetup() - { - // Tests against the sample OData service. - _customerContext = new RestObservable( - new AsyncJsonRestClientFactory(new Uri("http://services.odata.org/Northwind/Northwind.svc/Customers")), - new TestODataSerializerFactory()); - } - - [Test] - public void WhenRequestingCustomerByNameEndsWithThenLoadsCustomer() - { - var waitHandle = new ManualResetEvent(false); - - _customerContext - .Create() - .Where(x => x.CompanyName.EndsWith("Futterkiste")) - .Subscribe( - x => waitHandle.Set(), - e => Console.WriteLine(e.Message), - () => waitHandle.Set()); - - var result = waitHandle.WaitOne(5000); - - Assert.True(result); - } - - [Test] - public void WhenRequestingCustomerByNameLengthThenLoadsCustomer() - { - var waitHandle = new ManualResetEvent(false); - - _customerContext - .Create() - .Where(x => x.CompanyName.Length > 10) - .Subscribe(x => waitHandle.Set(), () => waitHandle.Set()); - - var result = waitHandle.WaitOne(2000); - - Assert.True(result); - } - - [Test] - public void WhenRequestingCustomerByNameStartsWithThenLoadsCustomer() - { - var waitHandle = new ManualResetEvent(false); - - _customerContext - .Create() - .Where(x => x.CompanyName.StartsWith("Alfr")) - .Subscribe(x => waitHandle.Set(), () => waitHandle.Set()); - - var result = waitHandle.WaitOne(2000); - - Assert.True(result); - } - - [Test] - public void WhenRequestingCustomerByNameThenLoadsCustomer() - { - var waitHandle = new ManualResetEvent(false); - - _customerContext - .Create() - .Where(x => x.CompanyName.IndexOf("Alfreds") > -1) - .Subscribe(x => waitHandle.Set(), () => waitHandle.Set()); - - var result = waitHandle.WaitOne(2000); - - Assert.True(result); - } - } -} \ No newline at end of file diff --git a/Linq2Rest.Reactive.Tests/Properties/AssemblyInfo.cs b/Linq2Rest.Reactive.Tests/Properties/AssemblyInfo.cs deleted file mode 100644 index f501b0f..0000000 --- a/Linq2Rest.Reactive.Tests/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,42 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright © Reimers.dk 2014 -// This source is subject to the Microsoft Public License (Ms-PL). -// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details. -// All other rights reserved. -// -// -// AssemblyInfo.cs -// -// -------------------------------------------------------------------------------------------------------------------- - -using System.Reflection; -using System.Runtime.InteropServices; - -[assembly: AssemblyTitle("Linq2Rest.Rx.Tests")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Linq2Rest.Rx.Tests")] -[assembly: AssemblyCopyright("Copyright © 2012")] -[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("4fdf2a24-a930-4a1a-a891-def18656b1db")] - -// 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("4.1.0.0")] -[assembly: AssemblyFileVersion("4.1.0.0")] diff --git a/Linq2Rest.Reactive.Tests/RequestTests.cs b/Linq2Rest.Reactive.Tests/RequestTests.cs deleted file mode 100644 index ffa5394..0000000 --- a/Linq2Rest.Reactive.Tests/RequestTests.cs +++ /dev/null @@ -1,316 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright © Reimers.dk 2014 -// This source is subject to the Microsoft Public License (Ms-PL). -// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details. -// All other rights reserved. -// -// -// Defines the RequestTests type. -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace Linq2Rest.Reactive.Tests -{ - using System; - using System.IO; - using System.Linq; - using System.Linq.Expressions; - using System.Reactive.Linq; - using System.Threading; - using System.Threading.Tasks; - using Linq2Rest.Reactive.Tests.Fakes; - using Moq; - using NUnit.Framework; - - [TestFixture] - public class RequestTests - { - private Mock _mockRestClient; - private Mock _mockClientFactory; - private RestObservable _observable; - - [SetUp] - public void Setup() - { - _mockRestClient = new Mock(); - _mockRestClient.Setup(x => x.Download()) - .Returns(() => Task.Factory.StartNew(() => "[]".ToStream())); - - _mockClientFactory = new Mock(); - _mockClientFactory.SetupGet(x => x.ServiceBase).Returns(new Uri("http://localhost")); - _mockClientFactory.Setup(x => x.Create(It.IsAny())).Returns(_mockRestClient.Object); - - _observable = new RestObservable(_mockClientFactory.Object, new TestSerializerFactory()); - } - - [Test] - public void WhenAnyExpressionRequiresEagerEvaluationThenCallsRestServiceWithExistingFilterParameter() - { - var waitHandle = new ManualResetEvent(false); - - _observable - .Create() - .Where(x => x.IntValue <= 3) - .Any(x => x.DoubleValue.Equals(3d)) - .Subscribe(x => waitHandle.Set(), () => waitHandle.Set()); - - waitHandle.WaitOne(2000); - - var requestUri = new Uri("http://localhost/?$filter=Number+le+3"); - _mockClientFactory.Verify(x => x.Create(requestUri), Times.Once()); - } - - [Test] - public void WhenApplyingAllQueryThenCallsRestServiceWithFilterParameter() - { - var waitHandle = new ManualResetEvent(false); - - _observable - .Create() - .Where(x => x.Children.All(y => y.Text == "blah")) - .Subscribe(x => waitHandle.Set(), () => waitHandle.Set()); - - waitHandle.WaitOne(2000); - - var requestUri = new Uri("http://localhost/?$filter=Children%2fall(y:+y%2fText+eq+'blah')"); - _mockClientFactory.Verify(x => x.Create(requestUri), Times.Once()); - } - - [Test] - public void WhenApplyingAnyQueryThenCallsRestServiceWithFilterParameter() - { - var waitHandle = new ManualResetEvent(false); - - _observable - .Create() - .Where(x => x.Children.Any(y => y.Text == "blah")) - .Subscribe(x => waitHandle.Set(), () => waitHandle.Set()); - - waitHandle.WaitOne(2000); - - var requestUri = new Uri("http://localhost/?$filter=Children%2fany(y:+y%2fText+eq+'blah')"); - _mockClientFactory.Verify(x => x.Create(requestUri), Times.Once()); - } - - [Test] - public void WhenApplyingNestedAllQueryThenCallsRestServiceWithFilterParameter() - { - var waitHandle = new ManualResetEvent(false); - - _observable - .Create() - .Where(x => x.Children.All(y => y.Descendants.Any(z => z.Text == "blah"))) - .Subscribe(x => waitHandle.Set(), () => waitHandle.Set()); - - waitHandle.WaitOne(2000); - - var requestUri = new Uri("http://localhost/?$filter=Children%2fall(y:+y%2fDescendants%2fany(z:+z%2fText+eq+'blah'))"); - _mockClientFactory.Verify(x => x.Create(requestUri), Times.Once()); - } - - [Test] - public void WhenApplyingProjectionThenCallsRestServiceWithExistingFilterParameter() - { - var waitHandle = new ManualResetEvent(false); - - _observable - .Create() - .Select(x => new { x.StringValue, x.IntValue }) - .Subscribe(x => waitHandle.Set(), e => - { - Console.WriteLine(e.Message); - waitHandle.Set(); - }, () => waitHandle.Set()); - - waitHandle.WaitOne(); - - var requestUri = new Uri("http://localhost/?$select=StringValue,Number"); - _mockClientFactory.Verify(x => x.Create(requestUri), Times.Once()); - } - - [Test] - public void WhenApplyingQueryThenCallsRestServiceOnce() - { - var waitHandle = new ManualResetEvent(false); - - _observable - .Create() - .Where(x => x.IntValue <= 3) - .Subscribe(x => waitHandle.Set(), () => waitHandle.Set()); - - waitHandle.WaitOne(); - - _mockClientFactory.Verify(x => x.Create(It.IsAny()), Times.Once()); - } - - [Test] - public void WhenApplyingQueryWithMultipleFiltersThenCallsRestServiceWithSingleFilterParameter() - { - var waitHandle = new ManualResetEvent(false); - - _observable - .Create() - .Where(x => x.IntValue <= 3) - .Where(x => x.StringValue == "blah") - .Subscribe(x => waitHandle.Set(), () => waitHandle.Set()); - - waitHandle.WaitOne(); - - var requestUri = new Uri("http://localhost/?$filter=(Number+le+3)+and+(StringValue+eq+'blah')"); - _mockClientFactory.Verify(x => x.Create(requestUri), Times.Once()); - } - - [Test] - public void WhenApplyingQueryWithNoFilterThenCallsRestServiceOnce() - { - var waitHandle = new ManualResetEvent(false); - - _observable - .Create() - .Subscribe(x => waitHandle.Set(), () => waitHandle.Set()); - - waitHandle.WaitOne(); - - var requestUri = new Uri("http://localhost/"); - _mockClientFactory.Verify(x => x.Create(requestUri), Times.Once()); - } - - [Test] - public void WhenApplyingSkipFilterThenCallsRestServiceWithExistingFilterParameter() - { - var waitHandle = new ManualResetEvent(false); - - _observable - .Create() - .Skip(1) - .Subscribe(x => waitHandle.Set(), () => waitHandle.Set()); - - waitHandle.WaitOne(); - - var requestUri = new Uri("http://localhost/?$skip=1"); - _mockClientFactory.Verify(x => x.Create(requestUri), Times.Once()); - } - - [Test] - public void WhenApplyingTakeFilterThenCallsRestServiceWithExistingFilterParameter() - { - var waitHandle = new ManualResetEvent(false); - - _observable - .Create() - .Take(1) - - .Subscribe(x => waitHandle.Set(), () => waitHandle.Set()); - - waitHandle.WaitOne(); - - var requestUri = new Uri("http://localhost/?$top=1"); - _mockClientFactory.Verify(x => x.Create(requestUri), Times.Once()); - } - - [Test] - public void WhenGroupByExpressionRequiresEagerEvaluationThenCallsRestServiceWithExistingFilterParameter() - { - var waitHandle = new ManualResetEvent(false); - - _observable - .Create() - .Where(x => x.IntValue <= 3) - .GroupBy(x => x.StringValue) - .Subscribe( - x => waitHandle.Set(), - e => - { - Console.WriteLine(e.Message); - Console.WriteLine(e.StackTrace); - waitHandle.Set(); - }, - () => waitHandle.Set()); - - waitHandle.WaitOne(); - - var requestUri = new Uri("http://localhost/?$filter=Number+le+3"); - _mockClientFactory.Verify(x => x.Create(requestUri), Times.Once()); - } - - [Test] - public void WhenMainExpressionIsContainedInIsTrueExpressionThenUsesOperandExpression() - { - var waitHandle = new ManualResetEvent(false); - - var parameter = Expression.Parameter(typeof(FakeItem), "x"); - var trueExpression = - Expression.IsTrue( - Expression.LessThanOrEqual(Expression.Property(parameter, "IntValue"), Expression.Constant(3))); - - _observable - .Create() - .Where(Expression.Lambda>(trueExpression, parameter)) - .Subscribe(x => waitHandle.Set(), () => waitHandle.Set()); - - waitHandle.WaitOne(); - - var requestUri = new Uri("http://localhost/?$filter=Number+le+3"); - _mockClientFactory.Verify(x => x.Create(requestUri), Times.Once()); - } - - [Test] - public void WhenQueryIncludesFinalEffectsThenInvokesSideEffect() - { - _mockRestClient.Setup(x => x.Download()) - .Returns(() => Task.Factory.StartNew(() => "[{\"DoubleValue\":1.2}]".ToStream())); - var waitHandle = new ManualResetEvent(false); - var action = new Action(() => waitHandle.Set()); - var mockObserver = new Mock>(); - - _observable - .Create() - .Take(1) - .Finally(action) - .Subscribe(mockObserver.Object); - - var result = waitHandle.WaitOne(2000); - - Assert.True(result); - } - - [Test] - public void WhenQueryIncludesSideEffectsThenCallsRestServiceWithExistingFilterParameter() - { - var waitHandle = new ManualResetEvent(false); - var action = new Action(x => { }); - - _observable - .Create() - .Take(1) - .Do(action) - .Subscribe(x => waitHandle.Set(), () => waitHandle.Set()); - - waitHandle.WaitOne(); - - var requestUri = new Uri("http://localhost/?$top=1"); - _mockClientFactory.Verify(x => x.Create(requestUri), Times.Once()); - } - - [Test] - public void WhenQueryIncludesSideEffectsThenInvokesSideEffect() - { - _mockRestClient.Setup(x => x.Download()) - .Returns(() => Task.Factory.StartNew(() => "[{\"DoubleValue\":1.2}]".ToStream())); - var waitHandle = new ManualResetEvent(false); - var action = new Action(x => waitHandle.Set()); - var mockObserver = new Mock>(); - - _observable - .Create() - .Take(1) - .Do(action) - .Subscribe(mockObserver.Object); - - var result = waitHandle.WaitOne(2000); - - Assert.True(result); - } - } -} diff --git a/Linq2Rest.Reactive.Tests/RestObservableTests.cs b/Linq2Rest.Reactive.Tests/RestObservableTests.cs deleted file mode 100644 index 8078f8e..0000000 --- a/Linq2Rest.Reactive.Tests/RestObservableTests.cs +++ /dev/null @@ -1,285 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright © Reimers.dk 2014 -// This source is subject to the Microsoft Public License (Ms-PL). -// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details. -// All other rights reserved. -// -// -// Defines the RestObservableTests type. -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace Linq2Rest.Reactive.Tests -{ - using System; - using System.IO; - using System.Reactive.Concurrency; - using System.Reactive.Linq; - using System.Threading; - using System.Threading.Tasks; - using Linq2Rest.Reactive.Tests.Fakes; - using Moq; - using NUnit.Framework; - - [TestFixture] - public class RestObservableTests - { - [Test] - public void CanCreateQbservable() - { - Assert.DoesNotThrow( - () => new RestObservable( - new FakeAsyncRestClientFactory(), - new TestSerializerFactory())); - } - - [Test] - public void CanCreateSubscription() - { - var waitHandle = new ManualResetEvent(false); - var observable = new RestObservable(new FakeAsyncRestClientFactory(), new TestSerializerFactory()); - - observable - .Create() - .SubscribeOn(NewThreadScheduler.Default) - .Where(x => x.StringValue == "blah") - .ObserveOn(Scheduler.Default) - .Subscribe( - x => - { - Console.WriteLine(Thread.CurrentThread.ManagedThreadId); - waitHandle.Set(); - }, - () => - { - Console.WriteLine(Thread.CurrentThread.ManagedThreadId); - waitHandle.Set(); - }); - - var result = waitHandle.WaitOne(5000); - - Assert.True(result); - } - - [Test] - public void WhenDisposingSubscriptionThenDoesNotExecute() - { - var completedWaitHandle = new ManualResetEvent(false); - var onnextWaitHandle = new ManualResetEvent(false); - - var observable = new RestObservable(new FakeAsyncRestClientFactory(2000), new TestSerializerFactory()); - var subscription = observable - .Create() - .Where(x => x.StringValue == "blah") - .ObserveOn(Scheduler.CurrentThread) - .Subscribe(x => onnextWaitHandle.Set(), () => completedWaitHandle.Set()); - - subscription.Dispose(); - - var next = onnextWaitHandle.WaitOne(2000); - var completed = completedWaitHandle.WaitOne(2000); - - Assert.False(next); - Assert.True(completed); - } - - [Test] - public void WhenGettingSingleThenReturnsResults() - { - var observable = new RestObservable(new FakeAsyncRestClientFactory(), new TestSerializerFactory()); - var result = observable - .Create() - .Where(x => x.StringValue == "blah") - .SingleOrDefault(); - - Assert.Null(result); - } - - [Test] - public void WhenGroupingSourceThenReturnsResults() - { - var waitHandle = new ManualResetEvent(false); - var observable = new RestObservable(new FakeAsyncRestClientFactory(), new TestSerializerFactory()); - observable - .Create() - .Where(x => x.StringValue == "blah") - .GroupBy(x => x.StringValue) - .Subscribe( - x => { }, - e => - { - Console.WriteLine(e.Message); - Console.WriteLine(e.StackTrace); - waitHandle.Set(); - }, - () => waitHandle.Set()); - - var result = waitHandle.WaitOne(); - - Assert.True(result); - } - - [Test] - public void WhenInvokingDeleteThenHttpMethodIsSetOnClientFactory() - { - var waitHandle = new ManualResetEvent(false); - - var mockRestClient = new Mock(); - mockRestClient.Setup(x => x.Download()) - .Returns(() => Task.Factory.StartNew(() => "[]".ToStream())); - - var mockClientFactory = new Mock(); - mockClientFactory.SetupGet(x => x.ServiceBase).Returns(new Uri("http://localhost")); - mockClientFactory.Setup(x => x.Create(It.IsAny())).Returns(mockRestClient.Object); - - new RestObservable(mockClientFactory.Object, new TestSerializerFactory()) - .Create() - .Delete() - .Where(x => x.StringValue == "blah") - .Subscribe(x => waitHandle.Set(), () => waitHandle.Set()); - - waitHandle.WaitOne(5000); - - mockClientFactory.Verify(x => x.SetMethod(HttpMethod.Delete)); - } - - [Test] - public void WhenInvokingPostThenHttpMethodIsSetOnClientFactory() - { - var waitHandle = new ManualResetEvent(false); - - var mockRestClient = new Mock(); - mockRestClient.Setup(x => x.Download()) - .Returns(() => Task.Factory.StartNew(() => "[]".ToStream())); - - var mockClientFactory = new Mock(); - mockClientFactory.SetupGet(x => x.ServiceBase).Returns(new Uri("http://localhost")); - mockClientFactory.Setup(x => x.Create(It.IsAny())).Returns(mockRestClient.Object); - - new RestObservable(mockClientFactory.Object, new TestSerializerFactory()) - .Create() - .Post(() => 1) - .Where(x => x.StringValue == "blah") - .Subscribe(x => waitHandle.Set(), () => waitHandle.Set()); - - waitHandle.WaitOne(5000); - - mockClientFactory.Verify(x => x.SetMethod(HttpMethod.Post)); - } - - [Test] - public void WhenInvokingPutThenHttpMethodIsSetOnClientFactory() - { - var waitHandle = new ManualResetEvent(false); - - var mockRestClient = new Mock(); - mockRestClient.Setup(x => x.Download()) - .Returns(() => Task.Factory.StartNew(() => "[]".ToStream())); - - var mockClientFactory = new Mock(); - mockClientFactory.SetupGet(x => x.ServiceBase).Returns(new Uri("http://localhost")); - mockClientFactory.Setup(x => x.Create(It.IsAny())).Returns(mockRestClient.Object); - - new RestObservable(mockClientFactory.Object, new TestSerializerFactory()) - .Create() - .Put(() => 1) - .Where(x => x.StringValue == "blah") - .Subscribe(x => waitHandle.Set(), () => waitHandle.Set()); - - waitHandle.WaitOne(5000); - - mockClientFactory.Verify(x => x.SetMethod(HttpMethod.Put)); - } - - [Test] - public void WhenInvokingThenCallsRestClient() - { - var waitHandle = new ManualResetEvent(false); - - var mockRestClient = new Mock(); - mockRestClient.Setup(x => x.Download()) - .Returns(() => Task.Factory.StartNew(() => "[]".ToStream())); - - var mockClientFactory = new Mock(); - mockClientFactory.SetupGet(x => x.ServiceBase).Returns(new Uri("http://localhost")); - mockClientFactory.Setup(x => x.Create(It.IsAny())).Returns(mockRestClient.Object); - - new RestObservable(mockClientFactory.Object, new TestSerializerFactory()) - .Create() - .Where(x => x.StringValue == "blah") - .Subscribe(x => waitHandle.Set(), () => waitHandle.Set()); - - waitHandle.WaitOne(5000); - - mockRestClient.Verify(x => x.Download()); - } - - [Test] - public void WhenInvokingWithExpandThenCallsRestClient() - { - var waitHandle = new ManualResetEvent(false); - - var mockRestClient = new Mock(); - mockRestClient.Setup(x => x.Download()) - .Returns(() => Task.Factory.StartNew(() => "[]".ToStream())); - - var mockClientFactory = new Mock(); - mockClientFactory.SetupGet(x => x.ServiceBase).Returns(new Uri("http://localhost")); - mockClientFactory.Setup(x => x.Create(It.IsAny())).Returns(mockRestClient.Object); - - new RestObservable(mockClientFactory.Object, new TestSerializerFactory()) - .Create() - .Expand(i => i.Children, i => i.MoreChildren) - .Subscribe(x => waitHandle.Set(), () => waitHandle.Set()); - - waitHandle.WaitOne(5000); - - mockRestClient.Verify(x => x.Download()); - } - - [Test] - public void WhenObservingOnDifferentSchedulerThenInvocationHappensOnDifferentThread() - { - var testThreadId = Thread.CurrentThread.ManagedThreadId; - - var waitHandle = new ManualResetEvent(false); - var observable = new RestObservable(new FakeAsyncRestClientFactory(), new TestSerializerFactory()); - observable - .Create() - .Where(x => x.StringValue == "blah") - .ObserveOn(Scheduler.Default) - .Subscribe( - x => - { - }, - () => - { - var observerThreadId = Thread.CurrentThread.ManagedThreadId; - if (observerThreadId != testThreadId) - { - waitHandle.Set(); - } - }); - - var result = waitHandle.WaitOne(2000); - - Assert.True(result); - } - - [Test] - public void WhenResultReturnedThenCompletesSubscription() - { - var waitHandle = new ManualResetEvent(false); - var observable = new RestObservable(new FakeAsyncRestClientFactory(), new TestSerializerFactory()); - var subscription = observable - .Create() - .Where(x => x.StringValue == "blah") - .Subscribe(x => { }, () => waitHandle.Set()); - - var result = waitHandle.WaitOne(); - - Assert.True(result); - } - } -} \ No newline at end of file diff --git a/Linq2Rest.Reactive.Tests/Settings.StyleCop b/Linq2Rest.Reactive.Tests/Settings.StyleCop deleted file mode 100644 index f8a65f2..0000000 --- a/Linq2Rest.Reactive.Tests/Settings.StyleCop +++ /dev/null @@ -1,6 +0,0 @@ - - - Linked - ..\SolutionSettings.StyleCop - - \ No newline at end of file diff --git a/Linq2Rest.Reactive.Tests/TriggeredRestObservableTests.cs b/Linq2Rest.Reactive.Tests/TriggeredRestObservableTests.cs deleted file mode 100644 index b6240ca..0000000 --- a/Linq2Rest.Reactive.Tests/TriggeredRestObservableTests.cs +++ /dev/null @@ -1,99 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright © Reimers.dk 2014 -// This source is subject to the Microsoft Public License (Ms-PL). -// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details. -// All other rights reserved. -// -// -// Defines the TriggeredRestObservableTests type. -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace Linq2Rest.Reactive.Tests -{ - using System; - using System.IO; - using System.Reactive; - using System.Reactive.Concurrency; - using System.Reactive.Linq; - using System.Threading; - using System.Threading.Tasks; - using Linq2Rest.Reactive.Tests.Fakes; - using Moq; - using NUnit.Framework; - - [TestFixture] - public class TriggeredRestObservableTests - { - [Test] - public void WhenDisposingPollSubscriptionThenCompletes() - { - var waitHandle = new ManualResetEvent(false); - var factory = new FakeAsyncRestClientFactory("[{\"Text\":\"blah\", \"Number\":1}]"); - var observable = new RestObservable(factory, new TestSerializerFactory()); - var subscription = observable - .Poll(Observable.Interval(TimeSpan.FromSeconds(0.5)).Select(x => Unit.Default)) - .Where(x => x.StringValue == "blah") - .Subscribe(x => { }, () => waitHandle.Set()); - - Task.Factory.StartNew( - () => - { - Thread.Sleep(1000); - subscription.Dispose(); - }); - - var result = waitHandle.WaitOne(2000); - - Assert.True(result); - - subscription.Dispose(); - } - - [Test] - public void WhenInvokingThenCallsRestClient() - { - var waitHandle = new ManualResetEvent(false); - var mockRestClient = new Mock(); - mockRestClient.Setup(x => x.Download()) - .Returns(() => Task.Factory.StartNew(() => "[]".ToStream())); - - var mockClientFactory = new Mock(); - mockClientFactory.SetupGet(x => x.ServiceBase).Returns(new Uri("http://localhost")); - mockClientFactory.Setup(x => x.Create(It.IsAny())) - .Callback(Console.WriteLine) - .Returns(mockRestClient.Object); - - var subscription = new RestObservable(mockClientFactory.Object, new TestSerializerFactory()) - .Poll(Observable.Repeat(Unit.Default, 2)) - .Where(x => x.IntValue == 2) - .Subscribe(x => { }, () => waitHandle.Set()); - - waitHandle.WaitOne(2000); - - mockClientFactory.Verify(x => x.Create(It.IsAny()), Times.Exactly(2)); - - subscription.Dispose(); - } - - [Test] - public void WhenObservablePollsThenDoesNotComplete() - { - var waitHandle = new ManualResetEvent(false); - var factory = new FakeAsyncRestClientFactory("[{\"Text\":\"blah\", \"Number\":1}]"); - var observable = new RestObservable(factory, new TestSerializerFactory()); - var subscription = observable - .Poll(Observable.Interval(TimeSpan.FromSeconds(0.5)).Select(x => Unit.Default)) - .ObserveOn(TaskPoolScheduler.Default) - .Where(x => x.StringValue == "blah") - .Subscribe(x => { }, () => waitHandle.Set()); - - var result = waitHandle.WaitOne(2000); - - Assert.False(result); - - subscription.Dispose(); - } - } -} \ No newline at end of file diff --git a/Linq2Rest.Reactive.Tests/packages.config b/Linq2Rest.Reactive.Tests/packages.config deleted file mode 100644 index 773ef6f..0000000 --- a/Linq2Rest.Reactive.Tests/packages.config +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/Linq2Rest.Reactive.WP7Sample/App.xaml b/Linq2Rest.Reactive.WP7Sample/App.xaml deleted file mode 100644 index 90df09f..0000000 --- a/Linq2Rest.Reactive.WP7Sample/App.xaml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/Linq2Rest.Reactive.WP7Sample/App.xaml.cs b/Linq2Rest.Reactive.WP7Sample/App.xaml.cs deleted file mode 100644 index a7a4734..0000000 --- a/Linq2Rest.Reactive.WP7Sample/App.xaml.cs +++ /dev/null @@ -1,148 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright © Reimers.dk 2012 -// This source is subject to the Microsoft Public License (Ms-PL). -// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details. -// All other rights reserved. -// -// -// Defines the App type. -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace Linq2Rest.Reactive.WP8.Sample -{ - using System.Diagnostics; - using System.Threading; - using System.Windows; - using System.Windows.Navigation; - using System.Windows.Threading; - using Microsoft.Phone.Controls; - using Microsoft.Phone.Shell; - - public partial class App : Application - { - // Avoid double-initialization - private bool _phoneApplicationInitialized = false; - - /// - /// Initializes a new instance of the class. - /// - public App() - { - SynchronizationContext.SetSynchronizationContext(new DispatcherSynchronizationContext()); - - // Global handler for uncaught exceptions. - UnhandledException += Application_UnhandledException; - - // Standard Silverlight initialization - InitializeComponent(); - - // Phone-specific initialization - InitializePhoneApplication(); - - // Show graphics profiling information while debugging. - if (Debugger.IsAttached) - { - // Display the current frame rate counters. - Current.Host.Settings.EnableFrameRateCounter = true; - - // Show the areas of the app that are being redrawn in each frame. - // Application.Current.Host.Settings.EnableRedrawRegions = true; - - // Enable non-production analysis visualization mode, - // which shows areas of a page that are handed off to GPU with a colored overlay. - // Application.Current.Host.Settings.EnableCacheVisualization = true; - - // Disable the application idle detection by setting the UserIdleDetectionMode property of the - // application's PhoneApplicationService object to Disabled. - // Caution:- Use this under debug mode only. Application that disables user idle detection will continue to run - // and consume battery power when the user is not using the phone. - PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled; - } - } - - /// - /// Provides easy access to the root frame of the Phone Application. - /// - /// The root frame of the Phone Application. - public PhoneApplicationFrame RootFrame { get; private set; } - - // Code to execute when the application is launching (eg, from Start) - // This code will not execute when the application is reactivated - private void Application_Launching(object sender, LaunchingEventArgs e) - { - } - - // Code to execute when the application is activated (brought to foreground) - // This code will not execute when the application is first launched - private void Application_Activated(object sender, ActivatedEventArgs e) - { - } - - // Code to execute when the application is deactivated (sent to background) - // This code will not execute when the application is closing - private void Application_Deactivated(object sender, DeactivatedEventArgs e) - { - } - - // Code to execute when the application is closing (eg, user hit Back) - // This code will not execute when the application is deactivated - private void Application_Closing(object sender, ClosingEventArgs e) - { - } - - // Code to execute if a navigation fails - private void RootFrame_NavigationFailed(object sender, NavigationFailedEventArgs e) - { - if (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(); - } - } - - // Do not add any additional code to this method - private void InitializePhoneApplication() - { - if (_phoneApplicationInitialized) - { - return; - } - - // Create the frame but don't set it as RootVisual yet; this allows the splash - // screen to remain active until the application is ready to render. - RootFrame = new PhoneApplicationFrame(); - RootFrame.Navigated += CompleteInitializePhoneApplication; - - // Handle navigation failures - RootFrame.NavigationFailed += RootFrame_NavigationFailed; - - // Ensure we don't initialize again - _phoneApplicationInitialized = true; - } - - // Do not add any additional code to this method - private void CompleteInitializePhoneApplication(object sender, NavigationEventArgs e) - { - // Set the root visual to allow the application to render - if (RootVisual != RootFrame) - { - RootVisual = RootFrame; - } - - // Remove this handler since it is no longer needed - RootFrame.Navigated -= CompleteInitializePhoneApplication; - } - } -} \ No newline at end of file diff --git a/Linq2Rest.Reactive.WP7Sample/ApplicationIcon.png b/Linq2Rest.Reactive.WP7Sample/ApplicationIcon.png deleted file mode 100644 index 5859393..0000000 Binary files a/Linq2Rest.Reactive.WP7Sample/ApplicationIcon.png and /dev/null differ diff --git a/Linq2Rest.Reactive.WP7Sample/Background.png b/Linq2Rest.Reactive.WP7Sample/Background.png deleted file mode 100644 index e46f21d..0000000 Binary files a/Linq2Rest.Reactive.WP7Sample/Background.png and /dev/null differ diff --git a/Linq2Rest.Reactive.WP7Sample/Linq2Rest.Reactive.WP8.Sample.csproj b/Linq2Rest.Reactive.WP7Sample/Linq2Rest.Reactive.WP8.Sample.csproj deleted file mode 100644 index 1a18745..0000000 --- a/Linq2Rest.Reactive.WP7Sample/Linq2Rest.Reactive.WP8.Sample.csproj +++ /dev/null @@ -1,174 +0,0 @@ - - - - Debug - AnyCPU - 10.0.20506 - 2.0 - {EC6D6A2B-62D4-4161-BBFF-B72CEDA2EE71} - {C089C8C0-30E0-4E22-80C0-CE093F111A43};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} - Library - Properties - Linq2Rest.Reactive.WP8.Sample - Linq2Rest.Reactive.WP8.Sample - v8.0 - - - - - WindowsPhone - true - - - true - true - Linq2Rest.Reactive.WP8.Sample_Debug_AnyCPU.xap - Properties\AppManifest.xml - Linq2Rest.Reactive.WP8.Sample.App - true - true - ..\ - true - 11.0 - - - true - full - false - Bin\Debug - DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE - true - true - prompt - 4 - false - - - pdbonly - true - Bin\Release - TRACE;SILVERLIGHT;WINDOWS_PHONE - true - true - prompt - 4 - false - - - true - Bin\x86\Debug - DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE - true - full - - - prompt - MinimumRecommendedRules.ruleset - false - - - Bin\x86\Release - TRACE;SILVERLIGHT;WINDOWS_PHONE - true - true - pdbonly - - - prompt - MinimumRecommendedRules.ruleset - - - true - Bin\ARM\Debug - DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE - true - full - - - prompt - MinimumRecommendedRules.ruleset - false - - - Bin\ARM\Release - TRACE;SILVERLIGHT;WINDOWS_PHONE - true - true - pdbonly - - - prompt - MinimumRecommendedRules.ruleset - - - - App.xaml - - - MainPage.xaml - - - - - - - - - - - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - - - - - Designer - - - - - - PreserveNewest - - - PreserveNewest - - - - - - ..\packages\Rx-Core.2.2.4\lib\windowsphone8\System.Reactive.Core.dll - - - ..\packages\Rx-Interfaces.2.2.4\lib\windowsphone8\System.Reactive.Interfaces.dll - - - ..\packages\Rx-Linq.2.2.4\lib\windowsphone8\System.Reactive.Linq.dll - - - ..\packages\Rx-PlatformServices.2.2.4\lib\windowsphone8\System.Reactive.PlatformServices.dll - - - ..\packages\Rx-Providers.2.2.4\lib\windowsphone8\System.Reactive.Providers.dll - - - - - - - - \ No newline at end of file diff --git a/Linq2Rest.Reactive.WP7Sample/MainPage.xaml b/Linq2Rest.Reactive.WP7Sample/MainPage.xaml deleted file mode 100644 index f96a506..0000000 --- a/Linq2Rest.Reactive.WP7Sample/MainPage.xaml +++ /dev/null @@ -1,90 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Linq2Rest.Reactive.WP7Sample/MainPage.xaml.cs b/Linq2Rest.Reactive.WP7Sample/MainPage.xaml.cs deleted file mode 100644 index eed445f..0000000 --- a/Linq2Rest.Reactive.WP7Sample/MainPage.xaml.cs +++ /dev/null @@ -1,50 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright © Reimers.dk 2012 -// This source is subject to the Microsoft Public License (Ms-PL). -// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details. -// All other rights reserved. -// -// -// Defines the MainPage type. -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace Linq2Rest.Reactive.WP8.Sample -{ - using System; - using System.Collections.ObjectModel; - using System.Reactive; - using System.Reactive.Concurrency; - using System.Reactive.Linq; - using System.Threading; - using Linq2Rest.Reactive.WP8.Sample.Models; - using Linq2Rest.Reactive.WP8.Sample.Support; - using Microsoft.Phone.Controls; - - public partial class MainPage : PhoneApplicationPage - { - private readonly IDisposable _nugetObservable; - private readonly ObservableCollection _packageCollection; - - public MainPage() - { - _packageCollection = new ObservableCollection(); - Resources.Add("Packages", _packageCollection); - InitializeComponent(); - var trigger = Observable.FromEventPattern(txtSearch, "TextChanged") - .Throttle(TimeSpan.FromMilliseconds(300)) - .Do(_ => Dispatcher.BeginInvoke(() => _packageCollection.Clear())) - .Select(_ => Unit.Default); - _nugetObservable = new RestObservable( - new AsyncJsonRestClientFactory(new Uri("http://nuget.org/api/v2/Packages")), - new ODataSerializerFactory()) - .Poll(trigger) - .Where(p => p.Id.ToLower() - .Contains(txtSearch.Text)) - .ObserveOn(new SynchronizationContextScheduler(SynchronizationContext.Current)) - .SubscribeOn(new SynchronizationContextScheduler(SynchronizationContext.Current)) - .SubscribeSafe(Observer.Create(_packageCollection.Add)); - } - } -} \ No newline at end of file diff --git a/Linq2Rest.Reactive.WP7Sample/Models/NugetPackage.cs b/Linq2Rest.Reactive.WP7Sample/Models/NugetPackage.cs deleted file mode 100644 index e686d2f..0000000 --- a/Linq2Rest.Reactive.WP7Sample/Models/NugetPackage.cs +++ /dev/null @@ -1,105 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright © Reimers.dk 2012 -// This source is subject to the Microsoft Public License (Ms-PL). -// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details. -// All other rights reserved. -// -// -// Defines the NugetPackage type. -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace Linq2Rest.Reactive.WP8.Sample.Models -{ - using System; - using System.Runtime.Serialization; - - [DataContract] - public class NugetPackage - { - [DataMember] - public string Id { get; set; } - - [DataMember] - public string Version { get; set; } - - [DataMember] - public string Authors { get; set; } - - [DataMember] - public string Copyright { get; set; } - - [DataMember] - public DateTime Created { get; set; } - - [DataMember] - public string Dependencies { get; set; } - - [DataMember] - public string Description { get; set; } - - [DataMember] - public int DownloadCount { get; set; } - - [DataMember] - public string GalleryDetailsUrl { get; set; } - - [DataMember] - public string IconUrl { get; set; } - - [DataMember] - public bool IsLatestVersion { get; set; } - - [DataMember] - public bool IsAbsoluteLatestVersion { get; set; } - - [DataMember] - public bool IsPrerelease { get; set; } - - [DataMember] - public DateTime LastUpdated { get; set; } - - [DataMember] - public DateTime Published { get; set; } - - [DataMember] - public string Language { get; set; } - - [DataMember] - public string LicenseUrl { get; set; } - - [DataMember] - public string PackageHash { get; set; } - - [DataMember] - public string PackageHashAlgorithm { get; set; } - - [DataMember] - public long PackageSize { get; set; } - - [DataMember] - public string ProjectUrl { get; set; } - - [DataMember] - public string ReportAbuseUrl { get; set; } - - [DataMember] - public string ReleaseNotes { get; set; } - - [DataMember] - public bool RequireLicenseAcceptance { get; set; } - - [DataMember] - public string Summary { get; set; } - - [DataMember] - public string Tags { get; set; } - - [DataMember] - public string Title { get; set; } - - [DataMember] - public int VersionDownloadCount { get; set; } - } -} diff --git a/Linq2Rest.Reactive.WP7Sample/Properties/AppManifest.xml b/Linq2Rest.Reactive.WP7Sample/Properties/AppManifest.xml deleted file mode 100644 index a955232..0000000 --- a/Linq2Rest.Reactive.WP7Sample/Properties/AppManifest.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - diff --git a/Linq2Rest.Reactive.WP7Sample/Properties/AssemblyInfo.cs b/Linq2Rest.Reactive.WP7Sample/Properties/AssemblyInfo.cs deleted file mode 100644 index 1300367..0000000 --- a/Linq2Rest.Reactive.WP7Sample/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,43 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright © Reimers.dk 2012 -// This source is subject to the Microsoft Public License (Ms-PL). -// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details. -// All other rights reserved. -// -// -// AssemblyInfo.cs -// -// -------------------------------------------------------------------------------------------------------------------- - -using System.Reflection; -using System.Resources; -using System.Runtime.InteropServices; - -[assembly: AssemblyTitle("Linq2Rest.Reactive.WP7Sample")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Reimers.dk")] -[assembly: AssemblyProduct("Linq2Rest.Reactive.WP7Sample")] -[assembly: AssemblyCopyright("Copyright © Reimers.dk 2012")] -[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("a43d841c-f41e-42eb-8db5-934c1200e39e")] - -// 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("2.2.0")] -[assembly: AssemblyFileVersion("2.2.0")] -[assembly: NeutralResourcesLanguage("en-US")] diff --git a/Linq2Rest.Reactive.WP7Sample/Properties/WMAppManifest.xml b/Linq2Rest.Reactive.WP7Sample/Properties/WMAppManifest.xml deleted file mode 100644 index b48f79b..0000000 --- a/Linq2Rest.Reactive.WP7Sample/Properties/WMAppManifest.xml +++ /dev/null @@ -1,67 +0,0 @@ - - - - - ApplicationIcon.png - - - - - - - - - - - - - - - - - - - - - - - - - Background.png - 0 - Background.png - Linq2Rest.Reactive.WP7Sample - - - - - - - - false - - - - - - - - - - \ No newline at end of file diff --git a/Linq2Rest.Reactive.WP7Sample/SampleDto.cs b/Linq2Rest.Reactive.WP7Sample/SampleDto.cs deleted file mode 100644 index 6f806a9..0000000 --- a/Linq2Rest.Reactive.WP7Sample/SampleDto.cs +++ /dev/null @@ -1,23 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright © Reimers.dk 2012 -// This source is subject to the Microsoft Public License (Ms-PL). -// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details. -// All other rights reserved. -// -// -// Defines the SampleDto type. -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace Linq2Rest.Reactive.WP8.Sample -{ - using System.Runtime.Serialization; - - [DataContract] - public class SampleDto - { - [DataMember] - public string Text { get; set; } - } -} diff --git a/Linq2Rest.Reactive.WP7Sample/Settings.StyleCop b/Linq2Rest.Reactive.WP7Sample/Settings.StyleCop deleted file mode 100644 index f8a65f2..0000000 --- a/Linq2Rest.Reactive.WP7Sample/Settings.StyleCop +++ /dev/null @@ -1,6 +0,0 @@ - - - Linked - ..\SolutionSettings.StyleCop - - \ No newline at end of file diff --git a/Linq2Rest.Reactive.WP7Sample/SplashScreenImage.jpg b/Linq2Rest.Reactive.WP7Sample/SplashScreenImage.jpg deleted file mode 100644 index 353b192..0000000 Binary files a/Linq2Rest.Reactive.WP7Sample/SplashScreenImage.jpg and /dev/null differ diff --git a/Linq2Rest.Reactive.WP7Sample/Support/AsyncJsonRestClientFactory.cs b/Linq2Rest.Reactive.WP7Sample/Support/AsyncJsonRestClientFactory.cs deleted file mode 100644 index 66b786a..0000000 --- a/Linq2Rest.Reactive.WP7Sample/Support/AsyncJsonRestClientFactory.cs +++ /dev/null @@ -1,121 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright © Reimers.dk 2012 -// This source is subject to the Microsoft Public License (Ms-PL). -// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details. -// All other rights reserved. -// -// -// Defines the factory to create a REST client using JSON requests. -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace Linq2Rest.Reactive.WP8.Sample.Support -{ - using System; - using System.IO; - using System.Net; - using System.Threading.Tasks; - - /// - /// Defines the factory to create a REST client using JSON requests. - /// - public class AsyncJsonRestClientFactory : IAsyncRestClientFactory - { - private Stream _input; - private HttpMethod _method; - - /// - /// Initializes a new instance of the class. - /// - /// The base for the REST service. - public AsyncJsonRestClientFactory(Uri serviceBase) - { - ServiceBase = serviceBase; - _method = HttpMethod.Get; - } - - /// - /// Gets the base service address. - /// - public Uri ServiceBase { get; private set; } - - /// - /// Creates an . - /// - /// The to download from. - /// An instance. - public IAsyncRestClient Create(Uri source) - { - return new AsyncJsonRestClient(source, _method, _input); - } - - public void SetMethod(HttpMethod method) - { - _method = method; - } - - public void SetInput(Stream input) - { - _input = input; - } - - private class AsyncJsonRestClient : IAsyncRestClient - { - private readonly Stream _input; - private readonly HttpMethod _method; - private readonly Uri _uri; - - public AsyncJsonRestClient(Uri uri, HttpMethod method, Stream input) - { - _uri = uri; - _method = method; - _input = input; - } - - public Task Download() - { - var request = (HttpWebRequest)WebRequest.Create(_uri); - request.Accept = "application/json"; - request.Method = _method.ToString().ToUpperInvariant(); - if (_method == HttpMethod.Put || _method == HttpMethod.Post) - { - return Task.Factory - .FromAsync( - request.BeginGetRequestStream, - request.EndGetRequestStream, - request) - .ContinueWith(WriteRequestStream) - .ContinueWith>(GetResponse) - .ContinueWith(w => w.Result.Result.GetResponseStream()) - .ContinueWith(s => s.Result); - } - - return Task.Factory - .FromAsync(request.BeginGetResponse, request.EndGetResponse, null) - .ContinueWith(x => x.Result.GetResponseStream()); - } - - private Task GetResponse(Task r) - { - var request = r.Result; - return Task - .Factory - .FromAsync( - request.BeginGetResponse, - request.EndGetResponse, - null); - } - - private HttpWebRequest WriteRequestStream(Task s) - { - var buffer = new byte[_input.Length]; - _input.Read(buffer, 0, buffer.Length); - - var stream = s.Result; - stream.Write(buffer, 0, buffer.Length); - return s.AsyncState as HttpWebRequest; - } - } - } -} \ No newline at end of file diff --git a/Linq2Rest.Reactive.WP7Sample/Support/ODataResponse.cs b/Linq2Rest.Reactive.WP7Sample/Support/ODataResponse.cs deleted file mode 100644 index 89c081d..0000000 --- a/Linq2Rest.Reactive.WP7Sample/Support/ODataResponse.cs +++ /dev/null @@ -1,23 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright © Reimers.dk 2012 -// This source is subject to the Microsoft Public License (Ms-PL). -// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details. -// All other rights reserved. -// -// -// Defines the ODataResponse type. -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace Linq2Rest.Reactive.WP8.Sample.Support -{ - using System.Runtime.Serialization; - - [DataContract] - public class ODataResponse - { - [DataMember(Name = "d")] - public ODataResult Result { get; set; } - } -} \ No newline at end of file diff --git a/Linq2Rest.Reactive.WP7Sample/Support/ODataResult.cs b/Linq2Rest.Reactive.WP7Sample/Support/ODataResult.cs deleted file mode 100644 index 35eab4b..0000000 --- a/Linq2Rest.Reactive.WP7Sample/Support/ODataResult.cs +++ /dev/null @@ -1,24 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright © Reimers.dk 2012 -// This source is subject to the Microsoft Public License (Ms-PL). -// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details. -// All other rights reserved. -// -// -// Defines the ODataResult type. -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace Linq2Rest.Reactive.WP8.Sample.Support -{ - using System.Collections.Generic; - using System.Runtime.Serialization; - - [DataContract] - public class ODataResult - { - [DataMember(Name = "results")] - public List Results { get; set; } - } -} \ No newline at end of file diff --git a/Linq2Rest.Reactive.WP7Sample/Support/ODataSerializer.cs b/Linq2Rest.Reactive.WP7Sample/Support/ODataSerializer.cs deleted file mode 100644 index 067fbdf..0000000 --- a/Linq2Rest.Reactive.WP7Sample/Support/ODataSerializer.cs +++ /dev/null @@ -1,47 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright © Reimers.dk 2012 -// This source is subject to the Microsoft Public License (Ms-PL). -// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details. -// All other rights reserved. -// -// -// Defines the ODataSerializer type. -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace Linq2Rest.Reactive.WP8.Sample.Support -{ - using System.Collections.Generic; - using System.IO; - using System.Linq; - using System.Runtime.Serialization.Json; - using Linq2Rest.Provider; - - public class ODataSerializer : ISerializer - { - private readonly DataContractJsonSerializer _innerSerializer = new DataContractJsonSerializer(typeof(ODataResponse)); - - public T Deserialize(Stream input) - { - var response = (ODataResponse)_innerSerializer.ReadObject(input); - return response.Result.Results.FirstOrDefault(); - } - - public IEnumerable DeserializeList(Stream input) - { - var response = (ODataResponse)_innerSerializer.ReadObject(input); - return response.Result.Results; - } - - public Stream Serialize(T item) - { - var response = new ODataResponse { Result = new ODataResult { Results = new List { item } } }; - var ms = new MemoryStream(); - _innerSerializer.WriteObject(ms, response); - ms.Flush(); - ms.Position = 0; - return ms; - } - } -} \ No newline at end of file diff --git a/Linq2Rest.Reactive.WP7Sample/Support/ODataSerializerFactory.cs b/Linq2Rest.Reactive.WP7Sample/Support/ODataSerializerFactory.cs deleted file mode 100644 index f4f9aa6..0000000 --- a/Linq2Rest.Reactive.WP7Sample/Support/ODataSerializerFactory.cs +++ /dev/null @@ -1,29 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright © Reimers.dk 2012 -// This source is subject to the Microsoft Public License (Ms-PL). -// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details. -// All other rights reserved. -// -// -// Defines the ODataSerializerFactory type. -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace Linq2Rest.Reactive.WP8.Sample.Support -{ - using Linq2Rest.Provider; - - public class ODataSerializerFactory : ISerializerFactory - { - public ISerializer Create() - { - return new ODataSerializer(); - } - - public ISerializer Create() - { - return Create(); - } - } -} \ No newline at end of file diff --git a/Linq2Rest.Reactive.WP7Sample/packages.config b/Linq2Rest.Reactive.WP7Sample/packages.config deleted file mode 100644 index d99fb98..0000000 --- a/Linq2Rest.Reactive.WP7Sample/packages.config +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/Linq2Rest.Reactive.WinPhone/Linq2Rest.Reactive.WP8.csproj b/Linq2Rest.Reactive.WinPhone/Linq2Rest.Reactive.WP8.csproj deleted file mode 100644 index 2238e15..0000000 --- a/Linq2Rest.Reactive.WinPhone/Linq2Rest.Reactive.WP8.csproj +++ /dev/null @@ -1,431 +0,0 @@ - - - - Debug - AnyCPU - 10.0.20506 - 2.0 - {2BE8FC8D-8306-4758-9730-8C29E171692F} - {C089C8C0-30E0-4E22-80C0-CE093F111A43};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} - Library - Properties - Linq2Rest.Reactive - Linq2Rest.Reactive - v8.0 - - - - - WindowsPhone - false - true - true - 1 - ..\ - true - 11.0 - - - true - full - false - bin\wp8\Debug\ - obj\wp8 - bin\wp8\Debug\Linq2Rest.Reactive.xml - TRACE;DEBUG;SILVERLIGHT;WINDOWS_PHONE;WP8 - true - true - prompt - 4 - False - False - True - False - False - False - False - False - False - False - False - False - False - False - False - True - False - False - False - True - False - False - True - - - - - - - False - Full - Build - 0 - ..\Linq2Rest.ruleset - false - - - pdbonly - true - bin\wp8\Release\ - obj\wp8 - bin\wp8\Release\Linq2Rest.Reactive.xml - TRACE;SILVERLIGHT;WINDOWS_PHONE - true - true - prompt - 4 - True - True - True - False - False - False - False - False - False - False - False - False - False - False - False - True - False - False - False - True - False - False - True - - - - - - - False - None - 0 - Build - ..\Linq2Rest.ruleset - true - false - True - True - True - False - True - False - True - True - - False - False - True - - - true - Bin\x86\Debug - DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE - Bin\Debug\Linq2Rest.Reactive.XML - true - full - - - prompt - ..\Linq2Rest.ruleset - false - - - Bin\x86\Release - TRACE;SILVERLIGHT;WINDOWS_PHONE - Bin\Debug\Linq2Rest.Reactive.xml - true - true - true - pdbonly - - - prompt - ..\Linq2Rest.ruleset - - - true - Bin\ARM\Debug - DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE - Bin\Debug\Linq2Rest.Reactive.XML - true - full - - - prompt - ..\Linq2Rest.ruleset - false - - - Bin\ARM\Release - TRACE;SILVERLIGHT;WINDOWS_PHONE - Bin\Debug\Linq2Rest.Reactive.xml - true - true - true - pdbonly - - - prompt - ..\Linq2Rest.ruleset - - - - AsyncExpressionProcessor.cs - - - IAsyncExpressionProcessor.cs - - - IAsyncRestClient.cs - - - IAsyncRestClientFactory.cs - - - Implementations\AsyncJsonRestClientFactory.cs - - - Implementations\AsyncXmlRestClientFactory.cs - - - InnerRestObservableBase.cs - - - InternalObservableExtensions.cs - - - ObservableExtensions.cs - - - ObserverPublisher.cs - - - ReflectionHelper.cs - - - RestObservable.cs - - - InnerRestObservable.cs - - - RestQueryableProvider.cs - - - RestQueryableProviderBase.cs - - - RestSubscription.cs - - - TriggeredRestObservable.cs - - - TriggeredRestQueryableProvider.cs - - - IMemberNameResolver.cs - - - Provider\ExpressionVisitor.cs - - - Provider\IExpressionVisitor.cs - - - Provider\ISerializer.cs - - - Provider\ISerializerFactory.cs - - - Provider\ParameterBuilder.cs - - - Provider\Writers\AnyAllMethodWriter.cs - - - Provider\Writers\BooleanValueWriter.cs - - - Provider\Writers\ByteArrayValueWriter.cs - - - Provider\Writers\ByteValueWriter.cs - - - Provider\Writers\DateTimeOffsetValueWriter.cs - - - Provider\Writers\DateTimeValueWriter.cs - - - Provider\Writers\DecimalValueWriter.cs - - - Provider\Writers\DefaultMethodWriter.cs - - - Provider\Writers\DoubleValueWriter.cs - - - Provider\Writers\EmptyAnyMethodWriter.cs - - - Provider\Writers\EnumValueWriter.cs - - - Provider\Writers\EqualsMethodWriter.cs - - - Provider\Writers\GuidValueWriter.cs - - - Provider\Writers\IMethodCallWriter.cs - - - Provider\Writers\IntegerValueWriter.cs - - - Provider\Writers\IntValueWriter.cs - - - Provider\Writers\IValueWriter.cs - - - Provider\Writers\LongValueWriter.cs - - - Provider\Writers\MathCeilingMethodWriter.cs - - - Provider\Writers\MathFloorMethodWriter.cs - - - Provider\Writers\MathMethodWriter.cs - - - Provider\Writers\MathRoundMethodWriter.cs - - - Provider\Writers\ParameterValueWriter.cs - - - Provider\Writers\RationalValueWriter.cs - - - Provider\Writers\ShortValueWriter.cs - - - Provider\Writers\SingleValueWriter.cs - - - Provider\Writers\StreamValueWriter.cs - - - Provider\Writers\StringContainsMethodWriter.cs - - - Provider\Writers\StringEndsWithMethodWriter.cs - - - Provider\Writers\StringIndexOfMethodWriter.cs - - - Provider\Writers\StringReplaceMethodWriter.cs - - - Provider\Writers\StringStartsWithMethodWriter.cs - - - Provider\Writers\StringSubstringMethodWriter.cs - - - Provider\Writers\StringToLowerMethodWriter.cs - - - Provider\Writers\StringToUpperMethodWriter.cs - - - Provider\Writers\StringTrimMethodWriter.cs - - - Provider\Writers\StringValueWriter.cs - - - Provider\Writers\TimeSpanValueWriter.cs - - - Provider\Writers\UnsignedIntValueWriter.cs - - - Provider\Writers\UnsignedLongValueWriter.cs - - - Provider\Writers\UnsignedShortValueWriter.cs - - - Provider\Writers\ValueWriterBase.cs - - - StringConstants.cs - - - - - - - - - - - - ..\packages\Rx-Core.2.2.4\lib\windowsphone8\System.Reactive.Core.dll - True - - - ..\packages\Rx-Interfaces.2.2.4\lib\windowsphone8\System.Reactive.Interfaces.dll - True - - - ..\packages\Rx-Linq.2.2.4\lib\windowsphone8\System.Reactive.Linq.dll - True - - - ..\packages\Rx-PlatformServices.2.2.4\lib\windowsphone8\System.Reactive.PlatformServices.dll - True - - - ..\packages\Rx-Providers.2.2.4\lib\windowsphone8\System.Reactive.Providers.dll - True - - - - - - - - \ No newline at end of file diff --git a/Linq2Rest.Reactive.WinPhone/MemberNameResolver.cs b/Linq2Rest.Reactive.WinPhone/MemberNameResolver.cs deleted file mode 100644 index b744210..0000000 --- a/Linq2Rest.Reactive.WinPhone/MemberNameResolver.cs +++ /dev/null @@ -1,210 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright © Reimers.dk 2014 -// This source is subject to the Microsoft Public License (Ms-PL). -// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details. -// All other rights reserved. -// -// -// Defines the MemberNameResolver type. -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace Linq2Rest -{ - using System; - using System.Collections.Generic; - using System.Diagnostics.Contracts; - using System.Linq; - using System.Reflection; - using System.Runtime.Serialization; - using System.Xml.Serialization; - - internal class MemberNameResolver : IMemberNameResolver - { - private static readonly object LockObject = new object(); - private static readonly Dictionary KnownMemberNames = new Dictionary(); - private static readonly Dictionary KnownAliasNames = new Dictionary(); - - public string ResolveName(Type type, string alias) - { - var members = type.GetMembers(); - var name = members.Select(ResolveName).FirstOrDefault(x => x == alias); - - return name; - } - - public MemberInfo ResolveAlias(Type type, string alias) - { - var key = type.AssemblyQualifiedName + alias; - if (!KnownAliasNames.ContainsKey(key)) - { - lock (LockObject) - { - return KnownAliasNames[key] = ResolveAliasInternal(type, alias); - } - } - - return KnownAliasNames[key]; - } - - public string ResolveName(MemberInfo member) - { - if (!KnownMemberNames.ContainsKey(member)) - { - KnownMemberNames[member] = ResolveNameInternal(member); - } - - var result = KnownMemberNames[member]; - - Contract.Assume(result != null); - - return result; - } - - private static MemberInfo ResolveAliasInternal(Type type, string alias) - { - var member = GetMembers(type) - .Select( - x => - { - var attributes = x.GetCustomAttributes(true); - var dataMember = attributes.OfType() - .FirstOrDefault(); - if (dataMember != null && dataMember.Name == alias) - { - return x; - } - - var xmlElement = attributes.OfType() - .FirstOrDefault(); - if (xmlElement != null && xmlElement.ElementName == alias) - { - return x; - } - - var xmlAttribute = attributes.OfType() - .FirstOrDefault(); - if (xmlAttribute != null && xmlAttribute.AttributeName == alias) - { - return x; - } - - if (x.Name == alias) - { - return x; - } - - return null; - }) - .FirstOrDefault(x => x != null); - - return member; - } - - private static IEnumerable GetMembers(Type type) - { -#if NETFX_CORE - var typeInfo = type.GetTypeInfo(); - if (typeInfo.IsInterface) - { - var propertyInfos = new List(); - - var considered = new List(); - var queue = new Queue(); - considered.Add(type); - queue.Enqueue(typeInfo); - while (queue.Count > 0) - { - var subType = queue.Dequeue(); - foreach (var subInterface in subType.ImplementedInterfaces.Where(x => !considered.Contains(x))) - { - considered.Add(subInterface); - queue.Enqueue(subInterface.GetTypeInfo()); - } - - var typeProperties = subType.DeclaredMembers; - - var newPropertyInfos = typeProperties - .Where(x => !propertyInfos.Contains(x)); - - propertyInfos.InsertRange(0, newPropertyInfos); - } - - return propertyInfos.ToArray(); - } - - return type.GetTypeInfo().DeclaredMembers; -#else - if (type.IsInterface) - { - var propertyInfos = new List(); - - var considered = new List(); - var queue = new Queue(); - considered.Add(type); - queue.Enqueue(type); - while (queue.Count > 0) - { - var subType = queue.Dequeue(); - foreach (var subInterface in subType.GetInterfaces() - .Where(x => !considered.Contains(x))) - { - considered.Add(subInterface); - queue.Enqueue(subInterface); - } - - var typeProperties = subType.GetMembers( - BindingFlags.FlattenHierarchy - | BindingFlags.Public - | BindingFlags.Instance); - - var newPropertyInfos = typeProperties - .Where(x => !propertyInfos.Contains(x)); - - propertyInfos.InsertRange(0, newPropertyInfos); - } - - return propertyInfos.ToArray(); - } - - return type.GetMembers(BindingFlags.FlattenHierarchy | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); -#endif - } - - private static string ResolveNameInternal(MemberInfo member) - { - Contract.Requires(member != null); - - var dataMember = member.GetCustomAttributes(typeof(DataMemberAttribute), true) - .OfType() - .FirstOrDefault(); - - if (dataMember != null && dataMember.Name != null) - { - return dataMember.Name; - } - - var xmlElement = member.GetCustomAttributes(typeof(XmlElementAttribute), true) - .OfType() - .FirstOrDefault(); - - if (xmlElement != null && xmlElement.ElementName != null) - { - return xmlElement.ElementName; - } - - var xmlAttribute = member.GetCustomAttributes(typeof(XmlAttributeAttribute), true) - .OfType() - .FirstOrDefault(); - - if (xmlAttribute != null && xmlAttribute.AttributeName != null) - { - return xmlAttribute.AttributeName; - } - - Contract.Assert(member.Name != null, "Member must have name"); - return member.Name; - } - } -} \ No newline at end of file diff --git a/Linq2Rest.Reactive.WinPhone/Properties/AssemblyInfo.cs b/Linq2Rest.Reactive.WinPhone/Properties/AssemblyInfo.cs deleted file mode 100644 index ab48ac4..0000000 --- a/Linq2Rest.Reactive.WinPhone/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,42 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright © Reimers.dk 2014 -// This source is subject to the Microsoft Public License (Ms-PL). -// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details. -// All other rights reserved. -// -// -// AssemblyInfo.cs -// -// -------------------------------------------------------------------------------------------------------------------- - -using System.Reflection; -using System.Resources; -using System.Runtime.InteropServices; - -[assembly: AssemblyTitle("Linq2Rest.Reactive.WP7")] -[assembly: AssemblyDescription("Generates OData style Rx Observables from LINQ queries.")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Reimers.dk")] -[assembly: AssemblyProduct("Linq2Rest.Reactive")] -[assembly: AssemblyCopyright("Copyright © Reimers.dk 2014")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("b58ad0a7-fcbf-46e7-8a73-7a5aa11c741c")] - -// 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("4.1.0.0")] -[assembly: AssemblyFileVersion("4.1.0.0")] diff --git a/Linq2Rest.Reactive.WinPhone/Provider/ExpressionExtensions.cs b/Linq2Rest.Reactive.WinPhone/Provider/ExpressionExtensions.cs deleted file mode 100644 index aa8971e..0000000 --- a/Linq2Rest.Reactive.WinPhone/Provider/ExpressionExtensions.cs +++ /dev/null @@ -1,75 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright © Reimers.dk 2014 -// This source is subject to the Microsoft Public License (Ms-PL). -// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details. -// All other rights reserved. -// -// -// Defines the ExpressionExtensions type. -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace Linq2Rest.Reactive.Provider -{ - using System; - using System.Diagnostics.Contracts; - using System.Linq; - using System.Reflection; - - internal static class ExpressionExtensions - { - public static Tuple GetNameFromAlias(this IMemberNameResolver memberNameResolver, MemberInfo alias, Type sourceType) - { - Contract.Requires(sourceType != null); - Contract.Requires(alias != null); - Contract.Ensures(Contract.Result>() != null); - -#if !NETFX_CORE - var source = sourceType.GetMembers() -#else - var source = sourceType.GetTypeInfo().DeclaredMembers -#endif - .Select(x => new { Original = x, Name = memberNameResolver.ResolveName(x) }) - .FirstOrDefault(x => x.Name == alias.Name); - - return source != null - ? new Tuple(GetMemberType(source.Original), source.Name) - : new Tuple(GetMemberType(alias), alias.Name); - } - - private static Type GetMemberType(MemberInfo member) - { -#if !NETFX_CORE - switch (member.MemberType) - { - case MemberTypes.Field: - return ((FieldInfo)member).FieldType; - case MemberTypes.Property: - return ((PropertyInfo)member).PropertyType; - case MemberTypes.Method: - return ((MethodInfo)member).ReturnType; - default: - throw new InvalidOperationException(member.MemberType + " is not resolvable"); - } -#else - var fieldInfo = member as FieldInfo; - if (fieldInfo != null) - { - return fieldInfo.FieldType; - } - var methodInfo = member as MethodInfo; - if (methodInfo != null) - { - return methodInfo.ReturnType; - } - var propertyInfo = member as PropertyInfo; - if (propertyInfo != null) - { - return propertyInfo.PropertyType; - } - throw new InvalidOperationException(member + " is not resolvable"); -#endif - } - } -} diff --git a/Linq2Rest.Reactive.WinPhone/Settings.StyleCop b/Linq2Rest.Reactive.WinPhone/Settings.StyleCop deleted file mode 100644 index f8a65f2..0000000 --- a/Linq2Rest.Reactive.WinPhone/Settings.StyleCop +++ /dev/null @@ -1,6 +0,0 @@ - - - Linked - ..\SolutionSettings.StyleCop - - \ No newline at end of file diff --git a/Linq2Rest.Reactive.WinPhone/packages.config b/Linq2Rest.Reactive.WinPhone/packages.config deleted file mode 100644 index d99fb98..0000000 --- a/Linq2Rest.Reactive.WinPhone/packages.config +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/Linq2Rest.Reactive.WinRT.Sample/App.xaml b/Linq2Rest.Reactive.WinRT.Sample/App.xaml deleted file mode 100644 index 2cd65d5..0000000 --- a/Linq2Rest.Reactive.WinRT.Sample/App.xaml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - diff --git a/Linq2Rest.Reactive.WinRT.Sample/App.xaml.cs b/Linq2Rest.Reactive.WinRT.Sample/App.xaml.cs deleted file mode 100644 index d0138fe..0000000 --- a/Linq2Rest.Reactive.WinRT.Sample/App.xaml.cs +++ /dev/null @@ -1,70 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright © Reimers.dk 2012 -// This source is subject to the Microsoft Public License (Ms-PL). -// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details. -// All other rights reserved. -// -// -// Provides application-specific behavior to supplement the default Application class. -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace Linq2Rest.Reactive.WinRT.Sample -{ - using Windows.ApplicationModel; - using Windows.ApplicationModel.Activation; - using Windows.UI.Xaml; - using Windows.UI.Xaml.Controls; - - /// - /// Provides application-specific behavior to supplement the default Application class. - /// - public sealed partial class App : Application - { - /// - /// Initializes a new instance of the class. - /// This is the first line of authored code - /// executed, and as such is the logical equivalent of main() or WinMain(). - /// - public App() - { - InitializeComponent(); - Suspending += OnSuspending; - } - - /// - /// Invoked when the application is launched normally by the end user. Other entry points - /// will be used when the application is launched to open a specific file, to display - /// search results, and so forth. - /// - /// Details about the launch request and process. - protected override void OnLaunched(LaunchActivatedEventArgs args) - { - if (args.PreviousExecutionState == ApplicationExecutionState.Terminated) - { - // TODO: Load state from previously suspended application - } - - // Create a Frame to act navigation context and navigate to the first page - var rootFrame = new Frame(); - rootFrame.Navigate(typeof(BlankPage)); - - // Place the frame in the current Window and ensure that it is active - Window.Current.Content = rootFrame; - Window.Current.Activate(); - } - - /// - /// Invoked when application execution is being suspended. Application state is saved - /// without knowing whether the application will be terminated or resumed with the contents - /// of memory still intact. - /// - /// The source of the suspend request. - /// Details about the suspend request. - private void OnSuspending(object sender, SuspendingEventArgs e) - { - // TODO: Save application state and stop any background activity - } - } -} diff --git a/Linq2Rest.Reactive.WinRT.Sample/Assets/Logo.png b/Linq2Rest.Reactive.WinRT.Sample/Assets/Logo.png deleted file mode 100644 index ebd735a..0000000 Binary files a/Linq2Rest.Reactive.WinRT.Sample/Assets/Logo.png and /dev/null differ diff --git a/Linq2Rest.Reactive.WinRT.Sample/Assets/SmallLogo.png b/Linq2Rest.Reactive.WinRT.Sample/Assets/SmallLogo.png deleted file mode 100644 index 92dd105..0000000 Binary files a/Linq2Rest.Reactive.WinRT.Sample/Assets/SmallLogo.png and /dev/null differ diff --git a/Linq2Rest.Reactive.WinRT.Sample/Assets/SplashScreen.png b/Linq2Rest.Reactive.WinRT.Sample/Assets/SplashScreen.png deleted file mode 100644 index 193187f..0000000 Binary files a/Linq2Rest.Reactive.WinRT.Sample/Assets/SplashScreen.png and /dev/null differ diff --git a/Linq2Rest.Reactive.WinRT.Sample/Assets/StoreLogo.png b/Linq2Rest.Reactive.WinRT.Sample/Assets/StoreLogo.png deleted file mode 100644 index 3765186..0000000 Binary files a/Linq2Rest.Reactive.WinRT.Sample/Assets/StoreLogo.png and /dev/null differ diff --git a/Linq2Rest.Reactive.WinRT.Sample/BlankPage.xaml b/Linq2Rest.Reactive.WinRT.Sample/BlankPage.xaml deleted file mode 100644 index ea2a75f..0000000 --- a/Linq2Rest.Reactive.WinRT.Sample/BlankPage.xaml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - -