/// <summary> /// Writes the JSON representation of the object. /// </summary> /// <param name="writer">The <see cref="T:Newtonsoft.Json.JsonWriter" /> to write to.</param> /// <param name="value">The existingValue.</param> /// <param name="serializer">The calling serializer.</param> public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { PolygonCoordinates coordinates = (PolygonCoordinates)value; writer.WriteStartArray(); foreach (LinearRing linearRing in coordinates.Rings) { serializer.Serialize(writer, linearRing.Positions); } writer.WriteEndArray(); }
public void PolygonCoordinatesSerialization() { PolygonCoordinates testObj = new PolygonCoordinates(new List <LinearRing>() { new LinearRing(new List <Position>() { new Position(1, 1) }) }); string result = ContractObjectToXml(testObj); Assert.IsTrue(VerifySerialization(result, testObj)); }
// Create shape by given parameters private async void CreateShape() { if (SelectedShapeItem != null) { if (SelectedShapeItem.IsCalculationRequired) { switch (SelectedShapeItem.Shapes) { case Shape.IsoscelesTriangle: IsoscelesTrianglePoints = TriangleCoordinates.CalculateCoordinateOfIsoscelesTriangle(HeightUnit, WidthUnit); break; case Shape.ScaleneTriangle: ScaleneTrianglePoints = TriangleCoordinates.CalculateCoordinateOfScaleneTriangle(HeightUnit, WidthUnit); break; case Shape.Parallelogram: ParallelogramPoints = ParallelogramCoordinates.CalculateCoordinateOfParallelogram(WidthUnit); break; default: { var numberOfSie = GetNumberOfSideOfShape(SelectedShapeItem.Shapes); PolygonPoints = PolygonCoordinates.CalculateCoordinateOfShape(numberOfSie, WidthUnit); break; } } } SetCurrentShape(SelectedShapeItem.Shapes); } else { var messageDialog = new MessageDialog("Please select the shape.", "Shapes"); await messageDialog.ShowAsync(); } }