public void TypeSerializer_Test() { var typeSerializer = new PolygonSerializer(); foreach (var item in Values) { var serialized = typeSerializer.Serialize(1, item); var deserialized = typeSerializer.Deserialize(1, serialized, 0, serialized.Length, null); Assert.AreEqual(item, deserialized); //starting from offset serialized = new byte[] { 1, 2, 3 }.Concat(serialized).ToArray(); deserialized = typeSerializer.Deserialize(1, serialized, 3, serialized.Length - 3, null); Assert.AreEqual(item, deserialized); } }
public void TypeSerializer_Test() { var typeSerializer = new PolygonSerializer(); foreach (var item in Values) { var serialized = typeSerializer.Serialize(1, item); var deserialized = typeSerializer.Deserialize(1, serialized, 0, serialized.Length, null); Assert.AreEqual(item, deserialized); //starting from offset serialized = new byte[] { 1, 2, 3 }.Concat(serialized).ToArray(); deserialized = typeSerializer.Deserialize(1, serialized, 3, serialized.Length - 3, null); Assert.AreEqual(item, deserialized); } }
public static AbstractGeometryType Deserialize(XmlReader reader) { var node = XElement.Load(reader); reader = node.CreateReader(); if (node.Name.NamespaceName != "http://www.opengis.net/gml") { throw new FormatException("The xml is not GML"); } if (node.Name.LocalName == "MultiPolygon") { return((MultiPolygonType)MultiPolygonSerializer.Deserialize(reader)); } if (node.Name.LocalName == "MultiCurve") { return((MultiCurveType)MultiCurveSerializer.Deserialize(reader)); } if (node.Name.LocalName == "MultiLineString") { return((MultiLineStringType)MultiLineStringSerializer.Deserialize(reader)); } if (node.Name.LocalName == "MultiSurface") { return((MultiSurfaceType)MultiSurfaceSerializer.Deserialize(reader)); } if (node.Name.LocalName == "MultiPoint") { return((MultiPointType)MultiPointSerializer.Deserialize(reader)); } if (node.Name.LocalName == "LinearRing") { return((LinearRingType)LinearRingSerializer.Deserialize(reader)); } if (node.Name.LocalName == "Polygon") { return((PolygonType)PolygonSerializer.Deserialize(reader)); } if (node.Name.LocalName == "LineString") { return((LineStringType)LineStringSerializer.Deserialize(reader)); } if (node.Name.LocalName == "Point") { return((PointType)PointSerializer.Deserialize(reader)); } throw new NotImplementedException(); }