[pgsqlclient-checkins] pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/NPgClient PgCharSet.cs,1.1.
Status: Inactive
Brought to you by:
carlosga_fb
Update of /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/NPgClient
In directory sc8-pr-cvs1:/tmp/cvs-serv15669
Modified Files:
PgCharSet.cs PgCharSetCollection.cs PgClientError.cs
PgClientErrorCollection.cs PgClientException.cs
PgConnectionParams.cs PgDbClient.cs PgFieldDescriptor.cs
PgOutputPacket.cs PgParameter.cs PgResponsePacket.cs
PgRowDescriptor.cs PgStatement.cs PgType.cs
PgTypeCollection.cs
Log Message:
2003-12-14 Carlos Guzmán Álvarez <car...@te...>
* Changed #region names in all source files.
Index: PgCharSet.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/NPgClient/PgCharSet.cs,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** PgCharSet.cs 2 Aug 2003 19:43:02 -0000 1.1.1.1
--- PgCharSet.cs 14 Dec 2003 15:07:13 -0000 1.2
***************
*** 1,67 ****
! /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+
! * Copyright (C) 2003 Carlos Guzmán Álvarez
! *
! * This library is free software; you can redistribute it and/or
! * modify it under the terms of the GNU Lesser General Public
! * License as published by the Free Software Foundation; either
! * version 2.1 of the License, or (at your option) any later version.
! *
! * This library is distributed in the hope that it will be useful,
! * but WITHOUT ANY WARRANTY; without even the implied warranty of
! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
! * Lesser General Public License for more details.
! *
! * You should have received a copy of the GNU Lesser General Public
! * License along with this library; if not, write to the Free Software
! * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
! */
!
! using System;
! using System.Text;
!
! namespace PostgreSql.Data.NPgClient
! {
! internal class PgCharSet
! {
! #region FIELDS
!
! private string charSet;
! private Encoding encoding;
!
! #endregion
!
! #region PROPERTIES
!
! public string CharSet
! {
! get { return charSet; }
! }
!
! public Encoding Encoding
! {
! get { return encoding; }
! }
!
! #endregion
!
! #region CONSTRUCTORS
!
! public PgCharSet()
! {
! }
!
! public PgCharSet(string charSet, string systemCharSet)
! {
! this.charSet = charSet;
! this.encoding = Encoding.GetEncoding(systemCharSet);
! }
!
! public PgCharSet(string charSet, int cp)
! {
! this.charSet = charSet;
! this.encoding = Encoding.GetEncoding(cp);
! }
!
! #endregion
! }
! }
--- 1,67 ----
! /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+
! * Copyright (C) 2003 Carlos Guzmán Álvarez
! *
! * This library is free software; you can redistribute it and/or
! * modify it under the terms of the GNU Lesser General Public
! * License as published by the Free Software Foundation; either
! * version 2.1 of the License, or (at your option) any later version.
! *
! * This library is distributed in the hope that it will be useful,
! * but WITHOUT ANY WARRANTY; without even the implied warranty of
! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
! * Lesser General Public License for more details.
! *
! * You should have received a copy of the GNU Lesser General Public
! * License along with this library; if not, write to the Free Software
! * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
! */
!
! using System;
! using System.Text;
!
! namespace PostgreSql.Data.NPgClient
! {
! internal class PgCharSet
! {
! #region Fields
!
! private string charSet;
! private Encoding encoding;
!
! #endregion
!
! #region Properties
!
! public string CharSet
! {
! get { return charSet; }
! }
!
! public Encoding Encoding
! {
! get { return encoding; }
! }
!
! #endregion
!
! #region Constructors
!
! public PgCharSet()
! {
! }
!
! public PgCharSet(string charSet, string systemCharSet)
! {
! this.charSet = charSet;
! this.encoding = Encoding.GetEncoding(systemCharSet);
! }
!
! public PgCharSet(string charSet, int cp)
! {
! this.charSet = charSet;
! this.encoding = Encoding.GetEncoding(cp);
! }
!
! #endregion
! }
! }
Index: PgCharSetCollection.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/NPgClient/PgCharSetCollection.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** PgCharSetCollection.cs 22 Aug 2003 15:13:36 -0000 1.2
--- PgCharSetCollection.cs 14 Dec 2003 15:07:13 -0000 1.3
***************
*** 1,109 ****
! /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+
! * Copyright (C) 2003 Carlos Guzmán Álvarez
! *
! * This library is free software; you can redistribute it and/or
! * modify it under the terms of the GNU Lesser General Public
! * License as published by the Free Software Foundation; either
! * version 2.1 of the License, or (at your option) any later version.
! *
! * This library is distributed in the hope that it will be useful,
! * but WITHOUT ANY WARRANTY; without even the implied warranty of
! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
! * Lesser General Public License for more details.
! *
! * You should have received a copy of the GNU Lesser General Public
! * License along with this library; if not, write to the Free Software
! * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
! */
!
! using System;
! using System.Data;
! using System.Collections;
! using System.Globalization;
!
! namespace PostgreSql.Data.NPgClient
! {
! internal class PgCharSetCollection : ArrayList
! {
! #region PROPERTIES
!
! public new PgCharSet this[int index]
! {
! get { return (PgCharSet)base[index]; }
! set { base[index] = (PgCharSet)value; }
! }
!
! public PgCharSet this[string name]
! {
! get { return (PgCharSet)this[IndexOf(name)]; }
! set { this[IndexOf(name)] = (PgCharSet)value; }
! }
!
! #endregion
!
! #region METHODS
!
! public bool Contains(string charset)
! {
! return(-1 != IndexOf(charset));
! }
!
! public int IndexOf(string charset)
! {
! int index = 0;
! foreach(PgCharSet item in this)
! {
! if (cultureAwareCompare(item.CharSet, charset))
! {
! return index;
! }
! index++;
! }
! return -1;
! }
!
! public void RemoveAt(string charset)
! {
! RemoveAt(IndexOf(charset));
! }
!
! public PgCharSet Add(PgCharSet charset)
! {
! base.Add(charset);
!
! return charset;
! }
!
! public PgCharSet Add(string charset, string systemCharset)
! {
! PgCharSet charSet = new PgCharSet(charset, systemCharset);
!
! base.Add(charSet);
!
! return charSet;
! }
!
! public PgCharSet Add(string charset, int cp)
! {
! PgCharSet charSet = new PgCharSet(charset, cp);
!
! base.Add(charSet);
!
! return charSet;
! }
!
! private bool cultureAwareCompare(string strA, string strB)
! {
! try
! {
! return CultureInfo.CurrentCulture.CompareInfo.Compare(strA, strB, CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth | CompareOptions.IgnoreCase) == 0 ? true : false;
! }
! catch (Exception)
! {
! return strA.ToUpper() == strB.ToUpper() ? true : false;
! }
! }
!
! #endregion
! }
! }
--- 1,109 ----
! /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+
! * Copyright (C) 2003 Carlos Guzmán Álvarez
! *
! * This library is free software; you can redistribute it and/or
! * modify it under the terms of the GNU Lesser General Public
! * License as published by the Free Software Foundation; either
! * version 2.1 of the License, or (at your option) any later version.
! *
! * This library is distributed in the hope that it will be useful,
! * but WITHOUT ANY WARRANTY; without even the implied warranty of
! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
! * Lesser General Public License for more details.
! *
! * You should have received a copy of the GNU Lesser General Public
! * License along with this library; if not, write to the Free Software
! * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
! */
!
! using System;
! using System.Data;
! using System.Collections;
! using System.Globalization;
!
! namespace PostgreSql.Data.NPgClient
! {
! internal class PgCharSetCollection : ArrayList
! {
! #region Properties
!
! public new PgCharSet this[int index]
! {
! get { return (PgCharSet)base[index]; }
! set { base[index] = (PgCharSet)value; }
! }
!
! public PgCharSet this[string name]
! {
! get { return (PgCharSet)this[IndexOf(name)]; }
! set { this[IndexOf(name)] = (PgCharSet)value; }
! }
!
! #endregion
!
! #region Methods
!
! public bool Contains(string charset)
! {
! return(-1 != IndexOf(charset));
! }
!
! public int IndexOf(string charset)
! {
! int index = 0;
! foreach(PgCharSet item in this)
! {
! if (cultureAwareCompare(item.CharSet, charset))
! {
! return index;
! }
! index++;
! }
! return -1;
! }
!
! public void RemoveAt(string charset)
! {
! RemoveAt(IndexOf(charset));
! }
!
! public PgCharSet Add(PgCharSet charset)
! {
! base.Add(charset);
!
! return charset;
! }
!
! public PgCharSet Add(string charset, string systemCharset)
! {
! PgCharSet charSet = new PgCharSet(charset, systemCharset);
!
! base.Add(charSet);
!
! return charSet;
! }
!
! public PgCharSet Add(string charset, int cp)
! {
! PgCharSet charSet = new PgCharSet(charset, cp);
!
! base.Add(charSet);
!
! return charSet;
! }
!
! private bool cultureAwareCompare(string strA, string strB)
! {
! try
! {
! return CultureInfo.CurrentCulture.CompareInfo.Compare(strA, strB, CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth | CompareOptions.IgnoreCase) == 0 ? true : false;
! }
! catch (Exception)
! {
! return strA.ToUpper() == strB.ToUpper() ? true : false;
! }
! }
!
! #endregion
! }
! }
Index: PgClientError.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/NPgClient/PgClientError.cs,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** PgClientError.cs 2 Aug 2003 19:43:02 -0000 1.1.1.1
--- PgClientError.cs 14 Dec 2003 15:07:13 -0000 1.2
***************
*** 1,128 ****
! /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+
! * Copyright (C) 2003 Carlos Guzmán Álvarez
! *
! * This library is free software; you can redistribute it and/or
! * modify it under the terms of the GNU Lesser General Public
! * License as published by the Free Software Foundation; either
! * version 2.1 of the License, or (at your option) any later version.
! *
! * This library is distributed in the hope that it will be useful,
! * but WITHOUT ANY WARRANTY; without even the implied warranty of
! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
! * Lesser General Public License for more details.
! *
! * You should have received a copy of the GNU Lesser General Public
! * License along with this library; if not, write to the Free Software
! * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
! */
!
! using System;
!
! namespace PostgreSql.Data.NPgClient
! {
! internal sealed class PgClientError
! {
! #region FIELDS
!
! private string severity;
! private string code;
! private string message;
! private string detail;
! private string hint;
! private string where;
! private string position;
! private string file;
! private int line;
! private string routine;
!
! #endregion
!
! #region PROPERTIES
!
! public string Severity
! {
! get { return severity; }
! set { severity = value; }
! }
!
! public string Message
! {
! get { return message; }
! set { message = value; }
! }
!
! public string Code
! {
! get { return code; }
! set { code = value; }
! }
!
! public string Detail
! {
! get { return detail; }
! set { detail = value; }
! }
!
! public string Hint
! {
! get { return hint; }
! set { hint = value; }
! }
!
! public string Where
! {
! get { return where; }
! set { where = value; }
! }
!
! public string Position
! {
! get { return position; }
! set { position = value; }
! }
!
! public string File
! {
! get { return file; }
! set { file = value; }
! }
!
! public int Line
! {
! get { return line; }
! set { line = value; }
! }
!
! public string Routine
! {
! get { return routine; }
! set { routine = value; }
! }
!
! #endregion
!
! #region CONSTRUCTORS
!
! public PgClientError()
! {
! }
!
! public PgClientError(string message)
! {
! this.message = message;
! }
!
! public PgClientError(string severity, string code, string message)
! {
! this.severity = severity;
! this.code = code;
! this.message = message;
! }
!
! #endregion
!
! #region METHODS
!
! #endregion
! }
! }
--- 1,128 ----
! /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+
! * Copyright (C) 2003 Carlos Guzmán Álvarez
! *
! * This library is free software; you can redistribute it and/or
! * modify it under the terms of the GNU Lesser General Public
! * License as published by the Free Software Foundation; either
! * version 2.1 of the License, or (at your option) any later version.
! *
! * This library is distributed in the hope that it will be useful,
! * but WITHOUT ANY WARRANTY; without even the implied warranty of
! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
! * Lesser General Public License for more details.
! *
! * You should have received a copy of the GNU Lesser General Public
! * License along with this library; if not, write to the Free Software
! * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
! */
!
! using System;
!
! namespace PostgreSql.Data.NPgClient
! {
! internal sealed class PgClientError
! {
! #region Fields
!
! private string severity;
! private string code;
! private string message;
! private string detail;
! private string hint;
! private string where;
! private string position;
! private string file;
! private int line;
! private string routine;
!
! #endregion
!
! #region Properties
!
! public string Severity
! {
! get { return severity; }
! set { severity = value; }
! }
!
! public string Message
! {
! get { return message; }
! set { message = value; }
! }
!
! public string Code
! {
! get { return code; }
! set { code = value; }
! }
!
! public string Detail
! {
! get { return detail; }
! set { detail = value; }
! }
!
! public string Hint
! {
! get { return hint; }
! set { hint = value; }
! }
!
! public string Where
! {
! get { return where; }
! set { where = value; }
! }
!
! public string Position
! {
! get { return position; }
! set { position = value; }
! }
!
! public string File
! {
! get { return file; }
! set { file = value; }
! }
!
! public int Line
! {
! get { return line; }
! set { line = value; }
! }
!
! public string Routine
! {
! get { return routine; }
! set { routine = value; }
! }
!
! #endregion
!
! #region Constructors
!
! public PgClientError()
! {
! }
!
! public PgClientError(string message)
! {
! this.message = message;
! }
!
! public PgClientError(string severity, string code, string message)
! {
! this.severity = severity;
! this.code = code;
! this.message = message;
! }
!
! #endregion
!
! #region Methods
!
! #endregion
! }
! }
Index: PgClientErrorCollection.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/NPgClient/PgClientErrorCollection.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** PgClientErrorCollection.cs 22 Aug 2003 15:13:36 -0000 1.2
--- PgClientErrorCollection.cs 14 Dec 2003 15:07:13 -0000 1.3
***************
*** 1,97 ****
! /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+
! * Copyright (C) 2003 Carlos Guzmán Álvarez
! *
! * This library is free software; you can redistribute it and/or
! * modify it under the terms of the GNU Lesser General Public
! * License as published by the Free Software Foundation; either
! * version 2.1 of the License, or (at your option) any later version.
! *
! * This library is distributed in the hope that it will be useful,
! * but WITHOUT ANY WARRANTY; without even the implied warranty of
! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
! * Lesser General Public License for more details.
! *
! * You should have received a copy of the GNU Lesser General Public
! * License along with this library; if not, write to the Free Software
! * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
! */
!
! using System;
! using System.Collections;
! using System.Globalization;
!
! namespace PostgreSql.Data.NPgClient
! {
! internal sealed class PgClientErrorCollection : ArrayList
! {
! #region PROPERTIES
!
! public PgClientError this[string errorMessage]
! {
! get { return (PgClientError)this[IndexOf(errorMessage)]; }
! set { this[IndexOf(errorMessage)] = (PgClientError)value; }
! }
!
! public new PgClientError this[int errorIndex]
! {
! get { return (PgClientError)base[errorIndex]; }
! set { base[errorIndex] = (PgClientError)value; }
! }
!
! #endregion
!
! #region METHODS
!
! public bool Contains(string errorMessage)
! {
! return(-1 != IndexOf(errorMessage));
! }
!
! public int IndexOf(string errorMessage)
! {
! int index = 0;
! foreach(PgClientError item in this)
! {
! if (cultureAwareCompare(item.Message, errorMessage))
! {
! return index;
! }
! index++;
! }
! return -1;
! }
!
! public void RemoveAt(string errorMessage)
! {
! RemoveAt(IndexOf(errorMessage));
! }
!
! public PgClientError Add(PgClientError error)
! {
! base.Add(error);
!
! return error;
! }
!
! public PgClientError Add(string severity, string message, string code)
! {
! PgClientError error = new PgClientError(severity, code, message);
!
! return Add(error);
! }
!
! private bool cultureAwareCompare(string strA, string strB)
! {
! try
! {
! return CultureInfo.CurrentCulture.CompareInfo.Compare(strA, strB, CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth | CompareOptions.IgnoreCase) == 0 ? true : false;
! }
! catch (Exception)
! {
! return strA.ToUpper() == strB.ToUpper() ? true : false;
! }
! }
!
! #endregion
! }
! }
--- 1,97 ----
! /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+
! * Copyright (C) 2003 Carlos Guzmán Álvarez
! *
! * This library is free software; you can redistribute it and/or
! * modify it under the terms of the GNU Lesser General Public
! * License as published by the Free Software Foundation; either
! * version 2.1 of the License, or (at your option) any later version.
! *
! * This library is distributed in the hope that it will be useful,
! * but WITHOUT ANY WARRANTY; without even the implied warranty of
! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
! * Lesser General Public License for more details.
! *
! * You should have received a copy of the GNU Lesser General Public
! * License along with this library; if not, write to the Free Software
! * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
! */
!
! using System;
! using System.Collections;
! using System.Globalization;
!
! namespace PostgreSql.Data.NPgClient
! {
! internal sealed class PgClientErrorCollection : ArrayList
! {
! #region Properties
!
! public PgClientError this[string errorMessage]
! {
! get { return (PgClientError)this[IndexOf(errorMessage)]; }
! set { this[IndexOf(errorMessage)] = (PgClientError)value; }
! }
!
! public new PgClientError this[int errorIndex]
! {
! get { return (PgClientError)base[errorIndex]; }
! set { base[errorIndex] = (PgClientError)value; }
! }
!
! #endregion
!
! #region Methods
!
! public bool Contains(string errorMessage)
! {
! return(-1 != IndexOf(errorMessage));
! }
!
! public int IndexOf(string errorMessage)
! {
! int index = 0;
! foreach(PgClientError item in this)
! {
! if (cultureAwareCompare(item.Message, errorMessage))
! {
! return index;
! }
! index++;
! }
! return -1;
! }
!
! public void RemoveAt(string errorMessage)
! {
! RemoveAt(IndexOf(errorMessage));
! }
!
! public PgClientError Add(PgClientError error)
! {
! base.Add(error);
!
! return error;
! }
!
! public PgClientError Add(string severity, string message, string code)
! {
! PgClientError error = new PgClientError(severity, code, message);
!
! return Add(error);
! }
!
! private bool cultureAwareCompare(string strA, string strB)
! {
! try
! {
! return CultureInfo.CurrentCulture.CompareInfo.Compare(strA, strB, CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth | CompareOptions.IgnoreCase) == 0 ? true : false;
! }
! catch (Exception)
! {
! return strA.ToUpper() == strB.ToUpper() ? true : false;
! }
! }
!
! #endregion
! }
! }
Index: PgClientException.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/NPgClient/PgClientException.cs,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** PgClientException.cs 2 Aug 2003 19:43:02 -0000 1.1.1.1
--- PgClientException.cs 14 Dec 2003 15:07:13 -0000 1.2
***************
*** 1,61 ****
! /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+
! * Copyright (C) 2003 Carlos Guzmán Álvarez
! *
! * This library is free software; you can redistribute it and/or
! * modify it under the terms of the GNU Lesser General Public
! * License as published by the Free Software Foundation; either
! * version 2.1 of the License, or (at your option) any later version.
! *
! * This library is distributed in the hope that it will be useful,
! * but WITHOUT ANY WARRANTY; without even the implied warranty of
! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
! * Lesser General Public License for more details.
! *
! * You should have received a copy of the GNU Lesser General Public
! * License along with this library; if not, write to the Free Software
! * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
! */
!
! using System;
! using System.Text;
!
! namespace PostgreSql.Data.NPgClient
! {
! internal class PgClientException : Exception
! {
! #region FIELDS
!
! private string message;
! private PgClientErrorCollection errors;
!
! #endregion
!
! #region PROPERTIES
!
! public new string Message
! {
! get { return message; }
! }
!
! public PgClientErrorCollection Errors
! {
! get { return errors; }
! }
!
! #endregion
!
! #region CONSTRUCTORS
!
! public PgClientException() : base()
! {
! errors = new PgClientErrorCollection();
! }
!
! public PgClientException(string message) : this()
! {
! this.message = message;
! }
!
! #endregion
! }
! }
--- 1,61 ----
! /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+
! * Copyright (C) 2003 Carlos Guzmán Álvarez
! *
! * This library is free software; you can redistribute it and/or
! * modify it under the terms of the GNU Lesser General Public
! * License as published by the Free Software Foundation; either
! * version 2.1 of the License, or (at your option) any later version.
! *
! * This library is distributed in the hope that it will be useful,
! * but WITHOUT ANY WARRANTY; without even the implied warranty of
! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
! * Lesser General Public License for more details.
! *
! * You should have received a copy of the GNU Lesser General Public
! * License along with this library; if not, write to the Free Software
! * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
! */
!
! using System;
! using System.Text;
!
! namespace PostgreSql.Data.NPgClient
! {
! internal class PgClientException : Exception
! {
! #region Fields
!
! private string message;
! private PgClientErrorCollection errors;
!
! #endregion
!
! #region Properties
!
! public new string Message
! {
! get { return message; }
! }
!
! public PgClientErrorCollection Errors
! {
! get { return errors; }
! }
!
! #endregion
!
! #region Constructors
!
! public PgClientException() : base()
! {
! errors = new PgClientErrorCollection();
! }
!
! public PgClientException(string message) : this()
! {
! this.message = message;
! }
!
! #endregion
! }
! }
Index: PgConnectionParams.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/NPgClient/PgConnectionParams.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** PgConnectionParams.cs 15 Aug 2003 17:50:09 -0000 1.2
--- PgConnectionParams.cs 14 Dec 2003 15:07:13 -0000 1.3
***************
*** 1,121 ****
! /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+
! * Copyright (C) 2003 Carlos Guzmán Álvarez
! *
! * This library is free software; you can redistribute it and/or
! * modify it under the terms of the GNU Lesser General Public
! * License as published by the Free Software Foundation; either
! * version 2.1 of the License, or (at your option) any later version.
! *
! * This library is distributed in the hope that it will be useful,
! * but WITHOUT ANY WARRANTY; without even the implied warranty of
! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
! * Lesser General Public License for more details.
! *
! * You should have received a copy of the GNU Lesser General Public
! * License along with this library; if not, write to the Free Software
! * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
! */
!
! using System;
! using System.Text;
!
! namespace PostgreSql.Data.NPgClient
! {
! internal class PgConnectionParams
! {
! #region FIELDS
!
! private string serverName;
! private string database;
! private string userName;
! private string userPassword;
! private int serverPort;
! private int packetSize;
! private int timeout;
! private bool pooling;
! private Encoding encoding;
! private bool ssl;
!
! #endregion
!
! #region PROPERTIES
!
! public string ServerName
! {
! get { return serverName; }
! set { serverName = value; }
! }
!
! public string Database
! {
! get { return database; }
! set { database = value; }
! }
!
! public string UserName
! {
! get { return userName; }
! set { userName = value; }
! }
!
! public string UserPassword
! {
! get { return userPassword; }
! set { userPassword = value; }
! }
!
! public int PacketSize
! {
! get { return packetSize; }
! set { packetSize = value; }
! }
!
! public int ServerPort
! {
! get { return serverPort; }
! set { serverPort = value; }
! }
!
! public Encoding Encoding
! {
! get { return encoding; }
! set { encoding = value; }
! }
!
! public int Timeout
! {
! get { return timeout; }
! set { timeout = value; }
! }
!
! public bool Pooling
! {
! get { return pooling; }
! set { pooling = value; }
! }
!
! public bool SSL
! {
! get { return ssl; }
! set { ssl = value; }
! }
!
! #endregion
!
! #region CONSTRUCTORS
!
! public PgConnectionParams()
! {
! serverName = "localhost";
! userName = "postgres";
! userPassword = "postgres";
! serverPort = 5432;
! packetSize = 8192;
! pooling = true;
! timeout = 15;
! encoding = Encoding.Default;
! }
!
! #endregion
! }
}
--- 1,121 ----
! /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+
! * Copyright (C) 2003 Carlos Guzmán Álvarez
! *
! * This library is free software; you can redistribute it and/or
! * modify it under the terms of the GNU Lesser General Public
! * License as published by the Free Software Foundation; either
! * version 2.1 of the License, or (at your option) any later version.
! *
! * This library is distributed in the hope that it will be useful,
! * but WITHOUT ANY WARRANTY; without even the implied warranty of
! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
! * Lesser General Public License for more details.
! *
! * You should have received a copy of the GNU Lesser General Public
! * License along with this library; if not, write to the Free Software
! * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
! */
!
! using System;
! using System.Text;
!
! namespace PostgreSql.Data.NPgClient
! {
! internal class PgConnectionParams
! {
! #region Fields
!
! private string serverName;
! private string database;
! private string userName;
! private string userPassword;
! private int serverPort;
! private int packetSize;
! private int timeout;
! private bool pooling;
! private Encoding encoding;
! private bool ssl;
!
! #endregion
!
! #region Properties
!
! public string ServerName
! {
! get { return serverName; }
! set { serverName = value; }
! }
!
! public string Database
! {
! get { return database; }
! set { database = value; }
! }
!
! public string UserName
! {
! get { return userName; }
! set { userName = value; }
! }
!
! public string UserPassword
! {
! get { return userPassword; }
! set { userPassword = value; }
! }
!
! public int PacketSize
! {
! get { return packetSize; }
! set { packetSize = value; }
! }
!
! public int ServerPort
! {
! get { return serverPort; }
! set { serverPort = value; }
! }
!
! public Encoding Encoding
! {
! get { return encoding; }
! set { encoding = value; }
! }
!
! public int Timeout
! {
! get { return timeout; }
! set { timeout = value; }
! }
!
! public bool Pooling
! {
! get { return pooling; }
! set { pooling = value; }
! }
!
! public bool SSL
! {
! get { return ssl; }
! set { ssl = value; }
! }
!
! #endregion
!
! #region Constructors
!
! public PgConnectionParams()
! {
! serverName = "localhost";
! userName = "postgres";
! userPassword = "postgres";
! serverPort = 5432;
! packetSize = 8192;
! pooling = true;
! timeout = 15;
! encoding = Encoding.Default;
! }
!
! #endregion
! }
}
Index: PgDbClient.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/NPgClient/PgDbClient.cs,v
retrieving revision 1.38
retrieving revision 1.39
diff -C2 -d -r1.38 -r1.39
*** PgDbClient.cs 23 Nov 2003 13:24:37 -0000 1.38
--- PgDbClient.cs 14 Dec 2003 15:07:13 -0000 1.39
***************
*** 1,852 ****
! /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+
! * Copyright (C) 2003 Carlos Guzmán Álvarez
! *
! * This library is free software; you can redistribute it and/or
! * modify it under the terms of the GNU Lesser General Public
! * License as published by the Free Software Foundation; either
! * version 2.1 of the License, or (at your option) any later version.
! *
! * This library is distributed in the hope that it will be useful,
! * but WITHOUT ANY WARRANTY; without even the implied warranty of
[...1675 lines suppressed...]
! private void detach()
! {
! // Close streams
! if (sslStream != null)
! {
! sslStream.Close();
! }
! if (networkStream != null)
! {
! networkStream.Close();
! }
! if (socket != null)
! {
! socket.Close();
! }
! }
!
! #endregion
! }
! }
Index: PgFieldDescriptor.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/NPgClient/PgFieldDescriptor.cs,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** PgFieldDescriptor.cs 2 Aug 2003 19:43:02 -0000 1.1.1.1
--- PgFieldDescriptor.cs 14 Dec 2003 15:07:13 -0000 1.2
***************
*** 1,91 ****
! /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+
! * Copyright (C) 2003 Carlos Guzmán Álvarez
! *
! * This library is free software; you can redistribute it and/or
! * modify it under the terms of the GNU Lesser General Public
! * License as published by the Free Software Foundation; either
! * version 2.1 of the License, or (at your option) any later version.
! *
! * This library is distributed in the hope that it will be useful,
! * but WITHOUT ANY WARRANTY; without even the implied warranty of
! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
! * Lesser General Public License for more details.
! *
! * You should have received a copy of the GNU Lesser General Public
! * License along with this library; if not, write to the Free Software
! * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
! */
!
! using System;
!
! namespace PostgreSql.Data.NPgClient
! {
! internal class PgFieldDescriptor
! {
! #region FIELDS
!
! private string fieldName;
! private int oidTable;
! private short oidNumber;
! private PgType dataType;
! private short dataTypeSize;
! private int typeModifier;
! private short formatCode;
!
! #endregion
!
! #region PROPERTIES
!
! public string FieldName
! {
! get { return fieldName; }
! set { fieldName = value; }
! }
!
! public int OidTable
! {
! get { return oidTable; }
! set { oidTable = value; }
! }
!
! public short OidNumber
! {
! get { return oidNumber; }
! set { oidNumber = value; }
! }
!
! public PgType DataType
! {
! get { return dataType; }
! set { dataType = value; }
! }
!
! public short DataTypeSize
! {
! get { return dataTypeSize; }
! set { dataTypeSize = value; }
! }
!
! public int TypeModifier
! {
! get { return typeModifier; }
! set { typeModifier = value; }
! }
!
! public short FormatCode
! {
! get { return formatCode; }
! set { formatCode = value; }
! }
!
! #endregion
!
! #region CONSTRUCTORS
!
! public PgFieldDescriptor()
! {
! }
!
! #endregion
! }
! }
--- 1,91 ----
! /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+
! * Copyright (C) 2003 Carlos Guzmán Álvarez
! *
! * This library is free software; you can redistribute it and/or
! * modify it under the terms of the GNU Lesser General Public
! * License as published by the Free Software Foundation; either
! * version 2.1 of the License, or (at your option) any later version.
! *
! * This library is distributed in the hope that it will be useful,
! * but WITHOUT ANY WARRANTY; without even the implied warranty of
! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
! * Lesser General Public License for more details.
! *
! * You should have received a copy of the GNU Lesser General Public
! * License along with this library; if not, write to the Free Software
! * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
! */
!
! using System;
!
! namespace PostgreSql.Data.NPgClient
! {
! internal class PgFieldDescriptor
! {
! #region Fields
!
! private string fieldName;
! private int oidTable;
! private short oidNumber;
! private PgType dataType;
! private short dataTypeSize;
! private int typeModifier;
! private short formatCode;
!
! #endregion
!
! #region Properties
!
! public string FieldName
! {
! get { return fieldName; }
! set { fieldName = value; }
! }
!
! public int OidTable
! {
! get { return oidTable; }
! set { oidTable = value; }
! }
!
! public short OidNumber
! {
! get { return oidNumber; }
! set { oidNumber = value; }
! }
!
! public PgType DataType
! {
! get { return dataType; }
! set { dataType = value; }
! }
!
! public short DataTypeSize
! {
! get { return dataTypeSize; }
! set { dataTypeSize = value; }
! }
!
! public int TypeModifier
! {
! get { return typeModifier; }
! set { typeModifier = value; }
! }
!
! public short FormatCode
! {
! get { return formatCode; }
! set { formatCode = value; }
! }
!
! #endregion
!
! #region Constructors
!
! public PgFieldDescriptor()
! {
! }
!
! #endregion
! }
! }
Index: PgOutputPacket.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/NPgClient/PgOutputPacket.cs,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** PgOutputPacket.cs 21 Nov 2003 16:59:23 -0000 1.20
--- PgOutputPacket.cs 14 Dec 2003 15:07:13 -0000 1.21
***************
*** 1,488 ****
! /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+
! * Copyright (C) 2003 Carlos Guzmán Álvarez
! *
! * This library is free software; you can redistribute it and/or
! * modify it under the terms of the GNU Lesser General Public
! * License as published by the Free Software Foundation; either
! * version 2.1 of the License, or (at your option) any later version.
! *
! * This library is distributed in the hope that it will be useful,
! * but WITHOUT ANY WARRANTY; without even the implied warranty of
! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
! * Lesser General Public License for more details.
! *
! * You should have received a copy of the GNU Lesser General Public
! * License along with this library; if not, write to the Free Software
! * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
! */
!
! using System;
! using System.Data;
! using System.Net;
! using System.IO;
! using System.Text;
! using System.Globalization;
!
! using PostgreSql.Data.PgTypes;
!
! namespace PostgreSql.Data.NPgClient
! {
! internal class PgOutputPacket : BinaryWriter
! {
! #region FIELDS
!
! private Encoding encoding;
!
! #endregion
!
! #region PROPERTIES
!
! public long Position
! {
! get { return ((MemoryStream)BaseStream).Position; }
! }
!
! public long Length
! {
! get { return ((MemoryStream)BaseStream).Length; }
! }
!
! #endregion
!
! #region CONSTRUCTORS
!
! public PgOutputPacket() : base(new MemoryStream())
! {
! this.encoding = Encoding.Default;
! Write(new byte[0]);
! }
!
! public PgOutputPacket(Encoding encoding) : base(new MemoryStream(), encoding)
! {
! this.encoding = encoding;
! this.Write(new byte[0]);
! }
!
! #endregion
!
! #region STRING_TYPES_WRITE
!
! public void WriteString(string data)
! {
! if (!data.EndsWith(PgCodes.NULL_TERMINATOR.ToString()))
! {
! data += PgCodes.NULL_TERMINATOR;
! }
! this.Write(encoding.GetBytes(data));
! }
!
! #endregion
!
! #region NUMERIC_TYPES_WRITE
!
! public void WriteShort(short val)
! {
! this.Write((short)IPAddress.HostToNetworkOrder(val));
! }
!
! public void WriteInt(int val)
! {
! this.Write((int)IPAddress.HostToNetworkOrder(val));
! }
!
! public void WriteLong(long val)
! {
! this.Write((long)IPAddress.HostToNetworkOrder(val));
! }
!
! public void WriteFloat(float val)
! {
! FloatLayout floatValue = new FloatLayout();
!
! floatValue.f = val;
! floatValue.i0 = IPAddress.HostToNetworkOrder(floatValue.i0);
!
! this.Write(floatValue.f);
! }
!
! public void WriteDouble(double val)
! {
! DoubleLayout doubleValue = new DoubleLayout();
! int temp;
!
! doubleValue.d = val;
! doubleValue.i0 = IPAddress.HostToNetworkOrder(doubleValue.i0);
! doubleValue.i4 = IPAddress.HostToNetworkOrder(doubleValue.i4);
!
! temp = doubleValue.i0;
! doubleValue.i0 = doubleValue.i4;
! doubleValue.i4 = temp;
!
! this.Write(doubleValue.d);
! }
!
! #endregion
!
! #region DATE_TIME_WRITE
!
! public void WriteDate(DateTime date)
! {
! TimeSpan days = date.Subtract(PgCodes.BASE_DATE);
!
! this.WriteInt(days.Days);
! }
!
! public void WriteInterval(TimeSpan interval)
! {
! int months = (interval.Days / 30);
! int days = (interval.Days % 30);
!
! this.WriteDouble(interval.Subtract(TimeSpan.FromDays(months * 30)).TotalSeconds);
! this.WriteInt(months);
! }
!
! public void WriteTime(DateTime time)
! {
! DateTime realTime = new DateTime(PgCodes.BASE_DATE.Year,
! PgCodes.BASE_DATE.Month,
! PgCodes.BASE_DATE.Day,
! time.Hour,
! time.Minute,
! time.Second,
! time.Millisecond);
!
! TimeSpan seconds = realTime.Subtract(PgCodes.BASE_DATE);
!
! this.WriteDouble(seconds.TotalSeconds);
! }
!
! public void WriteTimeWithTZ(DateTime time)
! {
! DateTime realTime = new DateTime(PgCodes.BASE_DATE.Year,
! PgCodes.BASE_DATE.Month,
! PgCodes.BASE_DATE.Day,
! time.Hour,
! time.Minute,
! time.Second,
! time.Millisecond);
!
! TimeSpan seconds = realTime.Subtract(PgCodes.BASE_DATE);
!
! this.WriteDouble(seconds.TotalSeconds);
! this.WriteInt((-1)*Int32.Parse(time.ToString("zz"))*3600);
! }
!
! public void WriteTimestamp(DateTime timestamp)
! {
! TimeSpan days = timestamp.Subtract(PgCodes.BASE_DATE);
!
! this.WriteDouble(days.TotalSeconds);
! }
!
! public void WriteTimestampWithTZ(DateTime timestamp)
! {
! this.WriteTimestamp(timestamp);
! }
!
! #endregion
!
! #region GEOMETRIC_TYPES_WRITE
!
! public void WritePoint(PgPoint point)
! {
! this.WriteDouble(point.X);
! this.WriteDouble(point.Y);
! }
!
! public void WriteCircle(PgCircle circle)
! {
! this.WritePoint(circle.Center);
! this.WriteDouble(circle.Radius);
! }
!
! public void WriteLine(PgLine line)
! {
! this.WritePoint(line.StartPoint);
! this.WritePoint(line.EndPoint);
! }
!
! public void WriteLSeg(PgLSeg lseg)
! {
! this.WritePoint(lseg.StartPoint);
! this.WritePoint(lseg.EndPoint);
! }
!
! public void WriteBox(PgBox box)
! {
! this.WritePoint(box.UpperRight);
! this.WritePoint(box.LowerLeft);
! }
!
! public void WritePolygon(PgPolygon polygon)
! {
! this.WriteInt(polygon.Points.Length);
! for (int i = 0; i < polygon.Points.Length; i++)
! {
! this.WritePoint(polygon.Points[i]);
! }
! }
!
! public void WritePath(PgPath path)
! {
! this.Write(path.IsClosedPath);
! this.WriteInt(path.Points.Length);
! for (int i = 0; i < path.Points.Length; i++)
! {
! this.WritePoint(path.Points[i]);
! }
! }
!
! #endregion
!
! #region PARAMETER_WRITE
!
! public void WriteParameter(PgParameter parameter)
! {
! int size = parameter.DataType.Size;
!
! if (parameter.Value == System.DBNull.Value ||
! parameter.Value == null)
! {
! // -1 indicates a NULL argument value
! this.WriteInt(-1);
! }
! else
! {
! if (parameter.DataType.DataType == PgDataType.Binary ||
! parameter.DataType.DataType == PgDataType.Array ||
! parameter.DataType.DataType == PgDataType.Vector)
! {
! // Handle this type as Array values
! System.Array array = (System.Array)parameter.Value;
!
! // Get array elements type info
! PgType elementType = PgDbClient.Types[parameter.DataType.ElementType];
! size = elementType.Size;
!
! // Create a new packet for write array parameter information
! PgOutputPacket packet = new PgOutputPacket();
!
! // Write the number of dimensions
! packet.WriteInt(array.Rank);
!
! // Write flags (always 0)
! packet.WriteInt(0);
!
! // Write base type of the array elements
! packet.WriteInt(parameter.DataType.ElementType);
!
! // Write lengths and lower bounds
! for (int i = 0; i < array.Rank; i ++)
! {
! packet.WriteInt(array.GetLength(i));
! packet.WriteInt(array.GetLowerBound(i) + 1);
! }
!
! // Write array values
! foreach (object element in array)
! {
! this.writeParameter(packet, elementType.DataType, size, element);
! }
!
! // Write parameter size
! this.WriteInt(packet.GetByteCount());
! // Write parameter data
! this.Write(packet.ToArray());
! }
! else
! {
! this.writeParameter(this, parameter.DataType.DataType, size, parameter.Value);
! }
! }
! }
!
! #endregion
!
! #region PRIVATE_METHODS
!
! private void writeParameter(PgOutputPacket packet, PgDataType dataType, int size, object value)
! {
! switch (dataType)
! {
! case PgDataType.Binary:
! packet.WriteInt(((byte[])value).Length);
! packet.Write((byte[])value);
! break;
!
! case PgDataType.Byte:
! packet.WriteInt(size);
! packet.Write((byte)value);
! break;
!
! case PgDataType.Int2:
! packet.WriteInt(size);
! packet.WriteShort(Convert.ToInt16(value));
! break;
!
! case PgDataType.Int4:
! packet.WriteInt(size);
! packet.WriteInt(Convert.ToInt32(value));
! break;
!
! case PgDataType.Int8:
! packet.WriteInt(size);
! packet.WriteLong(Convert.ToInt64(value));
! break;
!
! case PgDataType.Interval:
! packet.WriteInt(size);
! packet.WriteInterval(TimeSpan.Parse(value.ToString()));
! break;
!
! case PgDataType.Decimal:
! {
! string paramValue = value.ToString();
! packet.WriteInt(encoding.GetByteCount(paramValue));
! packet.Write(paramValue.ToCharArray());
! }
! break;
!
! case PgDataType.Double:
! packet.WriteInt(size);
! packet.WriteDouble(Convert.ToDouble(value));
! break;
!
! case PgDataType.Float:
! packet.WriteInt(size);
! packet.WriteFloat(Convert.ToSingle(value));
! break;
!
! case PgDataType.Currency:
! packet.WriteInt(size);
! packet.WriteInt(Convert.ToInt32(Convert.ToSingle(value)*100));
! break;
!
! case PgDataType.Date:
! packet.WriteInt(size);
! packet.WriteDate(Convert.ToDateTime(value));
! break;
!
! case PgDataType.Time:
! packet.WriteInt(size);
! packet.WriteTime(Convert.ToDateTime(value));
! break;
!
! case PgDataType.TimeWithTZ:
! packet.WriteInt(size);
! packet.WriteTimeWithTZ(Convert.ToDateTime(value));
! break;
!
! case PgDataType.Timestamp:
! packet.WriteInt(size);
! packet.WriteTimestamp(Convert.ToDateTime(value));
! break;
!
! case PgDataType.TimestampWithTZ:
! packet.WriteInt(size);
! packet.WriteTimestampWithTZ(Convert.ToDateTime(value));
! break;
!
! case PgDataType.Char:
! case PgDataType.VarChar:
! {
! string paramValue = value.ToString() + PgCodes.NULL_TERMINATOR;
! packet.WriteInt(encoding.GetByteCount(paramValue));
! packet.WriteString(paramValue);
! }
! break;
!
! case PgDataType.Point:
! packet.WriteInt(size);
! packet.WritePoint((PgPoint)value);
! break;
!
! case PgDataType.Circle:
! packet.WriteInt(size);
! packet.WriteCircle((PgCircle)value);
! break;
!
! case PgDataType.Line:
! packet.WriteInt(size);
! packet.WriteLine((PgLine)value);
! break;
!
! case PgDataType.LSeg:
! packet.WriteInt(size);
! packet.WriteLSeg((PgLSeg)value);
! break;
!
! case PgDataType.Box:
! packet.WriteInt(size);
! packet.WriteBox((PgBox)value);
! break;
!
! case PgDataType.Polygon:
! PgPolygon polygon = (PgPolygon)value;
!
! packet.WriteInt((size*polygon.Points.Length) + 4);
! packet.WritePolygon(polygon);
! break;
!
! case PgDataType.Path:
! PgPath path = (PgPath)value;
!
! packet.WriteInt((size*path.Points.Length) + 5);
! packet.WritePath(path);
! break;
! }
! }
!
! #endregion
!
! #region STREAM_METHODS
!
! public int GetByteCount()
! {
! return (int)((MemoryStream)BaseStream).Length;
! }
!
! public byte[] ToArray()
! {
! return ((MemoryStream)BaseStream).ToArray();
! }
!
! public void Reset()
! {
! ((MemoryStream)BaseStream).SetLength(0);
! ((MemoryStream)BaseStream).Position = 0;
! }
!
! #endregion
!
! #region PACKET_BYTES
!
! public byte[] GetSimplePacketBytes()
! {
! PgOutputPacket packet = new PgOutputPacket();
!
! // Write packet contents
! packet.WriteInt(GetByteCount() + 4);
! packet.Write(ToArray());
!
! return packet.ToArray();
! }
!
! public byte[] GetPacketBytes(char format)
! {
! PgOutputPacket packet = new PgOutputPacket();
!
! packet.Write((byte)format);
! packet.WriteInt(GetByteCount() + 4);
! packet.Write(ToArray());
!
! return packet.ToArray();
! }
!
! #endregion
! }
}
--- 1,488 ----
! /* PgSqlClient - ADO.NET Data Provider for PostgreSQL 7.4+
! * Copyright (C) 2003 Carlos Guzmán Álvarez
! *
! * This library is free software; you can redistribute it and/or
! * modify it under the terms of the GNU Lesser General Public
! * License as published by the Free Software Foundation; either
! * version 2.1 of the License, or (at your option) any later version.
! *
! * This library is distributed in the hope that it will be useful,
! * but WITHOUT ANY WARRANTY; without even the implied warranty of
! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
! * Lesser General Public License for more details.
! *
! * You should have received a copy of the GNU Lesser General Public
! * License along with this library; if not, write to the Free Software
! * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
! */
!
! using System;
! using System.Data;
! using System.Net;
! using System.IO;
! using System.Text;
! using System.Globalization;
!
! using PostgreSql.Data.PgTypes;
!
! namespace PostgreSql.Data.NPgClient
! {
! internal class PgOutputPacket : BinaryWriter
! {
! #region Fields
!
! private Encoding encoding;
!
! #endregion
!
! #region Properties
!
! public long Position
! {
! get { return ((MemoryStream)BaseStream).Position; }
! }
!
! public long Length
! {
! get { return ((MemoryStream)BaseStream).Length; }
! }
!
! #endregion
!
! #region Constructors
!
! public PgOutputPacket() : base(new MemoryStream())
! {
! this.encoding = Encoding.Default;
! Write(new byte[0]);
! }
!
! public PgOutputPacket(Encoding encoding) : base(new MemoryStream(), encoding)
! {
! this.encoding = encoding;
! this.Write(new byte[0]);
! }
!
! #endregion
!
! #region STRING_TYPES_WRITE
!
! public void WriteString(string data)
! {
! if (!data.EndsWith(PgCodes.NULL_TERMINATOR.ToString()))
! {
! data += PgCodes.NULL_TERMINATOR;
! }
! this.Write(encoding.GetBytes(data));
! }
!
! #endregion
!
! #region NUMERIC_TYPES_WRITE
!
! public void WriteShort(short val)
! {
! this.Write((short)IPAddress.HostToNetworkOrder(val));
! }
!
! public void WriteInt(int val)
! {
! this.Write((int)IPAddress.HostToNetworkOrder(val));
! }
!
! public void WriteLong(long val)
! {
! this.Write((long)IPAddress.HostToNetworkOrder(val));
! }
!
! public void WriteFloat(float val)
! {
! FloatLayout floatValue = new FloatLayout();
!
! floatValue.f = val;
! floatValue.i0 = IPAddress.HostToNetworkOrder(floatValue.i0);
!
! this.Write(floatValue.f);
! }
!
! public void WriteDouble(double val)
! {
! DoubleLayout doubleValue = new DoubleLayout();
! int temp;
!
! doubleValue.d = val;
! doubleValue.i0 = IPAddress.HostToNetworkOrder(doubleValue.i0);
! doubleValue.i4 = IPAddress.HostToNetworkOrder(doubleValue.i4);
!
! temp = doubleValue.i0;
! doubleValue.i0 = doubleValue.i4;
! doubleValue.i4 = temp;
!
! this.Write(doubleValue.d);
! }
!
! #endregion
!
! #region DATE_TIME_WRITE
!
! public void WriteDate(DateTime date)
! {
! TimeSpan days = date.Subtract(PgCodes.BASE_DATE);
!
! this.WriteInt(days.Days);
! }
!
! public void WriteInterval(TimeSpan interval)
! {
! int months = (interval.Days / 30);
! int days = (interval.Days % 30);
!
! this.WriteDouble(interval.Subtract(TimeSpan.FromDays(months * 30)).TotalSeconds);
! this.WriteInt(months);
! }
!
! public void WriteTime(DateTime time)
! {
! DateTime realTime = new DateTime(PgCodes.BASE_DATE.Year,
! PgCodes.BASE_DATE.Month,
! PgCodes.BASE_DATE.Day,
! time.Hour,
! time.Minute,
! time.Second,
! time.Millisecond);
!
! TimeSpan seconds = realTime.Subtract(PgCodes.BASE_DATE);
!
! this.WriteDouble(seconds.TotalSeconds);
! }
!
! public void WriteTimeWithTZ(DateTime time)
! {
! DateTime realTime = new DateTime(PgCodes.BASE_DATE.Year,
! PgCodes.BASE_DATE.Month,
! PgCodes.BASE_DATE.Day,
! time.Hour,
! time.Minute,
! time.Second,
! time.Millisecond);
!
! TimeSpan seconds = realTime.Subtract(PgCodes.BASE_DATE);
!
! this.WriteDouble(seconds.TotalSeconds);
! this.WriteInt((-1)*Int32.Parse(time.ToString("zz"))*3600);
! }
!
! public void WriteTimestamp(DateTime timestamp)
! {
! TimeSpan days = timestamp.Subtract(PgCodes.BASE_DATE);
!
! this.WriteDouble(days.TotalSeconds);
! }
!
! public void WriteTimestampWithTZ(DateTime timestamp)
! {
! this.WriteTimestamp(timestamp);
! }
!
! #endregion
!
! #region GEOMETRIC_TYPES_WRITE
!
! public void WritePoint(PgPoint point)
! {
! this.WriteDouble(point.X);
! this.WriteDouble(point.Y);
! }
!
! public void WriteCircle(PgCircle circle)
! {
! this.WritePoint(circle.Center);
! this.WriteDouble(circle.Radius);
! }
!
! public void WriteLine(PgLine line)
! {
! this.WritePoint(line.StartPoint);
! this.WritePoint(line.EndPoint);
! }
!
! public void WriteLSeg(PgLSeg lseg)
! {
! this.WritePoint(lseg.StartPoint);
! this.WritePoint(lseg.EndPoint);
! }
!
! public void WriteBox(PgBox box)
! {
! this.WritePoint(box.UpperRight);
! this.WritePoint(box.LowerLeft);
! }
!
! public void WritePolygon(PgPolygon polygon)
! {
! this.WriteInt(polygon.Points.Length);
! for (int i = 0; i < polygon.Points.Length; i++)
! {
! this.WritePoint(polygon.Points[i]);
! }
! }
!
! public void WritePath(PgPath path)
! {
! this.Write(path.IsClosedPath);
! this.WriteInt(path.Points.Length);
! for (int i = 0; i < path.Points.Length; i++)
! {
! this.WritePoint(path.Points[i]);
! }
! }
!
! #endregion
!
! #region PARAMETER_WRITE
!
! public void WriteParameter(PgParameter parameter)
! {
! int size = parameter.DataType.Size;
!
! if (parameter.Value == System.DBNull.Value ||
! parameter.Value == null)
! {
! // -1 indicates a NULL argument value
! this.WriteInt(-1);
! }
! else
! {
! if (parameter.DataType.DataType == PgDataType.Binary ||
! parameter.DataType.DataType == PgDataType.Array ||
! parameter.DataType.DataType == PgDataType.Vector)
! {
! // Handle this type as Array values
! System.Array array = (System.Array)parameter.Value;
!
! // Get array elements type info
! PgType elementType = PgDbClient.Types[parameter.DataType.ElementType];
! size = elementType.Size;
!
! // Create a new packet for write array parameter information
! PgOutputPacket packet = new PgOutputPacket();
!
! // Write the number of dimensions
! packet.WriteInt(array.Rank);
!
! // Write flags (always 0)
! packet.WriteInt(0);
!
! // Write base type of the array elements
! packet.WriteInt(parameter.DataType.ElementType);
!
! // Write lengths and lower bounds
! for (int i = 0; i < array.Rank; i ++)
! {
! packet.WriteInt(array.GetLength(i));
! packet.WriteInt(array.GetLowerBound(i) + 1);
! }
!
! // Write array values
! foreach (object element in array)
! {
! this.writeParameter(packet, elementType.DataType, size, element);
! }
!
! // Write parameter size
! this.WriteInt(packet.GetByteCount());
! // Write parameter data
! this.Write(packet.ToArray());
! }
! else
! {
! this.writeParameter(this, parameter.DataType.DataType, size, parameter.Value);
! }
! }
! }
!
! #endregion
!
! #region Private Methods
!
! private void writeParameter(PgOutputPacket packet, PgDataType dataType, int size, object value)
! {
! switch (dataType)
! {
! case PgDataType.Binary:
! packet.WriteInt(((byte[])value).Length);
! packet.Write((byte[])value);
! break;
!
! case PgDataType.Byte:
! packet.WriteInt(size);
! packet.Write((byte)value);
! break;
!
! case PgDataType.Int2:
! packet.WriteInt(size);
! packet.WriteShort(Convert.ToInt16(value));
! break;
!
! case PgDataType.Int4:
! packet.WriteInt(size);
! packet.WriteInt(Convert.ToInt32(value));
! break;
!
! case PgDataType.Int8:
! packet.WriteInt(size);
! packet.WriteLong(Convert.ToInt64(value));
! break;
!
! case PgDataType.Interval:
! packet.WriteInt(size);
! packet.WriteInterval(TimeSpan.Parse(value.ToString()));
! break;
!
! case PgDataType.Decimal:
! {
! string paramValue = value.ToString();
! packet.WriteInt(encoding.GetByteCount(paramValue));
! packet.Write(paramValue.ToCharArray());
! }
! break;
!
! case PgDataType.Double:
! packet.WriteInt(size);
! packet.WriteDouble(Convert.ToDouble(value));
! break;
!
! case PgDataType.Float:
! packet.WriteInt(size);
! packet.WriteFloat(Convert.ToSingle(value));
! break;
!
! case PgDataType.Currency:
! packet.WriteInt(size);
! packet.WriteInt(Convert.ToInt32(Convert.ToSingle(value)*100));
! break;
!
! case PgDataType.Date:
! packet.WriteInt(size);
! packet.WriteDate(Convert.ToDateTime(value));
! break;
!
! case PgDataType.Time:
! packet.WriteInt(size);
! packet.WriteTime(Convert.ToDateTime(value));
! break;
!
! case PgDataType.TimeWithTZ:
! packet.WriteInt(size);
! packet.WriteTimeWithTZ(Convert.ToDateTime(value));
! break;
!
! case PgDataType.Timestamp:
! packet.WriteInt(size);
! packet.WriteTimestamp(Convert.ToDateTime(value));
! break;
!
! case PgDataType.TimestampWithTZ:
! packet.WriteInt(size);
! packet.WriteTimestampWithTZ(Convert.ToDateTime(value));
! break;
!
! case PgDataType.Char:
! case PgDataType.VarChar:
! {
! string paramValue = value.ToString() + PgCodes.NULL_TERMINATOR;
! packet.WriteInt(encoding.GetByteCount(paramValue));
! packet.WriteString(paramValue);
! }
! break;
!
! case PgDataType.Point:
! packet.WriteInt(size);
! packet.WritePoint((PgPoint)value);
! break;
!
! case PgDataType.Circle:
! packet.WriteInt(size);
! packet.WriteCircle((PgCircle)value);
! break;
!
! case PgDataType.Line:
! packet.WriteInt(size);
! packet.WriteLine((PgLine)value);
! break;
!
! case PgDataType.LSeg:
! packet.WriteInt(size);
! packet.WriteLSeg((PgLSeg)value);
! break;
!
! case PgDataType.Box:
! packet.WriteInt(size);
! packet.WriteBox((PgBox)value);
! break;
!
! case PgDataType.Polygon:
! PgPolygon polygon = (PgPolygon)value;
!
! ...
[truncated message content] |