Ooui-tws-port/Ooui/Mapping.cs

37 lines
840 B
C#
Raw Normal View History

2017-06-12 20:19:18 +00:00
using System;
using System.Collections.Generic;
namespace Ooui
{
2017-06-12 20:46:42 +00:00
public class Mapping
2017-06-12 20:19:18 +00:00
{
readonly Type type;
public string TagName { get; private set; }
2017-06-12 20:46:42 +00:00
public Mapping (Type type)
2017-06-12 20:19:18 +00:00
{
this.type = type;
TagName = type.Name.ToLowerInvariant ();
}
public string GetMemberPath (string propertyName)
{
return propertyName;
}
2017-06-12 20:46:42 +00:00
static readonly Dictionary<string, Mapping> mappings =
new Dictionary<string, Mapping> ();
2017-06-12 20:19:18 +00:00
2017-06-12 20:46:42 +00:00
public static Mapping Get (Type type)
2017-06-12 20:19:18 +00:00
{
var key = type.FullName;
2017-06-12 20:46:42 +00:00
Mapping m;
2017-06-12 20:19:18 +00:00
if (!mappings.TryGetValue (key, out m)) {
2017-06-12 20:46:42 +00:00
m = new Mapping (type);
2017-06-12 20:19:18 +00:00
mappings[key] = m;
}
return m;
}
}
}