-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathXml.cs
64 lines (55 loc) · 2 KB
/
Xml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Xml.Schema;
using System.Xml.Serialization;
namespace GeoFramework
{
internal static class Xml
{
/// <summary>
/// Returns the XML namespace for GML documents.
/// </summary>
public const string GmlXmlNamespace = "http://www.opengis.net/gml";
/// <summary>
/// Returns the prefix applied to all GML XML elements.
/// </summary>
public const string GmlXmlPrefix = "gml";
/// <summary>
/// Returns the XML namespace for GeoFramework documents.
/// </summary>
public const string GeoFrameworkXmlNamespace = "http://www.geoframeworks.com/gml";
/// <summary>
/// Returns the prefix applied to all GeoFramework XML elements.
/// </summary>
public const string GeoFrameworkXmlPrefix = "geoframework";
#if Framework30
/// <summary>
/// Used to test the <see cref="IXmlSerializable.WriteXml"/> implementations of GeoFramework types.
/// </summary>
internal static string Serialize<T>(T obj)
where T: IXmlSerializable
{
using (StringWriter writer = new StringWriter())
{
XmlSerializer serializer = new XmlSerializer(typeof(T));
serializer.Serialize(writer, obj);
return writer.ToString();
}
}
/// <summary>
/// Used to test the <see cref="IXmlSerializable.ReadXml"/> implementations of GeoFramework types.
/// </summary>
internal static T Deserialize<T>(string xml)
where T : IXmlSerializable, new()
{
using (StringReader reader = new StringReader(xml))
{
XmlSerializer serializer = new XmlSerializer(typeof(T));
return (T)serializer.Deserialize(reader);
}
}
#endif
}
}