WIP
parent
86db89b0be
commit
2bc793622a
|
@ -13,13 +13,13 @@ using ln.types.json.converter;
|
|||
using Newtonsoft.Json.Linq;
|
||||
namespace ln.types.json
|
||||
{
|
||||
public class Convert
|
||||
public class JSONConvert
|
||||
{
|
||||
public Convert Fallback { get; private set; }
|
||||
public JSONConvert Fallback { get; private set; }
|
||||
|
||||
List<IJsonConvert> converters = new List<IJsonConvert>();
|
||||
|
||||
public Convert()
|
||||
public JSONConvert()
|
||||
{
|
||||
Fallback = DefaultInstance;
|
||||
if (Fallback == null)
|
||||
|
@ -30,17 +30,17 @@ namespace ln.types.json
|
|||
converters.Add(new JSONTimeSpanConverter());
|
||||
}
|
||||
}
|
||||
public Convert(IEnumerable<IJsonConvert> converters)
|
||||
public JSONConvert(IEnumerable<IJsonConvert> converters)
|
||||
{
|
||||
this.converters.AddRange(converters);
|
||||
}
|
||||
public Convert(Convert fallBack, IEnumerable<IJsonConvert> converters)
|
||||
public JSONConvert(JSONConvert fallBack, IEnumerable<IJsonConvert> converters)
|
||||
:this(converters)
|
||||
{
|
||||
Fallback = fallBack;
|
||||
}
|
||||
|
||||
bool JSON2Value(Type targetType, JToken jToken, ref object value)
|
||||
public bool JSON2Value(Type targetType, JToken jToken, ref object value)
|
||||
{
|
||||
foreach (IJsonConvert convert in converters)
|
||||
{
|
||||
|
@ -54,7 +54,7 @@ namespace ln.types.json
|
|||
return false;
|
||||
}
|
||||
|
||||
bool Value2JSON(object value, ref JToken jToken)
|
||||
public bool Value2JSON(object value, ref JToken jToken)
|
||||
{
|
||||
foreach (IJsonConvert convert in converters)
|
||||
{
|
||||
|
@ -68,7 +68,7 @@ namespace ln.types.json
|
|||
return false;
|
||||
}
|
||||
|
||||
public static Convert DefaultInstance { get; } = new Convert();
|
||||
public static JSONConvert DefaultInstance { get; } = new JSONConvert();
|
||||
|
||||
public static bool ToValue(Type targetType, JToken jToken, ref object value) => DefaultInstance.JSON2Value(targetType, jToken, ref value);
|
||||
public static bool ToJSON(object value, ref JToken jToken) => DefaultInstance.Value2JSON(value, ref jToken);
|
|
@ -106,7 +106,7 @@
|
|||
<Compile Include="btree\BTreeValueList.cs" />
|
||||
<Compile Include="net\MAC.cs" />
|
||||
<Compile Include="net\Endpoint4.cs" />
|
||||
<Compile Include="json\Convert.cs" />
|
||||
<Compile Include="json\JSONConvert.cs" />
|
||||
<Compile Include="json\IJsonConvert.cs" />
|
||||
<Compile Include="json\converter\JSONStringConverter.cs" />
|
||||
<Compile Include="json\converter\JSONNumberConverter.cs" />
|
||||
|
|
Loading…
Reference in New Issue