Merge branch 'master' of https://schwann.lnvpn.de/LupusNobilis/ln.json
commit
7b3ce46f52
|
@ -6,18 +6,21 @@ namespace ln.json
|
|||
public static JSONTrue Instance { get; } = new JSONTrue();
|
||||
private JSONTrue() : base(JSONValueType.TRUE) { }
|
||||
public override string ToString() => "true";
|
||||
}
|
||||
public override object ToNative() => true;
|
||||
}
|
||||
public class JSONFalse : JSONValue
|
||||
{
|
||||
public static JSONFalse Instance { get; } = new JSONFalse();
|
||||
private JSONFalse() : base(JSONValueType.FALSE) { }
|
||||
public override string ToString() => "false";
|
||||
}
|
||||
public override object ToNative() => false;
|
||||
}
|
||||
public class JSONNull : JSONValue
|
||||
{
|
||||
public static JSONNull Instance { get; } = new JSONNull();
|
||||
private JSONNull() : base(JSONValueType.NULL) { }
|
||||
public override string ToString() => "null";
|
||||
}
|
||||
public override object ToNative() => null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -55,6 +55,7 @@
|
|||
<Compile Include="mapping\JSONEnumMapping.cs" />
|
||||
<Compile Include="mapping\JSONDictionaryMapping.cs" />
|
||||
<Compile Include="mapping\JSONExceptionMapping.cs" />
|
||||
<Compile Include="mapping\JSONIPv6Mapping.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="mapping\" />
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
// /**
|
||||
// * File: JSONIPv6Mapping.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 ln.types;
|
||||
namespace ln.json.mapping
|
||||
{
|
||||
public class JSONIPv6Mapping : JSONMapping
|
||||
{
|
||||
public JSONIPv6Mapping() :base(typeof(IPv6))
|
||||
{
|
||||
}
|
||||
|
||||
public override object FromJson(JSONMapper mapper, JSONValue json)
|
||||
{
|
||||
return IPv6.Parse((json as JSONString).Value);
|
||||
}
|
||||
|
||||
public override JSONValue ToJson(JSONMapper mapper, object value)
|
||||
{
|
||||
return new JSONString((value as IPv6).ToCIDR());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -108,6 +108,8 @@ namespace ln.json.mapping
|
|||
Add(new JSONRPCCallMapping());
|
||||
Add(new JSONRPCResultMapping());
|
||||
|
||||
Add(new JSONIPv6Mapping());
|
||||
|
||||
}
|
||||
|
||||
public void Add(JSONMapping mapping)
|
||||
|
|
Loading…
Reference in New Issue