refabrique

vnext
Paul Schneider 8 years ago
parent ee4b70f32d
commit 82738899f1
8 changed files with 336 additions and 142 deletions

@ -1,128 +0,0 @@
//
// PostJson.cs
//
// Author:
// Paul Schneider <paulschneider@free.fr>
//
// Copyright (c) 2015 Paul Schneider
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System.Net;
using System.IO;
using System.Threading.Tasks;
using Newtonsoft.Json;
using System;
using System.Diagnostics;
namespace Yavsc.Helpers
{
/// <summary>
/// Simple json post method.
/// </summary>
public class NotSoSimpleJsonPostMethod : IDisposable
{
private HttpWebRequest request = null;
/// <summary>
/// Initializes a new instance of the Yavsc.Helpers.SimpleJsonPostMethod class.
/// </summary>
/// <param name="pathToMethod">Path to method.</param>
public NotSoSimpleJsonPostMethod(string pathToMethod, string authorizationHeader = null)
{
request = (HttpWebRequest)WebRequest.Create(pathToMethod);
request.Method = "POST";
request.Accept = "application/json";
request.ContentType = "application/json";
// request.SendChunked = true;
// request.TransferEncoding = "UTF-8";
request.Headers = new WebHeaderCollection();
if (authorizationHeader != null)
request.Headers["Authorization"] = "Bearer " + authorizationHeader;
}
public void Dispose()
{
request.Abort();
}
/// <summary>
/// Invoke the specified query.
/// </summary>
/// <param name="query">Query.</param>
public async Task<TAnswer> Invoke<TAnswer>(object query)
{
using (Stream streamQuery = await request.GetRequestStreamAsync())
{
using (StreamWriter writer = new StreamWriter(streamQuery))
{
writer.Write(JsonConvert.SerializeObject(query));
}
}
TAnswer ans = default(TAnswer);
using (WebResponse response = await request.GetResponseAsync())
{
using (Stream responseStream = response.GetResponseStream())
{
using (StreamReader rdr = new StreamReader(responseStream))
{
ans = (TAnswer)JsonConvert.DeserializeObject<TAnswer>(rdr.ReadToEnd());
}
}
}
return ans;
}
public async Task<object> InvokeAnonymous(object query)
{
object result = null;
using (Stream streamQuery = await request.GetRequestStreamAsync())
{
using (StreamWriter writer = new StreamWriter(streamQuery))
{
var json = JsonConvert.SerializeObject(query);
writer.Write(json);
}
}
try
{
using (WebResponse response = await request.GetResponseAsync())
{
using (Stream stream = response.GetResponseStream())
{
if (stream.Length > 0)
{
using (var sr = new StreamReader(stream))
{
var json = await sr.ReadToEndAsync();
result = JsonConvert.DeserializeObject(json);
}
}
}
}
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message.ToString());
}
return result;
}
}
}

@ -1,4 +1,22 @@
namespace Yavsc.Models.Identity
// Copyright (C) 2016 Paul Schneider
//
// This file is part of yavsc.
//
// yavsc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 2 of the License, or
// (at your option) any later version.
//
// yavsc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with yavsc. If not, see <http://www.gnu.org/licenses/>.
//
namespace Yavsc.Models.Identity
{
public interface IGCMDeclaration
{

@ -35,7 +35,6 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Compile Include="Helpers\SimpleJsonPostMethod.cs" />
<Compile Include="IAccountBalance.cs" />
<Compile Include="IApplicationUser.cs" />
<Compile Include="IBlog.cs" />
@ -53,22 +52,13 @@
</None>
</ItemGroup>
<ItemGroup>
<Reference Include="Json.NET.Web, Version=1.0.49.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Json.NET.Web.1.0.49\lib\portable45-net45+win8+wpa81\Json.NET.Web.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.8.0.3\lib\portable-net40+sl5+wp80+win8+wpa81\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Folder Include="Helpers\" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
<Import Project="..\packages\Xamarin.Forms.2.0.0.6482\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets" Condition="Exists('..\packages\Xamarin.Forms.2.0.0.6482\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>Ce projet fait référence à des packages NuGet qui sont manquants sur cet ordinateur. Utilisez l'option de restauration des packages NuGet pour les télécharger. Pour plus d'informations, consultez http://go.microsoft.com/fwlink/?LinkID=322105. Le fichier manquant est : {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Xamarin.Forms.2.0.0.6482\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Forms.2.0.0.6482\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

@ -0,0 +1,17 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Yavsc.Client", "Yavsc.Client.csproj", "{67F9D3A8-F71E-4428-913F-C37AE82CDB24}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{67F9D3A8-F71E-4428-913F-C37AE82CDB24}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{67F9D3A8-F71E-4428-913F-C37AE82CDB24}.Debug|Any CPU.Build.0 = Debug|Any CPU
{67F9D3A8-F71E-4428-913F-C37AE82CDB24}.Release|Any CPU.ActiveCfg = Release|Any CPU
{67F9D3A8-F71E-4428-913F-C37AE82CDB24}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal

@ -0,0 +1,23 @@
<Properties>
<MonoDevelop.Ide.Workbench ActiveDocument="IBlog.cs">
<Files>
<File FileName="IBlog.cs" Line="1" Column="1" />
</Files>
<Pads>
<Pad Id="ProjectPad">
<State name="__root__">
<Node name="Yavsc.Client" expanded="True">
<Node name="Yavsc.Client" expanded="True">
<Node name="References" expanded="True" />
</Node>
</Node>
</State>
</Pad>
</Pads>
</MonoDevelop.Ide.Workbench>
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
<MonoDevelop.Ide.DebuggingService.Breakpoints>
<BreakpointStore />
</MonoDevelop.Ide.DebuggingService.Breakpoints>
<MonoDevelop.Ide.DebuggingService.PinnedWatches />
</Properties>

@ -1,5 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Json.NET.Web" version="1.0.49" targetFramework="portable45-net45+win8+wpa81" />
<package id="Newtonsoft.Json" version="8.0.3" targetFramework="portable45-net45+win8+wpa81" />
</packages>

@ -0,0 +1,21 @@
{
"version": "1.0.0-*",
"description": "Yavsc Client Api",
"authors": [
"Paul Schneider"
],
"tags": [
""
],
"projectUrl": "",
"licenseUrl": "",
"tooling": {
"defaultNamespace": "Yavsc"
},
"dependencies": {
"Microsoft.AspNet.SignalR.Client.Portable": "2.0.1"
},
"frameworks": {
"net451": {}
}
}

@ -0,0 +1,255 @@
{
"locked": false,
"version": 2,
"targets": {
".NETFramework,Version=v4.5.1": {
"Microsoft.AspNet.SignalR.Client.Portable/2.0.1": {
"type": "package",
"dependencies": {
"Microsoft.Net.Http": "2.2.18",
"Newtonsoft.Json": "5.0.6"
},
"compile": {
"lib/Microsoft.AspNet.SignalR.Client.dll": {}
},
"runtime": {
"lib/Microsoft.AspNet.SignalR.Client.dll": {}
}
},
"Microsoft.Bcl/1.1.3": {
"type": "package",
"dependencies": {
"Microsoft.Bcl.Build": "1.0.4"
},
"compile": {
"lib/net45/_._": {}
},
"runtime": {
"lib/net45/_._": {}
}
},
"Microsoft.Bcl.Build/1.0.10": {
"type": "package"
},
"Microsoft.Net.Http/2.2.18": {
"type": "package",
"dependencies": {
"Microsoft.Bcl": "1.1.3",
"Microsoft.Bcl.Build": "1.0.10"
},
"frameworkAssemblies": [
"System.Net.Http",
"System.Net.Http.WebRequest"
],
"compile": {
"lib/net45/System.Net.Http.Extensions.dll": {},
"lib/net45/System.Net.Http.Primitives.dll": {}
},
"runtime": {
"lib/net45/System.Net.Http.Extensions.dll": {},
"lib/net45/System.Net.Http.Primitives.dll": {}
}
},
"Newtonsoft.Json/5.0.6": {
"type": "package",
"compile": {
"lib/net45/Newtonsoft.Json.dll": {}
},
"runtime": {
"lib/net45/Newtonsoft.Json.dll": {}
}
}
}
},
"libraries": {
"Microsoft.AspNet.SignalR.Client.Portable/2.0.1": {
"sha512": "IrbSa4V7I+sQbhXiZV+4FFAp0FKZ2Q+zJsbGmBUtixzWVksDytSl5zIOov8dAk6FiZWdvNOUigz8pbOJZL82Lw==",
"type": "package",
"files": [
"Microsoft.AspNet.SignalR.Client.Portable.2.0.1.nupkg.sha512",
"Microsoft.AspNet.SignalR.Client.Portable.nuspec",
"lib/Microsoft.AspNet.SignalR.Client.XML",
"lib/Microsoft.AspNet.SignalR.Client.dll"
]
},
"Microsoft.Bcl/1.1.3": {
"sha512": "NlSh9kk1UyC25O5JJ6vM/omaEirx0Ysep3CMkFNluQbzlIE14eWNa2rHtmFV1NGAsA/OW6MYvuSi7T7aowD2jw==",
"type": "package",
"files": [
"License-RTM.rtf",
"Microsoft.Bcl.1.1.3.nupkg.sha512",
"Microsoft.Bcl.nuspec",
"ReleaseNotes.txt",
"content/net45/_._",
"content/portable-net45+win8+wp8/_._",
"content/sl4/_._",
"content/sl5/_._",
"content/win8/_._",
"content/wp8/_._",
"lib/net40/System.IO.dll",
"lib/net40/System.IO.xml",
"lib/net40/System.Runtime.dll",
"lib/net40/System.Runtime.xml",
"lib/net40/System.Threading.Tasks.dll",
"lib/net40/System.Threading.Tasks.xml",
"lib/net40/ensureRedirect.xml",
"lib/net45/_._",
"lib/portable-net40+sl4+win8+wp71/System.IO.dll",
"lib/portable-net40+sl4+win8+wp71/System.IO.xml",
"lib/portable-net40+sl4+win8+wp71/System.Runtime.dll",
"lib/portable-net40+sl4+win8+wp71/System.Runtime.xml",
"lib/portable-net40+sl4+win8+wp71/System.Threading.Tasks.dll",
"lib/portable-net40+sl4+win8+wp71/System.Threading.Tasks.xml",
"lib/portable-net40+sl4+win8+wp71/ensureRedirect.xml",
"lib/portable-net40+sl4+win8+wp8/System.IO.dll",
"lib/portable-net40+sl4+win8+wp8/System.IO.xml",
"lib/portable-net40+sl4+win8+wp8/System.Runtime.dll",
"lib/portable-net40+sl4+win8+wp8/System.Runtime.xml",
"lib/portable-net40+sl4+win8+wp8/System.Threading.Tasks.dll",
"lib/portable-net40+sl4+win8+wp8/System.Threading.Tasks.xml",
"lib/portable-net40+sl4+win8+wp8/ensureRedirect.xml",
"lib/portable-net40+sl4+win8/System.IO.dll",
"lib/portable-net40+sl4+win8/System.IO.xml",
"lib/portable-net40+sl4+win8/System.Runtime.dll",
"lib/portable-net40+sl4+win8/System.Runtime.xml",
"lib/portable-net40+sl4+win8/System.Threading.Tasks.dll",
"lib/portable-net40+sl4+win8/System.Threading.Tasks.xml",
"lib/portable-net40+sl4+win8/ensureRedirect.xml",
"lib/portable-net40+sl5+win8+wp8/System.IO.dll",
"lib/portable-net40+sl5+win8+wp8/System.IO.xml",
"lib/portable-net40+sl5+win8+wp8/System.Runtime.dll",
"lib/portable-net40+sl5+win8+wp8/System.Runtime.xml",
"lib/portable-net40+sl5+win8+wp8/System.Threading.Tasks.dll",
"lib/portable-net40+sl5+win8+wp8/System.Threading.Tasks.xml",
"lib/portable-net40+sl5+win8+wp8/ensureRedirect.xml",
"lib/portable-net40+win8+wp8/System.IO.dll",
"lib/portable-net40+win8+wp8/System.IO.xml",
"lib/portable-net40+win8+wp8/System.Runtime.dll",
"lib/portable-net40+win8+wp8/System.Runtime.xml",
"lib/portable-net40+win8+wp8/System.Threading.Tasks.dll",
"lib/portable-net40+win8+wp8/System.Threading.Tasks.xml",
"lib/portable-net40+win8+wp8/ensureRedirect.xml",
"lib/portable-net40+win8/System.IO.dll",
"lib/portable-net40+win8/System.IO.xml",
"lib/portable-net40+win8/System.Runtime.dll",
"lib/portable-net40+win8/System.Runtime.xml",
"lib/portable-net40+win8/System.Threading.Tasks.dll",
"lib/portable-net40+win8/System.Threading.Tasks.xml",
"lib/portable-net40+win8/ensureRedirect.xml",
"lib/portable-net45+win8+wp8/_._",
"lib/sl4-windowsphone71/System.IO.dll",
"lib/sl4-windowsphone71/System.IO.xml",
"lib/sl4-windowsphone71/System.Runtime.dll",
"lib/sl4-windowsphone71/System.Runtime.xml",
"lib/sl4-windowsphone71/System.Threading.Tasks.dll",
"lib/sl4-windowsphone71/System.Threading.Tasks.xml",
"lib/sl4-windowsphone71/ensureRedirect.xml",
"lib/sl4/System.IO.dll",
"lib/sl4/System.IO.xml",
"lib/sl4/System.Runtime.dll",
"lib/sl4/System.Runtime.xml",
"lib/sl4/System.Threading.Tasks.dll",
"lib/sl4/System.Threading.Tasks.xml",
"lib/sl5/System.IO.dll",
"lib/sl5/System.IO.xml",
"lib/sl5/System.Runtime.dll",
"lib/sl5/System.Runtime.xml",
"lib/sl5/System.Threading.Tasks.dll",
"lib/sl5/System.Threading.Tasks.xml",
"lib/win8/_._",
"lib/wp8/_._"
]
},
"Microsoft.Bcl.Build/1.0.10": {
"sha512": "JpazBBc/JT6o76Gx2q3mxJlGHfv2gK+GTzaJ+PZjf2XNGQOcajNU4PKJqc0udRwmPunZP5GrMhiWUuDVkabh+A==",
"type": "package",
"files": [
"License-Stable.rtf",
"Microsoft.Bcl.Build.1.0.10.nupkg.sha512",
"Microsoft.Bcl.Build.nuspec",
"content/net40/_._",
"content/netcore45/_._",
"content/portable-net40+win8+sl4+wp71/_._",
"content/sl4-windowsphone71/_._",
"content/sl4/_._",
"tools/Install.ps1",
"tools/Microsoft.Bcl.Build.Tasks.dll",
"tools/Microsoft.Bcl.Build.targets",
"tools/Uninstall.ps1"
]
},
"Microsoft.Net.Http/2.2.18": {
"sha512": "YSmLk8qh917EkfrP5ULL4Nu8mxpoz1fwd5pXwNPUlg4+grLWWpHyYPIMZKjxa7HOR5gsZ8ZfhaSoYzQyom8xUw==",
"type": "package",
"files": [
"License-Stable.rtf",
"Microsoft.Net.Http.2.2.18.nupkg.sha512",
"Microsoft.Net.Http.nuspec",
"lib/net40/System.Net.Http.Extensions.XML",
"lib/net40/System.Net.Http.Extensions.dll",
"lib/net40/System.Net.Http.Primitives.dll",
"lib/net40/System.Net.Http.Primitives.xml",
"lib/net40/System.Net.Http.WebRequest.dll",
"lib/net40/System.Net.Http.WebRequest.xml",
"lib/net40/System.Net.Http.dll",
"lib/net40/System.Net.Http.xml",
"lib/net40/ensureRedirect.xml",
"lib/net45/System.Net.Http.Extensions.XML",
"lib/net45/System.Net.Http.Extensions.dll",
"lib/net45/System.Net.Http.Primitives.dll",
"lib/net45/System.Net.Http.Primitives.xml",
"lib/net45/ensureRedirect.xml",
"lib/portable-net40+sl4+win8+wp71/System.Net.Http.Extensions.XML",
"lib/portable-net40+sl4+win8+wp71/System.Net.Http.Extensions.dll",
"lib/portable-net40+sl4+win8+wp71/System.Net.Http.Primitives.XML",
"lib/portable-net40+sl4+win8+wp71/System.Net.Http.Primitives.dll",
"lib/portable-net40+sl4+win8+wp71/System.Net.Http.dll",
"lib/portable-net40+sl4+win8+wp71/System.Net.Http.xml",
"lib/portable-net40+sl4+win8+wp71/ensureRedirect.xml",
"lib/portable-net45+win8/System.Net.Http.Extensions.XML",
"lib/portable-net45+win8/System.Net.Http.Extensions.dll",
"lib/portable-net45+win8/System.Net.Http.Primitives.dll",
"lib/portable-net45+win8/System.Net.Http.Primitives.xml",
"lib/portable-net45+win8/ensureRedirect.xml",
"lib/sl4-windowsphone71/System.Net.Http.Extensions.XML",
"lib/sl4-windowsphone71/System.Net.Http.Extensions.dll",
"lib/sl4-windowsphone71/System.Net.Http.Primitives.XML",
"lib/sl4-windowsphone71/System.Net.Http.Primitives.dll",
"lib/sl4-windowsphone71/System.Net.Http.dll",
"lib/sl4-windowsphone71/System.Net.Http.xml",
"lib/win8/System.Net.Http.Extensions.XML",
"lib/win8/System.Net.Http.Extensions.dll",
"lib/win8/System.Net.Http.Primitives.dll",
"lib/win8/System.Net.Http.Primitives.xml"
]
},
"Newtonsoft.Json/5.0.6": {
"sha512": "Z594WlU7Wndv4vQxwsS7ym2y2Izsuw5U86UxQbx6YIKIjVju7V7OU4l1QQl5fM9AmPdzWIOxSlonzuQzzulMaw==",
"type": "package",
"files": [
"Newtonsoft.Json.5.0.6.nupkg.sha512",
"Newtonsoft.Json.nuspec",
"lib/net20/Newtonsoft.Json.dll",
"lib/net20/Newtonsoft.Json.xml",
"lib/net35/Newtonsoft.Json.dll",
"lib/net35/Newtonsoft.Json.xml",
"lib/net40/Newtonsoft.Json.dll",
"lib/net40/Newtonsoft.Json.xml",
"lib/net45/Newtonsoft.Json.dll",
"lib/net45/Newtonsoft.Json.xml",
"lib/netcore45/Newtonsoft.Json.dll",
"lib/netcore45/Newtonsoft.Json.xml",
"lib/portable-net40+sl4+wp7+win8/Newtonsoft.Json.dll",
"lib/portable-net40+sl4+wp7+win8/Newtonsoft.Json.xml",
"lib/portable-net45+wp80+win8/Newtonsoft.Json.dll",
"lib/portable-net45+wp80+win8/Newtonsoft.Json.xml"
]
}
},
"projectFileDependencyGroups": {
"": [
"Microsoft.AspNet.SignalR.Client.Portable >= 2.0.1"
],
".NETFramework,Version=v4.5.1": []
}
}
Loading…