obsolete
This commit is contained in:
parent
83ca421100
commit
4b27c04157
7 changed files with 0 additions and 3217 deletions
|
|
@ -1,99 +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.Json;
|
|
||||||
|
|
||||||
namespace Yavsc.Helpers
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Simple json post method.
|
|
||||||
/// </summary>
|
|
||||||
public class SimpleJsonPostMethod : 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 SimpleJsonPostMethod (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";
|
|
||||||
if (authorizationHeader!=null)
|
|
||||||
request.Headers["Authorization"]=authorizationHeader;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
request.Abort();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Invoke the specified query.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="query">Query.</param>
|
|
||||||
public TAnswer Invoke<TAnswer>(object query)
|
|
||||||
{
|
|
||||||
|
|
||||||
using (Stream streamQuery = request.GetRequestStream()) {
|
|
||||||
using (StreamWriter writer = new StreamWriter(streamQuery)) {
|
|
||||||
writer.Write (JsonConvert.SerializeObject(query));
|
|
||||||
}}
|
|
||||||
TAnswer ans = default (TAnswer);
|
|
||||||
using (WebResponse response = request.GetResponse ()) {
|
|
||||||
using (Stream responseStream = response.GetResponseStream ()) {
|
|
||||||
using (StreamReader rdr = new StreamReader (responseStream)) {
|
|
||||||
ans = (TAnswer) JsonConvert.DeserializeObject<TAnswer> (rdr.ReadToEnd ());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
response.Close();
|
|
||||||
}
|
|
||||||
return ans;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<JsonValue> InvokeJson(object query)
|
|
||||||
{
|
|
||||||
JsonValue jsonDoc=null;
|
|
||||||
using (Stream streamQuery = request.GetRequestStream()) {
|
|
||||||
using (StreamWriter writer = new StreamWriter(streamQuery)) {
|
|
||||||
writer.Write (JsonConvert.SerializeObject(query));
|
|
||||||
}}
|
|
||||||
using (WebResponse response = request.GetResponse ()) {
|
|
||||||
using (Stream stream = response.GetResponseStream ()) {
|
|
||||||
if (stream.Length>0)
|
|
||||||
jsonDoc = await Task.Run (() => JsonObject.Load (stream));
|
|
||||||
}
|
|
||||||
response.Close();
|
|
||||||
}
|
|
||||||
return jsonDoc;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
{
|
|
||||||
"name": "Yavsc.Api",
|
|
||||||
"version": "0.0.0",
|
|
||||||
"devDependencies": {
|
|
||||||
"gulp": "^3.9.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,21 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<PropertyGroup>
|
|
||||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
|
|
||||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
|
|
||||||
<PropertyGroup Label="Globals">
|
|
||||||
<ProjectGuid>5c3248ac-cae0-4324-8a70-08f2dca9fb08</ProjectGuid>
|
|
||||||
<RootNamespace>Yavsc.Api</RootNamespace>
|
|
||||||
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
|
|
||||||
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup>
|
|
||||||
<SchemaVersion>2.0</SchemaVersion>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
|
||||||
<ProduceOutputsOnBuild>True</ProduceOutputsOnBuild>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
|
|
||||||
</Project>
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<PropertyGroup>
|
|
||||||
<ActiveDebugProfile>Démarrer</ActiveDebugProfile>
|
|
||||||
</PropertyGroup>
|
|
||||||
</Project>
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
dnu pack
|
|
||||||
cp -a bin/Debug/*.nupkg ~/Nupkgs
|
|
||||||
(cd ../Yavsc && dnu install Yavsc.Api)
|
|
||||||
(cd ../testOauthClient && dnu install Yavsc.Api)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,30 +0,0 @@
|
||||||
{
|
|
||||||
"version": "1.0.0-*",
|
|
||||||
"description": "Api Class Library",
|
|
||||||
"authors": [
|
|
||||||
"Class Library template"
|
|
||||||
],
|
|
||||||
"tags": [
|
|
||||||
""
|
|
||||||
],
|
|
||||||
"projectUrl": "",
|
|
||||||
"licenseUrl": "",
|
|
||||||
"tooling": {
|
|
||||||
"defaultNamespace": "Yavsc"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"EntityFramework.Commands": "7.0.0-rc1-*",
|
|
||||||
"EntityFramework.Core": "7.0.0-rc1-*",
|
|
||||||
"EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-*",
|
|
||||||
"EntityFramework.Relational": "7.0.0-rc1-*",
|
|
||||||
"Microsoft.AspNet.Identity.EntityFramework": "3.0.0-rc1-*",
|
|
||||||
"Newtonsoft.Json": "9.0.1",
|
|
||||||
"System.Json": "4.0.20126.16343"
|
|
||||||
},
|
|
||||||
"frameworks": {
|
|
||||||
"net451": {
|
|
||||||
"dependencies": {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue