using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;

namespace memoQSampleCMSConnector
{
	internal static class Helper
	{
		public static Stream GenerateStreamFromString(string s)
		{
			var stream = new MemoryStream();
			var writer = new StreamWriter(stream);
			writer.Write(s);
			writer.Flush();
			stream.Position = 0;
			return stream;
		}

		public static T Deserialize<T>(this string SerializedJSONString)
		{
			dynamic parsedJson = JsonConvert.DeserializeObject(SerializedJSONString);
			var stuff = JsonConvert.DeserializeObject<T>(SerializedJSONString);
			return stuff;
		}

		public static List<T> DeserializeList<T>(this string SerializedJSONString)
		{
			dynamic parsedJson = JsonConvert.DeserializeObject(SerializedJSONString);
			var stuff = JsonConvert.DeserializeObject<List<T>>(SerializedJSONString);
			return stuff;
		}

	
	}
}