Add JSONIpv6Mapping

master
Harald Wolff 2019-10-07 09:08:42 +02:00
parent 0d3c6b50fc
commit 5262b420ea
3 changed files with 34 additions and 0 deletions

View File

@ -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\" />

View File

@ -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());
}
}
}

View File

@ -108,6 +108,8 @@ namespace ln.json.mapping
Add(new JSONRPCCallMapping());
Add(new JSONRPCResultMapping());
Add(new JSONIPv6Mapping());
}
public void Add(JSONMapping mapping)