44 lines
1.1 KiB
C#
44 lines
1.1 KiB
C#
// /**
|
|
// * File: JSONMapping.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;
|
|
namespace ln.json.mapping
|
|
{
|
|
public class JSONMapping
|
|
{
|
|
public Type TargetType { get; }
|
|
|
|
Func<JSONMapper, object, JSONValue> tojson;
|
|
Func<JSONMapper, JSONValue, object> fromjson;
|
|
|
|
public JSONMapping(Type targetType,Func<JSONMapper, object, JSONValue> tojson, Func<JSONMapper, JSONValue, object> fromjson)
|
|
{
|
|
TargetType = targetType;
|
|
this.fromjson = fromjson;
|
|
this.tojson = tojson;
|
|
}
|
|
protected JSONMapping(Type targetType)
|
|
{
|
|
TargetType = targetType;
|
|
}
|
|
|
|
public virtual object FromJson(JSONMapper mapper,JSONValue json)
|
|
{
|
|
return fromjson(mapper, json);
|
|
}
|
|
public virtual JSONValue ToJson(JSONMapper mapper,object value)
|
|
{
|
|
return tojson(mapper, value);
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|