[pgsqlclient-checkins] pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/NPgClient PgOutputPacket.cs
Status: Inactive
Brought to you by:
carlosga_fb
|
From: <car...@us...> - 2003-10-19 09:07:45
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/NPgClient
In directory sc8-pr-cvs1:/tmp/cvs-serv31173
Modified Files:
PgOutputPacket.cs PgResponsePacket.cs
Log Message:
- Added specific classes for handle Postgres Geometric types
- Added handling of line and lseg postgres types
Index: PgOutputPacket.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/NPgClient/PgOutputPacket.cs,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** PgOutputPacket.cs 17 Oct 2003 20:47:55 -0000 1.10
--- PgOutputPacket.cs 18 Oct 2003 11:58:13 -0000 1.11
***************
*** 24,27 ****
--- 24,29 ----
using System.Globalization;
+ using PostgreSql.Data.PgTypes;
+
namespace PostgreSql.Data.NPgClient
{
***************
*** 66,69 ****
--- 68,73 ----
#region WRITE_METHODS
+ // Standard types
+
public void WriteString(string data)
{
***************
*** 142,145 ****
--- 146,177 ----
}
+ // Geometric types
+
+ public void WritePoint(PgPoint point)
+ {
+ WriteDouble(point.X);
+ WriteDouble(point.Y);
+ }
+
+ public void WriteCircle(PgCircle circle)
+ {
+ WritePoint(circle.Center);
+ WriteDouble(circle.Radius);
+ }
+
+ public void WriteLine(PgLine line)
+ {
+ WritePoint(line.StartPoint);
+ WritePoint(line.EndPoint);
+ }
+
+ public void WriteLSeg(PgLSeg lseg)
+ {
+ WritePoint(lseg.StartPoint);
+ WritePoint(lseg.EndPoint);
+ }
+
+ // Parameters
+
public void WriteParameter(PgParameter parameter)
{
***************
*** 283,305 ****
case PgDataType.Point:
! double[] point = (double[])value;
packet.WriteInt(size);
! packet.WriteDouble(point[0]); // x
! packet.WriteDouble(point[1]); // y
break;
case PgDataType.Circle:
! double[] circle = (double[])value;
packet.WriteInt(size);
! packet.WriteDouble(circle[0]); // x
! packet.WriteDouble(circle[1]); // y
! packet.WriteDouble(circle[2]); // r
break;
- case PgDataType.Box:
case PgDataType.Line:
case PgDataType.LSeg:
case PgDataType.Path:
--- 315,346 ----
case PgDataType.Point:
! PgPoint point = value as PgPoint;
packet.WriteInt(size);
! packet.WritePoint(point);
break;
case PgDataType.Circle:
! PgCircle circle = value as PgCircle;
packet.WriteInt(size);
! packet.WriteCircle(circle);
break;
case PgDataType.Line:
+ PgLine line = value as PgLine;
+
+ packet.WriteInt(size);
+ packet.WriteLine(line);
+ break;
+
case PgDataType.LSeg:
+ PgLSeg lseg = value as PgLSeg;
+
+ packet.WriteInt(size);
+ packet.WriteLSeg(lseg);
+ break;
+
+ case PgDataType.Box:
case PgDataType.Path:
Index: PgResponsePacket.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/NPgClient/PgResponsePacket.cs,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** PgResponsePacket.cs 17 Oct 2003 20:47:55 -0000 1.9
--- PgResponsePacket.cs 18 Oct 2003 11:58:13 -0000 1.10
***************
*** 24,27 ****
--- 24,29 ----
using System.Net;
+ using PostgreSql.Data.PgTypes;
+
namespace PostgreSql.Data.NPgClient
{
***************
*** 293,313 ****
// Geometric datatypes methods
! public double[] ReadPoint()
{
! double x = ReadDouble();
! double y = ReadDouble();
! return new double[]{x, y};
}
! public double[] ReadCircle()
{
! double x = ReadDouble();
! double y = ReadDouble();
! double r = ReadDouble();
! return new double[]{x, y, r};
}
public object ReadValue(PgType type, int length)
{
--- 295,323 ----
// Geometric datatypes methods
! public PgPoint ReadPoint()
{
! double x = this.ReadDouble();
! double y = this.ReadDouble();
! return new PgPoint(x, y);
}
! public PgCircle ReadCircle()
{
! return new PgCircle(this.ReadPoint(), this.ReadDouble());
! }
! public PgLine ReadLine()
! {
! return new PgLine(this.ReadPoint(), this.ReadPoint());
}
+ public PgLSeg ReadLSeg()
+ {
+ return new PgLSeg(this.ReadPoint(), this.ReadPoint());
+ }
+
+ // Common read method
+
public object ReadValue(PgType type, int length)
{
***************
*** 317,382 ****
if (type.FormatCode == 0)
{
! return ReadStringArray(type, length);
}
else
{
! return ReadPrimitiveArray(type, length);
}
case PgDataType.Vector:
! return ReadVector(type, length);
case PgDataType.Binary:
! return ReadBytes(length);
case PgDataType.Char:
case PgDataType.VarChar:
! return ReadString(length);
case PgDataType.Boolean:
! return ReadBoolean();
case PgDataType.Byte:
! return ReadByte();
case PgDataType.Decimal:
! string numericValue = ReadString(length);
return Decimal.Parse(numericValue, NumberFormatInfo.InvariantInfo);
case PgDataType.Currency:
! return ReadCurrency();
case PgDataType.Float:
! return ReadSingle();
case PgDataType.Double:
! return ReadDouble();
case PgDataType.Int2:
! return ReadShort();
case PgDataType.Int4:
! return ReadInt();
case PgDataType.Int8:
! return ReadLong();
case PgDataType.Date:
! return ReadDate();
case PgDataType.Time:
! return ReadTime();
case PgDataType.TimeStamp:
! return ReadTimestamp();
case PgDataType.Point:
! return ReadPoint();
case PgDataType.Circle:
! return ReadCircle();
case PgDataType.Line:
case PgDataType.LSeg:
case PgDataType.Box:
case PgDataType.Path:
--- 327,396 ----
if (type.FormatCode == 0)
{
! return this.ReadStringArray(type, length);
}
else
{
! return this.ReadPrimitiveArray(type, length);
}
case PgDataType.Vector:
! return this.ReadVector(type, length);
case PgDataType.Binary:
! return this.ReadBytes(length);
case PgDataType.Char:
case PgDataType.VarChar:
! return this.ReadString(length);
case PgDataType.Boolean:
! return this.ReadBoolean();
case PgDataType.Byte:
! return this.ReadByte();
case PgDataType.Decimal:
! string numericValue = this.ReadString(length);
return Decimal.Parse(numericValue, NumberFormatInfo.InvariantInfo);
case PgDataType.Currency:
! return this.ReadCurrency();
case PgDataType.Float:
! return this.ReadSingle();
case PgDataType.Double:
! return this.ReadDouble();
case PgDataType.Int2:
! return this.ReadShort();
case PgDataType.Int4:
! return this.ReadInt();
case PgDataType.Int8:
! return this.ReadLong();
case PgDataType.Date:
! return this.ReadDate();
case PgDataType.Time:
! return this.ReadTime();
case PgDataType.TimeStamp:
! return this.ReadTimestamp();
case PgDataType.Point:
! return this.ReadPoint();
case PgDataType.Circle:
! return this.ReadCircle();
case PgDataType.Line:
+ return this.ReadLine();
+
case PgDataType.LSeg:
+ return this.ReadLSeg();
+
case PgDataType.Box:
case PgDataType.Path:
|