Remove deprecated Newtonsoft JSON References
parent
356953cad7
commit
cd94cf7201
|
@ -1,6 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
namespace ln.types
|
||||
{
|
||||
public static class JSONConverters
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
// /**
|
||||
// * File: IJsonConvert.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
|
||||
{
|
||||
public interface IJsonConvert
|
||||
{
|
||||
string GetSkyType(Type nativeType);
|
||||
|
||||
bool JSON2Value(Type targetType, JToken jToken,ref object value);
|
||||
bool Value2JSON(object value, ref JToken jToken);
|
||||
}
|
||||
}
|
|
@ -1,105 +0,0 @@
|
|||
// /**
|
||||
// * File: Convert.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 System.Collections.Generic;
|
||||
using ln.types.json.converter;
|
||||
using Newtonsoft.Json.Linq;
|
||||
namespace ln.types.json
|
||||
{
|
||||
public class JSONConvert
|
||||
{
|
||||
public JSONConvert Fallback { get; private set; }
|
||||
|
||||
List<IJsonConvert> converters = new List<IJsonConvert>();
|
||||
|
||||
public JSONConvert()
|
||||
{
|
||||
Fallback = DefaultInstance;
|
||||
if (Fallback == null)
|
||||
{
|
||||
converters.Add(new JSONStringConverter());
|
||||
converters.Add(new JSONNumberConverter());
|
||||
converters.Add(new JSONDateTimeConverter());
|
||||
converters.Add(new JSONTimeSpanConverter());
|
||||
converters.Add(new JSONGuidConverter());
|
||||
converters.Add(new JSONIPv4Converter());
|
||||
converters.Add(new JSONNetwork4Converter());
|
||||
}
|
||||
}
|
||||
public JSONConvert(IEnumerable<IJsonConvert> converters)
|
||||
{
|
||||
this.converters.AddRange(converters);
|
||||
}
|
||||
public JSONConvert(JSONConvert fallBack, IEnumerable<IJsonConvert> converters)
|
||||
:this(converters)
|
||||
{
|
||||
Fallback = fallBack;
|
||||
}
|
||||
|
||||
public string GetSkyType(Type targetType)
|
||||
{
|
||||
foreach (IJsonConvert convert in converters)
|
||||
{
|
||||
string skyType = convert.GetSkyType(targetType);
|
||||
if (skyType != null)
|
||||
return skyType;
|
||||
}
|
||||
if (Fallback != null)
|
||||
return Fallback.GetSkyType(targetType);
|
||||
return null;
|
||||
}
|
||||
|
||||
public T JSON2Value<T>(JToken jToken)
|
||||
{
|
||||
object v = null;
|
||||
if (JSON2Value(typeof(T),jToken,ref v))
|
||||
{
|
||||
if (v is T)
|
||||
{
|
||||
return (T)v;
|
||||
}
|
||||
}
|
||||
throw new FormatException(String.Format("JSON2Value could not convert {0} to Type {1}",jToken.ToString(),typeof(T).FullName));
|
||||
}
|
||||
public bool JSON2Value(Type targetType, JToken jToken, ref object value)
|
||||
{
|
||||
foreach (IJsonConvert convert in converters)
|
||||
{
|
||||
if (convert.JSON2Value(targetType, jToken, ref value))
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Fallback != null)
|
||||
return Fallback.JSON2Value(targetType, jToken, ref value);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool Value2JSON(object value, ref JToken jToken)
|
||||
{
|
||||
foreach (IJsonConvert convert in converters)
|
||||
{
|
||||
if (convert.Value2JSON(value, ref jToken))
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Fallback != null)
|
||||
return Fallback.Value2JSON(value, ref jToken);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
// /**
|
||||
// * File: JSONDateTimeConverter.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 JSONDateTimeConverter : IJsonConvert
|
||||
{
|
||||
public JSONDateTimeConverter()
|
||||
{
|
||||
}
|
||||
|
||||
public string GetSkyType(Type nativeType)
|
||||
{
|
||||
if (typeof(DateTime).Equals(nativeType) || typeof(DateTimeOffset).Equals(nativeType))
|
||||
return "datetime";
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool JSON2Value(Type targetType, JToken jToken, ref object value)
|
||||
{
|
||||
if (typeof(DateTime).Equals(targetType))
|
||||
{
|
||||
value = DateTimeOffset.FromUnixTimeSeconds(jToken.Value<long>()).DateTime;
|
||||
return true;
|
||||
}
|
||||
else if (typeof(DateTimeOffset).Equals(targetType))
|
||||
{
|
||||
value = DateTimeOffset.FromUnixTimeSeconds(jToken.Value<long>());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool Value2JSON(object value, ref JToken jToken)
|
||||
{
|
||||
if (value is DateTime)
|
||||
{
|
||||
jToken = JToken.FromObject(new DateTimeOffset((DateTime)value).ToUnixTimeSeconds());
|
||||
return true;
|
||||
}
|
||||
else if (value is DateTimeOffset)
|
||||
{
|
||||
jToken = JToken.FromObject(((DateTimeOffset)value).ToUnixTimeSeconds());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
using System;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace ln.types.json.converter
|
||||
{
|
||||
public class JSONGuidConverter : IJsonConvert
|
||||
{
|
||||
public JSONGuidConverter()
|
||||
{
|
||||
}
|
||||
|
||||
public string GetSkyType(Type nativeType)
|
||||
{
|
||||
if (typeof(Guid).Equals(nativeType))
|
||||
return "guid";
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool JSON2Value(Type targetType, JToken jToken, ref object value)
|
||||
{
|
||||
if (typeof(Guid).Equals(targetType))
|
||||
{
|
||||
String src = jToken.ToObject<string>();
|
||||
value = Guid.Parse(src);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool Value2JSON(object value, ref JToken jToken)
|
||||
{
|
||||
if (typeof(Guid).Equals(value.GetType()))
|
||||
{
|
||||
jToken = JToken.FromObject(((Guid)value).ToString());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
using System;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using ln.types.net;
|
||||
|
||||
namespace ln.types.json.converter
|
||||
{
|
||||
public class JSONIPv4Converter : IJsonConvert
|
||||
{
|
||||
public JSONIPv4Converter()
|
||||
{
|
||||
}
|
||||
|
||||
public string GetSkyType(Type nativeType)
|
||||
{
|
||||
if (typeof(IPv4).Equals(nativeType))
|
||||
return "ipv4";
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool JSON2Value(Type targetType, JToken jToken, ref object value)
|
||||
{
|
||||
if (typeof(IPv4).Equals(targetType))
|
||||
{
|
||||
value = IPv4.Parse(jToken.ToObject<String>());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool Value2JSON(object value, ref JToken jToken)
|
||||
{
|
||||
if (value is IPv4)
|
||||
{
|
||||
jToken = JToken.FromObject((value as IPv4).ToString());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,123 +0,0 @@
|
|||
// /**
|
||||
// * File: JSONNumberConverter.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 JSONNumberConverter : IJsonConvert
|
||||
{
|
||||
public JSONNumberConverter()
|
||||
{
|
||||
}
|
||||
|
||||
public string GetSkyType(Type nativeType)
|
||||
{
|
||||
if (typeof(short).Equals(nativeType))
|
||||
{
|
||||
return "int";
|
||||
}
|
||||
else if (typeof(ushort).Equals(nativeType))
|
||||
{
|
||||
return "int";
|
||||
}
|
||||
else if (typeof(int).Equals(nativeType))
|
||||
{
|
||||
return "int";
|
||||
}
|
||||
else if (typeof(uint).Equals(nativeType))
|
||||
{
|
||||
return "int";
|
||||
}
|
||||
else if (typeof(long).Equals(nativeType))
|
||||
{
|
||||
return "int";
|
||||
}
|
||||
else if (typeof(ulong).Equals(nativeType))
|
||||
{
|
||||
return "int";
|
||||
}
|
||||
else if (typeof(float).Equals(nativeType))
|
||||
{
|
||||
return "float";
|
||||
}
|
||||
else if (typeof(double).Equals(nativeType))
|
||||
{
|
||||
return "float";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool JSON2Value(Type targetType, JToken jToken, ref object value)
|
||||
{
|
||||
if (typeof(short).Equals(targetType))
|
||||
{
|
||||
value = jToken.Value<short>();
|
||||
return true;
|
||||
}
|
||||
else if (typeof(ushort).Equals(targetType))
|
||||
{
|
||||
value = jToken.Value<ushort>();
|
||||
return true;
|
||||
}
|
||||
else if (typeof(int).Equals(targetType))
|
||||
{
|
||||
value = jToken.Value<int>();
|
||||
return true;
|
||||
}
|
||||
else if (typeof(uint).Equals(targetType))
|
||||
{
|
||||
value = jToken.Value<uint>();
|
||||
return true;
|
||||
}
|
||||
else if (typeof(long).Equals(targetType))
|
||||
{
|
||||
value = jToken.Value<long>();
|
||||
return true;
|
||||
}
|
||||
else if (typeof(ulong).Equals(targetType))
|
||||
{
|
||||
value = jToken.Value<ulong>();
|
||||
return true;
|
||||
}
|
||||
else if (typeof(float).Equals(targetType))
|
||||
{
|
||||
value = jToken.Value<float>();
|
||||
return true;
|
||||
}
|
||||
else if (typeof(double).Equals(targetType))
|
||||
{
|
||||
value = jToken.Value<double>();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool Value2JSON(object value, ref JToken jToken)
|
||||
{
|
||||
Type sourceType = value.GetType();
|
||||
if (typeof(short).Equals(sourceType)
|
||||
|| typeof(ushort).Equals(sourceType)
|
||||
|| typeof(int).Equals(sourceType)
|
||||
|| typeof(uint).Equals(sourceType)
|
||||
|| typeof(long).Equals(sourceType)
|
||||
|| typeof(ulong).Equals(sourceType)
|
||||
|| typeof(float).Equals(sourceType)
|
||||
|| typeof(double).Equals(sourceType)
|
||||
)
|
||||
{
|
||||
jToken = JToken.FromObject(value);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
// /**
|
||||
// * 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<String>();
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
// /**
|
||||
// * File: JSONTimeSpanConverter.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 JSONTimeSpanConverter :IJsonConvert
|
||||
{
|
||||
public JSONTimeSpanConverter()
|
||||
{
|
||||
}
|
||||
|
||||
public string GetSkyType(Type nativeType)
|
||||
{
|
||||
if (typeof(TimeSpan).Equals(nativeType))
|
||||
return "timespan";
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool JSON2Value(Type targetType, JToken jToken, ref object value)
|
||||
{
|
||||
if (typeof(TimeSpan).Equals(targetType))
|
||||
{
|
||||
value = TimeSpan.FromSeconds(jToken.Value<double>());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool Value2JSON(object value, ref JToken jToken)
|
||||
{
|
||||
if (value is TimeSpan)
|
||||
{
|
||||
jToken = JToken.FromObject(((TimeSpan)value).TotalSeconds);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
using System;
|
||||
namespace ln.types.json.rpc
|
||||
{
|
||||
public class RPCError
|
||||
{
|
||||
public int Code { get; set; }
|
||||
public string Message { get; set; }
|
||||
|
||||
public object Data { get; set; }
|
||||
|
||||
public RPCError()
|
||||
{
|
||||
}
|
||||
public RPCError(Exception e)
|
||||
{
|
||||
Code = 500;
|
||||
Message = e.ToString();
|
||||
}
|
||||
public RPCError(int code,String message)
|
||||
{
|
||||
Code = code;
|
||||
Message = message;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
using System;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json;
|
||||
namespace ln.types.json.rpc
|
||||
{
|
||||
public class RPCMessage
|
||||
{
|
||||
public String Version { get; set; }
|
||||
public String Method { get; set; }
|
||||
public object[] Parameters { get; set; }
|
||||
|
||||
public object Result { get; set; }
|
||||
public RPCError Error { get; set; }
|
||||
|
||||
public JToken Identifier { get; set; }
|
||||
|
||||
public RPCMessage()
|
||||
{
|
||||
Version = "2.0";
|
||||
Parameters = new object[0];
|
||||
}
|
||||
public RPCMessage(JObject source)
|
||||
{
|
||||
Version = source["jsonrpc"].ToObject<string>();
|
||||
if (source.ContainsKey("method"))
|
||||
Method = source["method"].ToObject<string>();
|
||||
if (source.ContainsKey("params"))
|
||||
Parameters = source["params"].ToObject<object[]>();
|
||||
|
||||
if (source.ContainsKey("result"))
|
||||
Result = source["result"];
|
||||
|
||||
if (source.ContainsKey("error"))
|
||||
|
||||
if (source.ContainsKey("id"))
|
||||
Identifier = source["id"];
|
||||
else
|
||||
Identifier = null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -31,9 +31,6 @@
|
|||
<Reference Include="System.Xml.Serialization" />
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="Newtonsoft.Json">
|
||||
<HintPath>..\packages\Newtonsoft.Json.12.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="nunit.framework">
|
||||
<Package>nunit</Package>
|
||||
|
@ -85,7 +82,6 @@
|
|||
<Compile Include="odb\Query.cs" />
|
||||
<Compile Include="odb\ODBCollection.DocumentIndex.AvailableAreas.cs" />
|
||||
<Compile Include="net\IPv4.cs" />
|
||||
<Compile Include="JSONConverters.cs" />
|
||||
<Compile Include="net\Network4.cs" />
|
||||
<Compile Include="odb\values\ODBTypedValue.cs" />
|
||||
<Compile Include="odb\index\IndexPath.cs" />
|
||||
|
@ -106,20 +102,9 @@
|
|||
<Compile Include="btree\BTreeValueList.cs" />
|
||||
<Compile Include="net\MAC.cs" />
|
||||
<Compile Include="net\Endpoint4.cs" />
|
||||
<Compile Include="json\JSONConvert.cs" />
|
||||
<Compile Include="json\IJsonConvert.cs" />
|
||||
<Compile Include="json\converter\JSONStringConverter.cs" />
|
||||
<Compile Include="json\converter\JSONNumberConverter.cs" />
|
||||
<Compile Include="json\converter\JSONDateTimeConverter.cs" />
|
||||
<Compile Include="json\converter\JSONTimeSpanConverter.cs" />
|
||||
<Compile Include="json\converter\JSONGuidConverter.cs" />
|
||||
<Compile Include="json\converter\JSONIPv4Converter.cs" />
|
||||
<Compile Include="json\converter\JSONNetwork4Converter.cs" />
|
||||
<Compile Include="net\tools\Ping.cs" />
|
||||
<Compile Include="net\IPv4Header.cs" />
|
||||
<Compile Include="net\ICMPPacket.cs" />
|
||||
<Compile Include="json\rpc\RPCMessage.cs" />
|
||||
<Compile Include="json\rpc\RPCError.cs" />
|
||||
<Compile Include="ArgumentContainer.cs" />
|
||||
<Compile Include="rpc\RPCContainer.cs" />
|
||||
<Compile Include="rpc\RPCCall.cs" />
|
||||
|
@ -132,6 +117,7 @@
|
|||
<Compile Include="odb\ng\mappings\DictionaryMapping.cs" />
|
||||
<Compile Include="odb\ng\mappings\ListMapping.cs" />
|
||||
<Compile Include="odb\ng\Reference.cs" />
|
||||
<Compile Include="stream\CharStream.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="sync\" />
|
||||
|
@ -147,13 +133,11 @@
|
|||
<Folder Include="odb\mapped\" />
|
||||
<Folder Include="odb\enumeration\" />
|
||||
<Folder Include="odb\collections\" />
|
||||
<Folder Include="json\" />
|
||||
<Folder Include="json\converter\" />
|
||||
<Folder Include="net\tools\" />
|
||||
<Folder Include="json\rpc\" />
|
||||
<Folder Include="rpc\" />
|
||||
<Folder Include="odb\ng\" />
|
||||
<Folder Include="odb\ng\mappings\" />
|
||||
<Folder Include="stream\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ln.logging\ln.logging.csproj">
|
||||
|
@ -161,8 +145,5 @@
|
|||
<Name>ln.logging</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
23
net/IPv4.cs
23
net/IPv4.cs
|
@ -2,7 +2,6 @@
|
|||
using System.Linq;
|
||||
using System.Net;
|
||||
using ln.types.odb;
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
using ln.types.odb.values;
|
||||
namespace ln.types.net
|
||||
|
@ -126,28 +125,6 @@ namespace ln.types.net
|
|||
(mapper, value) => new ODBTypedValue(typeof(IPv4), value._ip),
|
||||
(mapper, oval) => new IPv4(oval.AsTypedValue.ODBValue.AsUInt)
|
||||
);
|
||||
|
||||
JSONConverters.converters.Add(new IPv4JsonConverter());
|
||||
}
|
||||
|
||||
public class IPv4JsonConverter : JsonConverter
|
||||
{
|
||||
public override bool CanConvert(Type objectType)
|
||||
{
|
||||
return (objectType == typeof(IPv4));
|
||||
}
|
||||
|
||||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, Newtonsoft.Json.JsonSerializer serializer)
|
||||
{
|
||||
return IPv4.Parse(reader.ReadAsString());
|
||||
}
|
||||
|
||||
public override void WriteJson(JsonWriter writer, object value, Newtonsoft.Json.JsonSerializer serializer)
|
||||
{
|
||||
writer.WriteValue((value as IPv4).ToString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,8 +11,6 @@ using System;
|
|||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections;
|
||||
using Newtonsoft.Json;
|
||||
using ln.types.net;
|
||||
|
||||
namespace ln.types.net
|
||||
{
|
||||
|
@ -214,32 +212,5 @@ namespace ln.types.net
|
|||
currentIP = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static Network4()
|
||||
{
|
||||
JSONConverters.converters.Add( new Network4JsonConverter());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class Network4JsonConverter: JsonConverter
|
||||
{
|
||||
public override bool CanConvert(Type objectType)
|
||||
{
|
||||
return (objectType == typeof(Network4));
|
||||
}
|
||||
|
||||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, Newtonsoft.Json.JsonSerializer serializer)
|
||||
{
|
||||
return Network4.Parse(reader.ReadAsString());
|
||||
}
|
||||
|
||||
public override void WriteJson(JsonWriter writer, object value, Newtonsoft.Json.JsonSerializer serializer)
|
||||
{
|
||||
writer.WriteValue((value as Network4).ToString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Newtonsoft.Json" version="12.0.2" targetFramework="net47" />
|
||||
</packages>
|
|
@ -1,6 +1,4 @@
|
|||
using System;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json;
|
||||
namespace ln.types.rpc
|
||||
{
|
||||
public class RPCCall
|
||||
|
@ -16,6 +14,7 @@ namespace ln.types.rpc
|
|||
{
|
||||
Identifier = Guid.NewGuid();
|
||||
}
|
||||
/*
|
||||
public RPCCall(JObject json)
|
||||
{
|
||||
if (json.ContainsKey("id"))
|
||||
|
@ -51,6 +50,6 @@ namespace ln.types.rpc
|
|||
else
|
||||
Parameters = new object[0];
|
||||
}
|
||||
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using Newtonsoft.Json.Linq;
|
||||
namespace ln.types.rpc
|
||||
{
|
||||
public class RPCResult
|
||||
|
@ -26,7 +25,7 @@ namespace ln.types.rpc
|
|||
Exception = e;
|
||||
ErrorText = e.ToString();
|
||||
}
|
||||
|
||||
/*
|
||||
public JObject ToJSON()
|
||||
{
|
||||
JObject result = new JObject();
|
||||
|
@ -45,6 +44,6 @@ namespace ln.types.rpc
|
|||
|
||||
return result;
|
||||
}
|
||||
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
// /**
|
||||
// * File: CharStream.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 System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
namespace ln.types.stream
|
||||
{
|
||||
public class CharStream
|
||||
{
|
||||
public char Current => characters[position];
|
||||
public int Position => position;
|
||||
|
||||
char[] characters;
|
||||
int position;
|
||||
|
||||
public CharStream(IEnumerable<char> characters)
|
||||
: this(characters.ToArray()) { }
|
||||
|
||||
public CharStream(char[] characters)
|
||||
{
|
||||
this.characters = characters;
|
||||
}
|
||||
|
||||
public bool TryNext()
|
||||
{
|
||||
position++;
|
||||
return (position < this.characters.Length);
|
||||
}
|
||||
public void MoveNext()
|
||||
{
|
||||
position++;
|
||||
if (position >= this.characters.Length)
|
||||
throw new IOException("Unexpected end of characters");
|
||||
}
|
||||
|
||||
public void Skip(Func<char, bool> test)
|
||||
{
|
||||
if (position < this.characters.Length)
|
||||
while (test(Current) && TryNext())
|
||||
{
|
||||
}
|
||||
}
|
||||
public char[] Read(Func<char, bool> test)
|
||||
{
|
||||
List<char> chars = new List<char>();
|
||||
|
||||
while (test(Current))
|
||||
{
|
||||
chars.Add(Current);
|
||||
MoveNext();
|
||||
}
|
||||
|
||||
return chars.ToArray();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -18,6 +18,7 @@ using System.Text;
|
|||
using ln.types.serialize;
|
||||
namespace ln.types.sync
|
||||
{
|
||||
|
||||
public class Synced : Attribute
|
||||
{
|
||||
}
|
||||
|
|
|
@ -11,11 +11,8 @@ using NUnit.Framework;
|
|||
using System;
|
||||
using System.IO;
|
||||
using ln.types.odb;
|
||||
using Newtonsoft.Json;
|
||||
using System.Diagnostics;
|
||||
using ln.types.threads;
|
||||
using System.Threading;
|
||||
using ln.logging;
|
||||
using ln.types.odb.attributes;
|
||||
using ln.types.odb.mapped;
|
||||
using System.Linq;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
using System;
|
||||
using ln.logging;
|
||||
using Newtonsoft.Json;
|
||||
using System.Threading;
|
||||
namespace ln.types.threads
|
||||
{
|
||||
|
@ -13,9 +12,7 @@ namespace ln.types.threads
|
|||
{
|
||||
public string Name { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public JobDelegate Job { get; }
|
||||
[JsonIgnore]
|
||||
public ExtendedJobDelegate ExtendedJob { get; }
|
||||
|
||||
public double Progress { get; set; }
|
||||
|
|
Loading…
Reference in New Issue