ln.json/mapping/JSONIPv6Mapping.cs

33 lines
788 B
C#

// /**
// * 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;
using ln.types.net;
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());
}
}
}