changement de candidat à l'investissement
This commit is contained in:
parent
8114c2409c
commit
be3087fff6
351 changed files with 359 additions and 497 deletions
44
ZicMoove/ZicMoove.Droid/Helpers/Settings.cs
Normal file
44
ZicMoove/ZicMoove.Droid/Helpers/Settings.cs
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
|
||||
// Helpers/Settings.cs This file was automatically added when you installed the Settings Plugin. If you are not using a PCL then comment this file back in to use it.
|
||||
using Plugin.Settings;
|
||||
using Plugin.Settings.Abstractions;
|
||||
|
||||
namespace BookAStar.Droid.Helpers
|
||||
{
|
||||
/// <summary>
|
||||
/// This is the Settings static class that can be used in your Core solution or in any
|
||||
/// of your client applications. All settings are laid out the same exact way with getters
|
||||
/// and setters.
|
||||
/// </summary>
|
||||
public static class Settings
|
||||
{
|
||||
private static ISettings AppSettings
|
||||
{
|
||||
get
|
||||
{
|
||||
return CrossSettings.Current;
|
||||
}
|
||||
}
|
||||
|
||||
#region Setting Constants
|
||||
|
||||
private const string SettingsKey = "settings_key";
|
||||
private static readonly string SettingsDefault = string.Empty;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
public static string GeneralSettings
|
||||
{
|
||||
get
|
||||
{
|
||||
return AppSettings.GetValueOrDefault<string>(SettingsKey, SettingsDefault);
|
||||
}
|
||||
set
|
||||
{
|
||||
AppSettings.AddOrUpdateValue<string>(SettingsKey, value);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
121
ZicMoove/ZicMoove.Droid/Helpers/SimpleJsonPostMethod.cs
Normal file
121
ZicMoove/ZicMoove.Droid/Helpers/SimpleJsonPostMethod.cs
Normal file
|
|
@ -0,0 +1,121 @@
|
|||
//
|
||||
// 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.Json;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using BookAStar;
|
||||
|
||||
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 ($"{BasePath}/{pathToMethod}");
|
||||
request.Method = "POST";
|
||||
request.Accept = "application/json";
|
||||
request.ContentType = "application/json";
|
||||
request.SendChunked = true;
|
||||
request.TransferEncoding = "UTF-8";
|
||||
if (authorizationHeader!=null)
|
||||
request.Headers.Add($"Authorization: {authorizationHeader}");
|
||||
}
|
||||
|
||||
public static string BasePath { get; private set; } = Constants.YavscApiUrl;
|
||||
|
||||
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;
|
||||
|
||||
try
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
catch (WebException ex)
|
||||
{
|
||||
// TODO err logging
|
||||
Debug.Print($"Web request failed: {request.ToString()}\n" + ex.ToString());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.Print($"Web request failed: {request.ToString()}\n" + ex.ToString());
|
||||
}
|
||||
|
||||
return jsonDoc;
|
||||
}
|
||||
}
|
||||
}
|
||||
25
ZicMoove/ZicMoove.Droid/Helpers/YavscHelpers.cs
Normal file
25
ZicMoove/ZicMoove.Droid/Helpers/YavscHelpers.cs
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
using System;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Collections.Specialized;
|
||||
using System.Net;
|
||||
using System.Runtime.Serialization.Json;
|
||||
using System.Text;
|
||||
using BookAStar.Model.Auth.Account;
|
||||
|
||||
namespace BookAStar.Droid
|
||||
{
|
||||
|
||||
public static class YavscHelpers
|
||||
{
|
||||
|
||||
public static void SetRegId(this User user, string regId)
|
||||
{
|
||||
if (user.YavscTokens == null)
|
||||
throw new InvalidOperationException();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue