// /** // * File: JSONStringConverter.cs // * Author: haraldwolff // * // * This file and it's content is copyrighted by the Author and / or copyright holder. // * Any use wihtout proper permission is illegal and may lead to legal actions. // * // * // **/ using System; using Newtonsoft.Json.Linq; namespace ln.types.json.converter { public class JSONStringConverter : IJsonConvert { public JSONStringConverter() { } public string GetSkyType(Type nativeType) { if (typeof(string).Equals(nativeType)) return "string"; return null; } public bool JSON2Value(Type targetType, JToken jToken, ref object value) { if (typeof(string).Equals(targetType)) { value = jToken.Value(); return true; } value = null; return false; } public bool Value2JSON(object value, ref JToken jToken) { if (value is string) { jToken = JToken.FromObject(value); return true; } jToken = null; return false; } } }