Ejemplo n.º 1
0
        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]);
        }
Ejemplo n.º 2
0
        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());
        }
Ejemplo n.º 3
0
        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));
        }
Ejemplo n.º 4
0
 public JsonAttribute(JsonSlots slots, JsonShape shape)
     : this()
 {
     Shape = shape;
     Slots = slots;
 }
Ejemplo n.º 5
0
 public JsonAttribute(JsonShape shape)
     : this()
 {
     Shape = shape;
 }
Ejemplo n.º 6
0
 public RectangleShape(JsonShape jsonShape, Vector2 center) : base(jsonShape, center)
 {
     Size = new Vector2(jsonShape.Size[0], jsonShape.Size[1]);
 }
Ejemplo n.º 7
0
 public CircleShape(JsonShape jsonShape, Vector2 center) : base(jsonShape, center)
 {
     R = jsonShape.R;
 }
Ejemplo n.º 8
0
 public PolygonShape(JsonShape jsonShape, Vector2 center) : base(jsonShape, center)
 {
     Points = jsonShape.Points.Select(x => new Vector2(x[0], x[1])).ToArray();
 }
Ejemplo n.º 9
0
 public Shape(JsonShape jsonShape, Vector2 center)
 {
     Center = center;
     Offset = new Vector2(jsonShape.Offset[0], jsonShape.Offset[1]);
 }
Ejemplo n.º 10
0
 public JsonAttribute(JsonSlots slots, JsonShape shape)
     : this()
 {
     Shape = shape;
     Slots = slots;
 }
Ejemplo n.º 11
0
 public JsonAttribute(JsonShape shape)
     : this()
 {
     Shape = shape;
 }