mirror of
https://github.com/cyanfish/naps2.git
synced 2024-09-11 15:26:55 +03:00
Support Guid serialization
This commit is contained in:
parent
b58987ef2b
commit
65470453ac
@ -50,6 +50,7 @@ public abstract class XmlSerializer
|
||||
{ typeof(ImmutableList<>), new XmlTypeInfo { CustomSerializer = new ImmutableListSerializer() } },
|
||||
{ typeof(ImmutableHashSet<>), new XmlTypeInfo { CustomSerializer = new ImmutableHashSetSerializer() } },
|
||||
{ typeof(DateTime), new XmlTypeInfo { CustomSerializer = new DateTimeSerializer() } },
|
||||
{ typeof(Guid), new XmlTypeInfo { CustomSerializer = new GuidSerializer() } },
|
||||
{ typeof(Nullable<>), new XmlTypeInfo { CustomSerializer = new NullableSerializer() } },
|
||||
};
|
||||
|
||||
@ -652,6 +653,19 @@ public abstract class XmlSerializer
|
||||
}
|
||||
}
|
||||
|
||||
protected class GuidSerializer : CustomXmlSerializer<Guid>
|
||||
{
|
||||
protected override void Serialize(Guid obj, XElement element)
|
||||
{
|
||||
element.Value = obj.ToString();
|
||||
}
|
||||
|
||||
protected override Guid Deserialize(XElement element)
|
||||
{
|
||||
return Guid.Parse(element.Value);
|
||||
}
|
||||
}
|
||||
|
||||
protected class NullableSerializer : CustomXmlSerializer
|
||||
{
|
||||
public override void SerializeObject(object obj, XElement element, Type type)
|
||||
|
Loading…
Reference in New Issue
Block a user