41 lines
997 B
C#
41 lines
997 B
C#
using System;
|
|
using Newtonsoft.Json.Linq;
|
|
using ln.types.net;
|
|
|
|
namespace ln.types.json.converter
|
|
{
|
|
public class JSONNetwork4Converter : IJsonConvert
|
|
{
|
|
public JSONNetwork4Converter()
|
|
{
|
|
}
|
|
|
|
public string GetSkyType(Type nativeType)
|
|
{
|
|
if (typeof(Network4).Equals(nativeType))
|
|
return "network4";
|
|
return null;
|
|
}
|
|
|
|
public bool JSON2Value(Type targetType, JToken jToken, ref object value)
|
|
{
|
|
if (typeof(Network4).Equals(targetType))
|
|
{
|
|
value = Network4.Parse(jToken.ToObject<string>());
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public bool Value2JSON(object value, ref JToken jToken)
|
|
{
|
|
if (value is Network4)
|
|
{
|
|
jToken = JToken.FromObject((value as Network4).ToString());
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
}
|