public EdgeShape(JsonShape jsonShape, Vector2 center) : base(jsonShape, center) { var p1 = jsonShape.Points[0]; var p2 = jsonShape.Points[1]; P1 = new Vector2(p1[0], p1[1]); P2 = new Vector2(p2[0], p2[1]); }
private string GetResultString(JsonShape jshape) { var stream1 = new MemoryStream(); var ser = new DataContractJsonSerializer(typeof(JsonShape)); ser.WriteObject(stream1, jshape); stream1.Position = 0; var sr = new StreamReader(stream1); return(sr.ReadToEnd()); }
public ActionResult <string> Get(string shape, uint side1, uint side2) { var jshape = new JsonShape(); jshape.shape = shape.ToLower(); jshape.side1 = side1; jshape.side2 = side2; if (String.IsNullOrEmpty(shape)) { jshape.result = "Fail"; return(GetResultString(jshape)); } uint result = 0; Shape.Shape s = null; switch (shape.ToLower()) { case "square": s = new Square(side1 == 0 ? side2 : side1); result = s.Area(); jshape.result = "Success"; break; case "rectangle": s = new Rectangle(side1, side2); result = s.Area(); jshape.result = "Success"; break; default: jshape.result = "Fail"; break; } jshape.area = result; return(GetResultString(jshape)); }
public JsonAttribute(JsonSlots slots, JsonShape shape) : this() { Shape = shape; Slots = slots; }
public JsonAttribute(JsonShape shape) : this() { Shape = shape; }
public RectangleShape(JsonShape jsonShape, Vector2 center) : base(jsonShape, center) { Size = new Vector2(jsonShape.Size[0], jsonShape.Size[1]); }
public CircleShape(JsonShape jsonShape, Vector2 center) : base(jsonShape, center) { R = jsonShape.R; }
public PolygonShape(JsonShape jsonShape, Vector2 center) : base(jsonShape, center) { Points = jsonShape.Points.Select(x => new Vector2(x[0], x[1])).ToArray(); }
public Shape(JsonShape jsonShape, Vector2 center) { Center = center; Offset = new Vector2(jsonShape.Offset[0], jsonShape.Offset[1]); }