Ejemplo n.º 1
0
 private static OXmlPolygon CreatePolygon(BsonDocument element)
 {
     if (element == null)
         return null;
     OXmlPolygon polygon = new OXmlPolygon
     {
         StartPoint = new OXmlPoint2DType { X = element.zGet("StartPointX").zAsLong(), Y = element.zGet("StartPointY").zAsLong() },
         Edited = element.zGet("Edited").zAsNullableBoolean()
     };
     List<OXmlPoint2DType> linesTo = new List<OXmlPoint2DType>();
     foreach (BsonValue line in element.zGet("LinesTo").zAsBsonArray())
     {
         BsonDocument line2 = line.AsBsonDocument;
         linesTo.Add(new OXmlPoint2DType { X = line2.zGet("X").zAsLong(), Y = line2.zGet("Y").zAsLong() });
     }
     polygon.LinesTo = linesTo.ToArray();
     return polygon;
 }
Ejemplo n.º 2
0
 private static void SerializePolygon(BsonWriter bsonWriter, OXmlPolygon polygon)
 {
     bsonWriter.WriteStartDocument("Polygon");
     if (polygon.StartPoint != null)
     {
         bsonWriter.WriteInt64("StartPointX", polygon.StartPoint.X);
         bsonWriter.WriteInt64("StartPointY", polygon.StartPoint.Y);
     }
     bsonWriter.WriteStartArray("LinesTo");
     foreach (OXmlPoint2DType lineTo in polygon.LinesTo)
     {
         bsonWriter.WriteStartDocument();
         bsonWriter.WriteInt64("X", lineTo.X);
         bsonWriter.WriteInt64("Y", lineTo.Y);
         bsonWriter.WriteEndDocument();
     }
     bsonWriter.WriteEndArray();
     if (polygon.Edited != null)
         bsonWriter.WriteBoolean("Edited", (bool)polygon.Edited);
     bsonWriter.WriteEndDocument();
 }