[pgsqlclient-checkins] pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/PgTypes PgPolygon.cs,1.1,1.
Status: Inactive
Brought to you by:
carlosga_fb
From: <car...@us...> - 2003-10-18 13:40:45
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/PgTypes In directory sc8-pr-cvs1:/tmp/cvs-serv12271 Modified Files: PgPolygon.cs Log Message: Added support for Polygon type ( read only at this moment ) Index: PgPolygon.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/PgTypes/PgPolygon.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PgPolygon.cs 18 Oct 2003 11:57:37 -0000 1.1 --- PgPolygon.cs 18 Oct 2003 13:38:40 -0000 1.2 *************** *** 23,29 **** public class PgPolygon { ! public PgPolygon() { } } } --- 23,133 ---- public class PgPolygon { ! #region FIELDS ! ! private PgPoint[] points; ! ! #endregion ! ! #region PROPERTIES ! ! public PgPoint[] Points ! { ! get { return points; } ! } ! ! #endregion ! ! #region CONSTRUCTORS ! ! public PgPolygon(PgPoint[] points) ! { ! this.points = (PgPoint[])points.Clone(); ! } ! ! #endregion ! ! #region OPERATORS ! ! public static bool operator ==(PgPolygon left, PgPolygon right) ! { ! bool equals = false; ! ! if (left.Points.Length == right.Points.Length) ! { ! equals = true; ! for (int i = 0; i < left.Points.Length; i++) ! { ! if (left.Points[i] != right.Points[i]) ! { ! equals = false; ! break; ! } ! } ! } ! ! return equals; ! } ! ! public static bool operator !=(PgPolygon left, PgPolygon right) ! { ! bool notequals = true; ! ! if (left.Points.Length == right.Points.Length) ! { ! notequals = false; ! for (int i = 0; i < left.Points.Length; i++) ! { ! if (left.Points[i] != right.Points[i]) ! { ! notequals = true; ! break; ! } ! } ! } ! ! return notequals; ! } ! ! #endregion ! ! #region OVERRIDEN_METHODS ! ! public override string ToString() { + System.Text.StringBuilder b = new System.Text.StringBuilder(); + + for (int i = 0; i < this.points.Length; i++) + { + if (b.Length > 0) + { + b.Append(","); + } + b.AppendFormat("({0},{1}),({2},{3})", + this.points[0].X, this.points[i].Y); + } + + b.AppendFormat("( {0} )", b.ToString()); + + return b.ToString(); + } + + public override int GetHashCode() + { + return base.GetHashCode(); + } + + public override bool Equals(object obj) + { + if (obj is PgPolygon) + { + return (obj as PgPolygon) == this; + } + else + { + return false; + } } + + #endregion } } |