aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.Common/Web/PPCWebClient.cs
blob: 52c9fdef3566b92e6cb3571afd3be2ca117d4046 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.Settings;
using Tango.Web;
using Tango.Web.Security;

namespace Tango.PPC.Common.Web
{
    public class PPCWebClient : PPCWebClientBase
    {
        public PPCWebClient(DeploymentSlot environment) : base(environment)
        {
        }

        public PPCWebClient(DeploymentSlot environment, string token) : base(environment, token)
        {
        }

        public PPCWebClient(string token) : this(SettingsManager.Default.GetOrCreate<PPCSettings>().DeploymentSlot, token)
        {
        }

        public PPCWebClient() : this(null)
        {
        }

        public PPCWebClient(string address, string token) : base(address, token)
        {
        }
    }
}
n>} } /// <summary> /// Deserialize object from a file. /// </summary> /// <typeparam name="T">Type of object to deserialize.</typeparam> /// <param name="filePath">The full path of the data file.</param> /// <returns>The resulting object.</returns> public T DeserializeFromFile<T>(string filePath) { using (FileStream fs = new FileStream(filePath, FileMode.Open)) { return DeserializeFromStream<T>(fs); } } /// <summary> /// Serialize object to stream. /// </summary> /// <typeparam name="T">Type of specified object.</typeparam> /// <param name="obj">The specified object.</param> /// <param name="st">The stream to write.</param> public void SerializeToStream<T>(T obj, Stream st) { JsonSerializer serializer = new JsonSerializer(); using (StreamWriter streamReader = new StreamWriter(st)) { serializer.Serialize(streamReader, obj); } } /// <summary> /// Deserialize object from stream. /// </summary> /// <typeparam name="T">Type of object to deserialize.</typeparam> /// <param name="st">Stream to read from.</param> /// <returns>The resulting object.</returns> public T DeserializeFromStream<T>(Stream st) { JsonSerializer serializer = new JsonSerializer(); T data; using (StreamReader streamReader = new StreamReader(st)) { data = (T)serializer.Deserialize(streamReader, typeof(T)); } return data; } /// <summary> /// Returns the serializer full name. /// </summary> /// <returns></returns> public override string ToString() { return SerializationHelper.GetSerializerName(this); } } }