Exemplo n.º 1
0
        public object Read(IPackStreamReader reader, byte signature, long size)
        {
            switch (signature)
            {
            case Point2DStructType:
            {
                PackStream.EnsureStructSize("Point2D", Point2DStructSize, size);
                var srId = reader.ReadInteger();
                var x    = reader.ReadDouble();
                var y    = reader.ReadDouble();

                return(new CypherPoint(srId, x, y));
            }

            case Point3DStructType:
            {
                PackStream.EnsureStructSize("Point3D", Point3DStructSize, size);
                var srId = reader.ReadInteger();
                var x    = reader.ReadDouble();
                var y    = reader.ReadDouble();
                var z    = reader.ReadDouble();

                return(new CypherPoint(srId, x, y, z));
            }

            default:
                throw new ProtocolException(
                          $"Unsupported struct signature {signature} passed to {nameof(PointHandler)}!");
            }
        }