Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Moved deprecated library

svn path=/old-code/; revision=152776
  • Loading branch information...
commit 67e6f28e314b28674d549f7d89ada072e28db101 1 parent ee07041
@migueldeicaza migueldeicaza authored
Showing with 40,603 additions and 0 deletions.
  1. +36 −0 FirebirdSql.Data.Firebird/Assembly/AssemblyInfo.cs
  2. +350 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/ArrayBase.cs
  3. +125 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/ArrayDesc.cs
  4. +161 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/BinaryEncoding.cs
  5. +207 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/BlobBase.cs
  6. +33 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/BlobParameterBuffer.cs
  7. +204 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/Charset.cs
  8. +96 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/CharsetCollection.cs
  9. +77 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/DatabaseParameterBuffer.cs
  10. +42 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/DbDataType.cs
  11. +655 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/DbField.cs
  12. +41 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/DbStatementType.cs
  13. +270 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/DbValue.cs
  14. +229 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/Descriptor.cs
  15. +51 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/EventParameterBuffer.cs
  16. +47 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/GlobalizationHelper.cs
  17. +115 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/IDatabase.cs
  18. +54 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/IServiceManager.cs
  19. +79 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/ITransaction.cs
  20. +1,543 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/IscCodes.cs
  21. +119 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/IscError.cs
  22. +56 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/IscErrorCollection.cs
  23. +209 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/IscException.cs
  24. +335 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/IscHelper.cs
  25. +129 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/ParameterBuffer.cs
  26. +238 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/RemoteEvent.cs
  27. BIN  FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/Resources/isc_error_msg.resources
  28. +3,598 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/Resources/isc_error_msg.txt
  29. +75 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/ServiceParameterBuffer.cs
  30. +414 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/StatementBase.cs
  31. +114 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/StringCollection.cs
  32. +37 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/TransactionParameterBuffer.cs
  33. +108 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/TypeDecoder.cs
  34. +108 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/TypeEncoder.cs
  35. +445 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/TypeHelper.cs
  36. +59 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Embedded/ArrayDescMarshal.cs
  37. +120 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Embedded/ArrayDescMarshaler.cs
  38. +479 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Embedded/FbClient.cs
  39. +462 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Embedded/FesArray.cs
  40. +215 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Embedded/FesBlob.cs
  41. +124 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Embedded/FesConnection.cs
  42. +400 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Embedded/FesDatabase.cs
  43. +159 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Embedded/FesServiceManager.cs
  44. +687 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Embedded/FesStatement.cs
  45. +403 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Embedded/FesTransaction.cs
  46. +59 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Embedded/XSQLDA.cs
  47. +433 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Embedded/XsqldaMarshaler.cs
  48. +1 −0  FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird.dll.resources
  49. +137 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird.dll.sources
  50. BIN  FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird.snk
  51. +80 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/ClientFactory.cs
  52. +88 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbCharacterSets.cs
  53. +117 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbCheckConstraints.cs
  54. +120 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbChecksByTable.cs
  55. +87 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbCollations.cs
  56. +109 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbColumnPrivileges.cs
  57. +205 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbColumns.cs
  58. +84 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbDataTypes.cs
  59. +178 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbDbSchema.cs
  60. +160 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbDbSchemaFactory.cs
  61. +172 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbDomains.cs
  62. +124 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbForeignKeys.cs
  63. +124 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbFunctions.cs
  64. +120 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbGenerators.cs
  65. +148 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbIndexes.cs
  66. +69 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbMetaDataCollections.cs
  67. +91 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbPrimaryKeys.cs
  68. +188 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbProcedureParameters.cs
  69. +102 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbProcedurePrivileges.cs
  70. +110 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbProcedures.cs
  71. +136 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbRestrictions.cs
  72. +71 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbRoles.cs
  73. +159 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbTableConstraints.cs
  74. +102 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbTablePrivileges.cs
  75. +146 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbTables.cs
  76. +125 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbTriggers.cs
  77. +91 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbUniqueKeys.cs
  78. +189 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbViewColumnUsage.cs
  79. +104 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbViewPrivileges.cs
  80. +88 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/DbSchema/FbViews.cs
  81. +84 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbCharset.cs
  82. +1,303 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbCommand.cs
  83. +1,060 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbCommandBuilder.cs
  84. +38 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbCommandBuilderBehavior.cs
  85. +876 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbConnection.cs
  86. +383 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbConnectionInternal.cs
  87. +554 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbConnectionPool.cs
  88. +484 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbConnectionString.cs
  89. +350 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbConnectionStringBuilder.cs
  90. +592 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbDataAdapter.cs
  91. +779 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbDataReader.cs
  92. +351 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbDatabaseInfo.cs
  93. +85 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbDbSchemaType.cs
  94. +62 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbDbType.cs
  95. +88 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbError.cs
  96. +133 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbErrorCollection.cs
  97. +124 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbException.cs
  98. +71 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbInfoMessageEventArgs.cs
  99. +407 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbParameter.cs
  100. +335 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbParameterCollection.cs
  101. +194 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbRemoteEvent.cs
  102. +72 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbRemoteEventEventArgs.cs
  103. +55 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbRowUpdatedEventArgs.cs
  104. +56 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbRowUpdatingEventArgs.cs
  105. +613 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbTransaction.cs
  106. +67 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/FbTransactionOptions.cs
  107. +109 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Isql/CommandExecutedEventArgs.cs
  108. +98 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Isql/CommandExecutingEventArgs.cs
  109. +807 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Isql/FbBatchExecution.cs
  110. +257 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Isql/FbScript.cs
  111. +365 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Isql/SqlStatementType.cs
  112. +379 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Isql/StringParser.cs
  113. +126 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbBackup.cs
  114. +62 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbBackupFile.cs
  115. +44 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbBackupFlags.cs
  116. +232 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbConfiguration.cs
  117. +58 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbDatabasesInfo.cs
  118. +68 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbLog.cs
  119. +146 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbRestore.cs
  120. +45 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbRestoreFlags.cs
  121. +256 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbSecurity.cs
  122. +188 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbServerConfig.cs
  123. +130 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbServerProperties.cs
  124. +563 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbService.cs
  125. +39 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbServiceState.cs
  126. +33 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbShutdownMode.cs
  127. +86 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbStatistical.cs
  128. +40 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbStatisticalFlags.cs
  129. +146 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbUserData.cs
  130. +86 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbValidation.cs
  131. +42 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/FbValidationFlags.cs
  132. +59 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird/Services/ServiceOutputEventArgs.cs
  133. +19 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Firebird_test.dll.sources
  134. +561 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Gds/GdsArray.cs
  135. +246 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Gds/GdsBlob.cs
  136. +292 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Gds/GdsConnection.cs
  137. +731 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Gds/GdsDatabase.cs
  138. +190 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Gds/GdsEventManager.cs
  139. +71 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Gds/GdsResponse.cs
  140. +207 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Gds/GdsServiceManager.cs
  141. +787 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Gds/GdsStatement.cs
  142. +371 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Gds/GdsTransaction.cs
  143. +719 −0 FirebirdSql.Data.Firebird/FirebirdSql.Data.Gds/XdrStream.cs
  144. +55 −0 FirebirdSql.Data.Firebird/Makefile
  145. +28 −0 FirebirdSql.Data.Firebird/Test/App.config
  146. +31 −0 FirebirdSql.Data.Firebird/Test/AssemblyInfo.cs
  147. +428 −0 FirebirdSql.Data.Firebird/Test/BaseTest.cs
  148. +1,031 −0 FirebirdSql.Data.Firebird/Test/FbArrayTest.cs
  149. +136 −0 FirebirdSql.Data.Firebird/Test/FbBlobTest.cs
  150. +185 −0 FirebirdSql.Data.Firebird/Test/FbCommandBuilderTest.cs
  151. +485 −0 FirebirdSql.Data.Firebird/Test/FbCommandTest.cs
  152. +162 −0 FirebirdSql.Data.Firebird/Test/FbConnectionTest.cs
  153. +683 −0 FirebirdSql.Data.Firebird/Test/FbDataAdapterTest.cs
  154. +382 −0 FirebirdSql.Data.Firebird/Test/FbDataReaderTest.cs
  155. +73 −0 FirebirdSql.Data.Firebird/Test/FbDatabaseInfoTest.cs
  156. +221 −0 FirebirdSql.Data.Firebird/Test/FbDatabaseSchemaTest.cs
  157. +215 −0 FirebirdSql.Data.Firebird/Test/FbImplicitTransactionTest.cs
  158. +43 −0 FirebirdSql.Data.Firebird/Test/FbParameterCollectionTest.cs
  159. +86 −0 FirebirdSql.Data.Firebird/Test/FbParameterTest.cs
  160. +51 −0 FirebirdSql.Data.Firebird/Test/FbScriptTest.cs
  161. +228 −0 FirebirdSql.Data.Firebird/Test/FbServicesTests.cs
  162. +150 −0 FirebirdSql.Data.Firebird/Test/FbStoredProcCallsTest.cs
  163. +142 −0 FirebirdSql.Data.Firebird/Test/FbTransactionTest.cs
  164. +89 −0 FirebirdSql.Data.Firebird/Test/GuidTest.cs
Sorry, we could not display the entire diff because it was too big.
View
36 FirebirdSql.Data.Firebird/Assembly/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+/*
+ * Firebird ADO.NET Data provider for .NET and Mono
+ *
+ * The contents of this file are subject to the Initial
+ * Developer's Public License Version 1.0 (the "License");
+ * you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ * http://www.ibphoenix.com/main.nfs?a=ibphoenix&l=;PAGES;NAME='ibp_idpl'
+ *
+ * Software distributed under the License is distributed on
+ * an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
+ * express or implied. See the License for the specific
+ * language governing rights and limitations under the License.
+ *
+ * Copyright (c) 2002, 2005 Carlos Guzman Alvarez
+ * All Rights Reserved.
+ */
+
+using System;
+using System.Resources;
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+[assembly: CLSCompliant(true)]
+[assembly: ComVisible(false)]
+[assembly: AssemblyTitle("Firebird .NET Data Provider")]
+[assembly: AssemblyDescription("Firebird .NET Data Provider")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("FirebirdSQL")]
+[assembly: AssemblyProduct("Firebird .NET Data Provider")]
+[assembly: AssemblyCopyright("(c) 2002-2005. Carlos Guzman Alvarez")]
+[assembly: AssemblyVersion("1.7.1.0")]
+[assembly: AssemblyDelaySign(false)]
+[assembly: AssemblyKeyFile("FirebirdSql.Data.Firebird.snk")]
+[assembly: AssemblyKeyName("")]
View
350 FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/ArrayBase.cs
@@ -0,0 +1,350 @@
+/*
+ * Firebird ADO.NET Data provider for .NET and Mono
+ *
+ * The contents of this file are subject to the Initial
+ * Developer's Public License Version 1.0 (the "License");
+ * you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ * http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ * Software distributed under the License is distributed on
+ * an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
+ * express or implied. See the License for the specific
+ * language governing rights and limitations under the License.
+ *
+ * Copyright (c) 2002, 2005 Carlos Guzman Alvarez
+ * All Rights Reserved.
+ */
+
+using System;
+using System.Text;
+using System.Globalization;
+
+namespace FirebirdSql.Data.Common
+{
+ internal abstract class ArrayBase
+ {
+ #region Fields
+
+ private ArrayDesc descriptor;
+ private string tableName;
+ private string fieldName;
+ private string rdbFieldName;
+
+ #endregion
+
+ #region Properties
+
+ public ArrayDesc Descriptor
+ {
+ get { return this.descriptor; }
+ }
+
+ #endregion
+
+ #region Abstract Properties
+
+ public abstract long Handle
+ {
+ get;
+ set;
+ }
+
+ public abstract IDatabase DB
+ {
+ get;
+ set;
+ }
+
+ public abstract ITransaction Transaction
+ {
+ get;
+ set;
+ }
+
+ #endregion
+
+ #region Constructors
+
+ protected ArrayBase(ArrayDesc descriptor)
+ {
+ this.tableName = descriptor.RelationName;
+ this.fieldName = descriptor.FieldName;
+ this.descriptor = descriptor;
+ }
+
+ protected ArrayBase(string tableName, string fieldName)
+ {
+ this.tableName = tableName;
+ this.fieldName = fieldName;
+ this.rdbFieldName = String.Empty;
+ }
+
+ #endregion
+
+ #region Abstract Methods
+
+ public abstract byte[] GetSlice(int slice_length);
+ public abstract void PutSlice(System.Array source_array, int slice_length);
+
+ #endregion
+
+ #region Protected Abstract Methods
+
+ protected abstract System.Array DecodeSlice(byte[] slice);
+
+ #endregion
+
+ #region Methods
+
+ public Array Read()
+ {
+ byte[] slice = this.GetSlice(this.GetSliceLength(true));
+
+ return this.DecodeSlice(slice);
+ }
+
+ public void Write(System.Array sourceArray)
+ {
+ this.SetDesc(sourceArray);
+ this.PutSlice(sourceArray, this.GetSliceLength(false));
+ }
+
+ public void SetDesc(System.Array sourceArray)
+ {
+ this.descriptor.Dimensions = (short)sourceArray.Rank;
+
+ for (int i = 0; i < sourceArray.Rank; i++)
+ {
+ int lb = this.descriptor.Bounds[i].LowerBound;
+ int ub = sourceArray.GetLength(i) - 1 + lb;
+
+ this.descriptor.Bounds[i].UpperBound = ub;
+ }
+ }
+
+ public void LookupBounds()
+ {
+ this.LookupDesc();
+
+ StatementBase lookup = this.DB.CreateStatement(this.Transaction);
+
+ lookup.Prepare(this.GetArrayBounds());
+ lookup.Execute();
+
+ int i = 0;
+ this.descriptor.Bounds = new ArrayBound[16];
+ DbValue[] values;
+
+ while ((values = lookup.Fetch()) != null)
+ {
+ this.descriptor.Bounds[i].LowerBound = values[0].GetInt32();
+ this.descriptor.Bounds[i].UpperBound = values[1].GetInt32();
+
+ i++;
+ }
+
+ lookup.Release();
+ lookup = null;
+ }
+
+ public void LookupDesc()
+ {
+ // Initializa array descriptor information
+ this.descriptor = new ArrayDesc();
+
+ // Create statement for retrieve information
+ StatementBase lookup = this.DB.CreateStatement(this.Transaction);
+
+ lookup.Prepare(this.GetArrayDesc());
+ lookup.Execute();
+
+ DbValue[] values = lookup.Fetch();
+ if (values != null && values.Length > 0)
+ {
+ this.descriptor.RelationName = tableName;
+ this.descriptor.FieldName = fieldName;
+ this.descriptor.DataType = values[0].GetByte();
+ this.descriptor.Scale = values[1].GetInt16();
+ this.descriptor.Length = values[2].GetInt16();
+ this.descriptor.Dimensions = values[3].GetInt16();
+ this.descriptor.Flags = 0;
+
+ this.rdbFieldName = values[4].GetString().Trim();
+ }
+ else
+ {
+ throw new InvalidOperationException();
+ }
+
+ lookup.Release();
+ lookup = null;
+ }
+
+ #endregion
+
+ #region Protected Methods
+
+ protected int GetSliceLength(bool read)
+ {
+ int length = 0;
+ int elements = 0;
+
+ for (int i = 0; i < this.descriptor.Dimensions; i++)
+ {
+ ArrayBound bound = this.descriptor.Bounds[i];
+
+ elements += (bound.UpperBound - bound.LowerBound) + 1;
+ }
+
+ length = elements * this.descriptor.Length;
+
+ switch (this.descriptor.DataType)
+ {
+ case IscCodes.blr_varying:
+ case IscCodes.blr_varying2:
+ length += elements * 2;
+ break;
+ }
+
+ return length;
+ }
+
+ protected Type GetSystemType()
+ {
+ Type systemType;
+
+ switch (this.descriptor.DataType)
+ {
+ case IscCodes.blr_text:
+ case IscCodes.blr_text2:
+ case IscCodes.blr_cstring:
+ case IscCodes.blr_cstring2:
+ // Char
+ systemType = typeof(System.String);
+ break;
+
+ case IscCodes.blr_varying:
+ case IscCodes.blr_varying2:
+ // VarChar
+ systemType = typeof(System.String);
+ break;
+
+ case IscCodes.blr_short:
+ // Short/Smallint
+ if (this.descriptor.Scale < 0)
+ {
+ systemType = typeof(System.Decimal);
+ }
+ else
+ {
+ systemType = typeof(System.Int16);
+ }
+ break;
+
+ case IscCodes.blr_long:
+ // Integer
+ if (this.descriptor.Scale < 0)
+ {
+ systemType = typeof(System.Decimal);
+ }
+ else
+ {
+ systemType = typeof(System.Int32);
+ }
+ break;
+
+ case IscCodes.blr_float:
+ // Float
+ systemType = typeof(System.Single);
+ break;
+
+ case IscCodes.blr_double:
+ case IscCodes.blr_d_float:
+ // Double
+ systemType = typeof(System.Double);
+ break;
+
+ case IscCodes.blr_quad:
+ case IscCodes.blr_int64:
+ // Long/Quad
+ if (this.descriptor.Scale < 0)
+ {
+ systemType = typeof(System.Decimal);
+ }
+ else
+ {
+ systemType = typeof(System.Int64);
+ }
+ break;
+
+ case IscCodes.blr_timestamp:
+ // Timestamp
+ systemType = typeof(System.DateTime);
+ break;
+
+ case IscCodes.blr_sql_time:
+ // Time
+ systemType = typeof(System.DateTime);
+ break;
+
+ case IscCodes.blr_sql_date:
+ // Date
+ systemType = typeof(System.DateTime);
+ break;
+
+ default:
+ throw new NotSupportedException("Unknown data type");
+ }
+
+ return systemType;
+ }
+
+ #endregion
+
+ #region Private Methods
+
+ private string GetArrayDesc()
+ {
+ StringBuilder sql = new StringBuilder();
+
+ sql.Append(
+ "SELECT Y.RDB$FIELD_TYPE, Y.RDB$FIELD_SCALE, Y.RDB$FIELD_LENGTH, Y.RDB$DIMENSIONS, X.RDB$FIELD_SOURCE " +
+ "FROM RDB$RELATION_FIELDS X, RDB$FIELDS Y " +
+ "WHERE X.RDB$FIELD_SOURCE = Y.RDB$FIELD_NAME ");
+
+ if (this.tableName != null && this.tableName.Length != 0)
+ {
+ sql.AppendFormat(
+ CultureInfo.CurrentCulture, " AND X.RDB$RELATION_NAME = '{0}'", tableName);
+ }
+
+ if (this.fieldName != null && this.fieldName.Length != 0)
+ {
+ sql.AppendFormat(
+ CultureInfo.CurrentCulture, " AND X.RDB$FIELD_NAME = '{0}'", fieldName);
+ }
+
+ return sql.ToString();
+ }
+
+ private string GetArrayBounds()
+ {
+ StringBuilder sql = new StringBuilder();
+
+ sql.Append("SELECT X.RDB$LOWER_BOUND, X.RDB$UPPER_BOUND FROM RDB$FIELD_DIMENSIONS X ");
+
+ if (this.fieldName != null && this.fieldName.Length != 0)
+ {
+ sql.AppendFormat(
+ CultureInfo.CurrentCulture, "WHERE X.RDB$FIELD_NAME = '{0}'", rdbFieldName);
+ }
+
+ sql.Append(" ORDER BY X.RDB$DIMENSION");
+
+ return sql.ToString();
+ }
+
+ #endregion
+ }
+}
View
125 FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/ArrayDesc.cs
@@ -0,0 +1,125 @@
+/*
+ * Firebird ADO.NET Data provider for .NET and Mono
+ *
+ * The contents of this file are subject to the Initial
+ * Developer's Public License Version 1.0 (the "License");
+ * you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ * http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ * Software distributed under the License is distributed on
+ * an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
+ * express or implied. See the License for the specific
+ * language governing rights and limitations under the License.
+ *
+ * Copyright (c) 2002, 2005 Carlos Guzman Alvarez
+ * All Rights Reserved.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+namespace FirebirdSql.Data.Common
+{
+ internal struct ArrayDesc
+ {
+ #region Fields
+
+ private byte dataType;
+ private short scale;
+ private short length;
+ private string fieldName;
+ private string relationName;
+ private short dimensions;
+ private short flags;
+ private ArrayBound[] bounds;
+
+ #endregion
+
+ #region Properties
+
+ public byte DataType
+ {
+ get { return this.dataType; }
+ set { this.dataType = value; }
+ }
+
+ // Scale for numeric datatypes
+ public short Scale
+ {
+ get { return this.scale; }
+ set { this.scale = value; }
+ }
+
+ // Legth in bytes of each array element
+ public short Length
+ {
+ get { return this.length; }
+ set { this.length = value; }
+ }
+
+ // Column name - 32
+ public string FieldName
+ {
+ get { return this.fieldName; }
+ set { this.fieldName = value; }
+ }
+
+ // Table name -32
+ public string RelationName
+ {
+ get { return this.relationName; }
+ set { this.relationName = value; }
+ }
+
+ // Number of array dimensions
+ public short Dimensions
+ {
+ get { return this.dimensions; }
+ set { this.dimensions = value; }
+ }
+
+ // Specifies wheter array is to be accesed in
+ // row mayor or column-mayor order
+ public short Flags
+ {
+ get { return this.flags; }
+ set { this.flags = value; }
+ }
+
+ // Lower and upper bounds for each dimension - 16
+ public ArrayBound[] Bounds
+ {
+ get { return this.bounds; }
+ set { this.bounds = value; }
+ }
+
+ #endregion
+ }
+
+ internal struct ArrayBound
+ {
+ #region Fields
+
+ private int lowerBound;
+ private int upperBound;
+
+ #endregion
+
+ #region Properties
+
+ public int LowerBound
+ {
+ get { return this.lowerBound; }
+ set { this.lowerBound = value; }
+ }
+
+ public int UpperBound
+ {
+ get { return this.upperBound; }
+ set { this.upperBound = value; }
+ }
+
+ #endregion
+ }
+}
View
161 FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/BinaryEncoding.cs
@@ -0,0 +1,161 @@
+/*
+ * BinaryEncoding handler for .Net. This class implements
+ * a symmetric encoding that will convert string to byte[]
+ * and byte[] to string without any character set
+ * transliteration.
+ *
+ * The contents of this file were written by jimb
+ * at connectedsw.com on Dec 9, 2004. It is placed in
+ * the Public Domain and may be used as you see fit.
+ */
+
+using System;
+using System.Text;
+
+namespace FirebirdSql.Data.Common
+{
+ internal class BinaryEncoding : Encoding
+ {
+ #region Static Methods
+
+ public static string BytesToString(byte[] byteArray)
+ {
+ // This code isn't great because it requires a double copy,
+ // but it requires unsafe code to solve the problem efficiently.
+ char[] charArray = new char[byteArray.GetLength(0)];
+ Array.Copy(byteArray, charArray, byteArray.Length);
+
+ return new string(charArray);
+ }
+
+ static void Validate(object data, int dataLength, int index, int count)
+ {
+ if (data == null)
+ {
+ throw new ArgumentNullException();
+ }
+
+ if (index < 0 || count < 0 || dataLength - index < count)
+ {
+ throw new ArgumentOutOfRangeException();
+ }
+ }
+
+ #endregion
+
+ #region Methods
+
+ public override int GetByteCount(char[] chars, int index, int count)
+ {
+ Validate(chars, chars.Length, index, count);
+
+ return count;
+ }
+
+ public override int GetByteCount(string chars)
+ {
+ return chars.Length;
+ }
+
+ public override int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int index)
+ {
+ Validate(chars, chars.Length, charIndex, charCount);
+
+ if (index < 0 || index > bytes.Length)
+ {
+ throw new ArgumentOutOfRangeException();
+ }
+ if (bytes.Length - index < charCount)
+ {
+ throw new ArgumentException();
+ }
+
+ int charEnd = charIndex + charCount;
+ while (charIndex < charEnd)
+ {
+ bytes[index++] = (byte)chars[charIndex++];
+ }
+
+ return charCount;
+ }
+
+ public override int GetBytes(string chars, int charIndex, int charCount, byte[] bytes, int index)
+ {
+ Validate(chars, chars.Length, charIndex, charCount);
+
+ if (index < 0 || index > bytes.Length)
+ {
+ throw new ArgumentOutOfRangeException();
+ }
+ if (bytes.Length - index < charCount)
+ {
+ throw new ArgumentException();
+ }
+
+ int charEnd = charIndex + charCount;
+ while (charIndex < charEnd)
+ {
+ bytes[index++] = (byte)chars[charIndex++];
+ }
+
+ return charCount;
+ }
+
+ public override int GetCharCount(byte[] bytes, int index, int count)
+ {
+ Validate(bytes, bytes.Length, index, count);
+
+ return (count);
+ }
+
+ public override int GetChars(byte[] bytes, int index, int count, char[] chars, int charIndex)
+ {
+ Validate(bytes, bytes.Length, index, count);
+
+ if (charIndex < 0 || charIndex > chars.Length)
+ {
+ throw new ArgumentOutOfRangeException();
+ }
+ if (chars.Length - charIndex < count)
+ {
+ throw new ArgumentException();
+ }
+
+ int byteEnd = index + count;
+ while (index < byteEnd)
+ {
+ chars[charIndex++] = (char)bytes[index++];
+ }
+
+ return count;
+ }
+
+#if (!NETCF)
+
+ public override string GetString(byte[] bytes)
+ {
+ return BytesToString(bytes);
+ }
+
+#endif
+
+ public override string GetString(byte[] bytes, int index, int count)
+ {
+ Validate(bytes, bytes.Length, index, count);
+
+ return BytesToString(bytes);
+ }
+
+ public override int GetMaxByteCount(int charCount)
+ {
+ return charCount;
+ }
+
+ public override int GetMaxCharCount(int count)
+ {
+ return count;
+ }
+
+ #endregion
+ }
+}
View
207 FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/BlobBase.cs
@@ -0,0 +1,207 @@
+/*
+ * Firebird ADO.NET Data provider for .NET and Mono
+ *
+ * The contents of this file are subject to the Initial
+ * Developer's Public License Version 1.0 (the "License");
+ * you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ * http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ * Software distributed under the License is distributed on
+ * an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
+ * express or implied. See the License for the specific
+ * language governing rights and limitations under the License.
+ *
+ * Copyright (c) 2002, 2005 Carlos Guzman Alvarez
+ * All Rights Reserved.
+ */
+
+using System;
+using System.Data;
+using System.Text;
+using System.IO;
+using System.Collections;
+
+namespace FirebirdSql.Data.Common
+{
+ internal abstract class BlobBase
+ {
+ #region Fields
+
+ private int rblFlags;
+ private Charset charset;
+ private int segmentSize;
+
+ #endregion
+
+ #region Protected Fields
+
+ protected long blobId;
+ protected int blobHandle;
+ protected int position;
+ protected ITransaction transaction;
+
+ #endregion
+
+ #region Properties
+
+ public int Handle
+ {
+ get { return this.blobHandle; }
+ }
+
+ public long Id
+ {
+ get { return this.blobId; }
+ }
+
+ public bool EOF
+ {
+ get { return (this.rblFlags & IscCodes.RBL_eof_pending) != 0; }
+ }
+
+ #endregion
+
+ #region Protected Properties
+
+ protected int SegmentSize
+ {
+ get { return this.segmentSize; }
+ }
+
+ #endregion
+
+ #region Abstract Properties
+
+ public abstract IDatabase DB
+ {
+ get;
+ }
+
+ #endregion
+
+ #region Constructors
+
+ protected BlobBase(IDatabase db)
+ {
+ this.segmentSize = db.PacketSize;
+ this.charset = db.Charset;
+ }
+
+ #endregion
+
+ #region Protected Abstract Methods
+
+ protected abstract void Create();
+ protected abstract void Open();
+ protected abstract byte[] GetSegment();
+ protected abstract void PutSegment(byte[] buffer);
+ protected abstract void Seek(int position);
+ protected abstract void GetBlobInfo();
+ protected abstract void Close();
+ protected abstract void Cancel();
+
+ #endregion
+
+ #region Methods
+
+ public string ReadString()
+ {
+ byte[] buffer = this.Read();
+ return this.charset.GetString(buffer, 0, buffer.Length);
+ }
+
+ public byte[] Read()
+ {
+ MemoryStream ms = new MemoryStream();
+
+ try
+ {
+ this.Open();
+
+ while (!EOF)
+ {
+ byte[] segment = this.GetSegment();
+ ms.Write(segment, 0, segment.Length);
+ }
+
+ this.Close();
+ }
+ catch (Exception)
+ {
+ // Cancel the blob and rethrow the exception
+ this.Cancel();
+
+ throw;
+ }
+
+ return ms.ToArray();
+ }
+
+ public void Write(string data)
+ {
+ this.Write(this.charset.GetBytes(data));
+ }
+
+ public void Write(byte[] buffer)
+ {
+ this.Write(buffer, 0, buffer.Length);
+ }
+
+ public void Write(byte[] buffer, int index, int count)
+ {
+ try
+ {
+ this.Create();
+
+ byte[] tmpBuffer = null;
+
+ int length = count;
+ int offset = index;
+ int chunk = length >= this.segmentSize ? this.segmentSize : length;
+
+ tmpBuffer = new byte[chunk];
+
+ while (length > 0)
+ {
+ if (chunk > length)
+ {
+ chunk = (int)length;
+ tmpBuffer = new byte[chunk];
+ }
+
+ Array.Copy(buffer, offset, tmpBuffer, 0, chunk);
+ this.PutSegment(tmpBuffer);
+
+ offset += chunk;
+ length -= chunk;
+ }
+
+ this.Close();
+ }
+ catch (Exception)
+ {
+ // Cancel the blob and rethrow the exception
+ this.Cancel();
+
+ throw;
+ }
+ }
+
+ #endregion
+
+ #region Protected Methods
+
+ protected void RblAddValue(int rblValue)
+ {
+ this.rblFlags |= rblValue;
+ }
+
+ protected void RblRemoveValue(int rblValue)
+ {
+ this.rblFlags &= ~rblValue;
+ }
+
+ #endregion
+ }
+}
View
33 FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/BlobParameterBuffer.cs
@@ -0,0 +1,33 @@
+/*
+ * Firebird ADO.NET Data provider for .NET and Mono
+ *
+ * The contents of this file are subject to the Initial
+ * Developer's Public License Version 1.0 (the "License");
+ * you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ * http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ * Software distributed under the License is distributed on
+ * an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
+ * express or implied. See the License for the specific
+ * language governing rights and limitations under the License.
+ *
+ * Copyright (c) 2002, 2005 Carlos Guzman Alvarez
+ * All Rights Reserved.
+ */
+
+using System;
+
+namespace FirebirdSql.Data.Common
+{
+ internal sealed class BlobParameterBuffer : ParameterBuffer
+ {
+ #region Constructors
+
+ public BlobParameterBuffer(bool isLittleEndian) : base(isLittleEndian)
+ {
+ }
+
+ #endregion
+ }
+}
View
204 FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/Charset.cs
@@ -0,0 +1,204 @@
+/*
+ * Firebird ADO.NET Data provider for .NET and Mono
+ *
+ * The contents of this file are subject to the Initial
+ * Developer's Public License Version 1.0 (the "License");
+ * you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ * http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ * Software distributed under the License is distributed on
+ * an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
+ * express or implied. See the License for the specific
+ * language governing rights and limitations under the License.
+ *
+ * Copyright (c) 2002, 2005 Carlos Guzman Alvarez
+ * All Rights Reserved.
+ */
+
+using System;
+using System.Text;
+
+namespace FirebirdSql.Data.Common
+{
+ internal sealed class Charset
+ {
+ #region Static Fields
+
+ private readonly static CharsetCollection supportedCharsets = Charset.InitializeSupportedCharsets();
+
+ #endregion
+
+ #region Static Properties
+
+ public static CharsetCollection SupportedCharsets
+ {
+ get { return Charset.supportedCharsets; }
+ }
+
+ public static Charset DefaultCharset
+ {
+ get { return Charset.SupportedCharsets[0]; }
+ }
+
+ #endregion
+
+ #region Fields
+
+ private int id;
+ private int bytesPerCharacter;
+ private string name;
+ private string systemName;
+
+ #endregion
+
+ #region Properties
+
+ public int ID
+ {
+ get { return this.id; }
+ }
+
+ public string Name
+ {
+ get { return this.name; }
+ }
+
+ public int BytesPerCharacter
+ {
+ get { return this.bytesPerCharacter; }
+ }
+
+ #endregion
+
+ #region Constructors
+
+ public Charset(
+ int id, string name, int bytesPerCharacter, string systemName)
+ {
+ this.id = id;
+ this.name = name;
+ this.bytesPerCharacter = bytesPerCharacter;
+ this.systemName = systemName;
+ }
+
+ #endregion
+
+ #region Methods
+
+ public byte[] GetBytes(string s)
+ {
+ return this.GetEncoding().GetBytes(s);
+ }
+
+ public int GetBytes(string s, int charIndex, int charCount, byte[] bytes, int byteIndex)
+ {
+ return this.GetEncoding().GetBytes(s, charIndex, charCount, bytes, byteIndex);
+ }
+
+ public string GetString(byte[] buffer)
+ {
+ return this.GetString(buffer, 0, buffer.Length);
+ }
+
+ public string GetString(byte[] buffer, int index, int count)
+ {
+ return this.GetEncoding().GetString(buffer, index, count);
+ }
+
+ #endregion
+
+ #region Private Methods
+
+ private Encoding GetEncoding()
+ {
+ switch (this.systemName)
+ {
+ case "NONE":
+ return Encoding.Default;
+
+ case "OCTETS":
+ return new BinaryEncoding();
+
+ default:
+ return Encoding.GetEncoding(this.systemName);
+ }
+ }
+
+ #endregion
+
+ #region Static Methods
+
+ public static CharsetCollection InitializeSupportedCharsets()
+ {
+ CharsetCollection charsets = new CharsetCollection();
+
+ // NONE
+ Charset.Add(charsets, 0, "NONE", 1, "NONE");
+ // OCTETS
+ Charset.Add(charsets, 1, "OCTETS", 1, "OCTETS");
+ // American Standard Code for Information Interchange
+ Charset.Add(charsets, 2, "ASCII", 1, "ascii");
+ // Eight-bit Unicode Transformation Format
+ Charset.Add(charsets, 3, "UNICODE_FSS", 3, "UTF-8");
+ // Shift-JIS, Japanese
+ Charset.Add(charsets, 5, "SJIS_0208", 2, "shift_jis");
+ // JIS X 0201, 0208, 0212, EUC encoding, Japanese
+ Charset.Add(charsets, 6, "EUCJ_0208", 2, "euc-jp");
+ // Windows Japanese
+ Charset.Add(charsets, 7, "ISO2022-JP", 2, "iso-2022-jp");
+ // MS-DOS United States, Australia, New Zealand, South Africa
+ Charset.Add(charsets, 10, "DOS437", 1, "IBM437");
+ // MS-DOS Latin-1
+ Charset.Add(charsets, 11, "DOS850", 1, "ibm850");
+ // MS-DOS Nordic
+ Charset.Add(charsets, 12, "DOS865", 1, "IBM865");
+ // MS-DOS Portuguese
+ Charset.Add(charsets, 13, "DOS860", 1, "IBM860");
+ // MS-DOS Canadian French
+ Charset.Add(charsets, 14, "DOS863", 1, "IBM863");
+ // ISO 8859-1, Latin alphabet No. 1
+ Charset.Add(charsets, 21, "ISO8859_1", 1, "iso-8859-1");
+ // ISO 8859-2, Latin alphabet No. 2
+ Charset.Add(charsets, 22, "ISO8859_2", 1, "iso-8859-2");
+ // Windows Korean
+ Charset.Add(charsets, 44, "KSC_5601", 2, "ks_c_5601-1987");
+ // MS-DOS Icelandic
+ Charset.Add(charsets, 47, "DOS861", 1, "ibm861");
+ // Windows Eastern European
+ Charset.Add(charsets, 51, "WIN1250", 1, "windows-1250");
+ // Windows Cyrillic
+ Charset.Add(charsets, 52, "WIN1251", 1, "windows-1251");
+ // Windows Latin-1
+ Charset.Add(charsets, 53, "WIN1252", 1, "windows-1252");
+ // Windows Greek
+ Charset.Add(charsets, 54, "WIN1253", 1, "windows-1253");
+ // Windows Turkish
+ Charset.Add(charsets, 55, "WIN1254", 1, "windows-1254");
+ // Big5, Traditional Chinese
+ Charset.Add(charsets, 56, "BIG_5", 2, "big5");
+ // GB2312, EUC encoding, Simplified Chinese
+ Charset.Add(charsets, 57, "GB_2312", 2, "gb2312");
+ // Windows Hebrew
+ Charset.Add(charsets, 58, "WIN1255", 1, "windows-1255");
+ // Windows Arabic
+ Charset.Add(charsets, 59, "WIN1256", 1, "windows-1256");
+ // Windows Baltic
+ Charset.Add(charsets, 60, "WIN1257", 1, "windows-1257");
+
+ return charsets;
+ }
+
+ private static void Add(
+ CharsetCollection charsets, int id, string charset, int bytesPerCharacter, string systemName)
+ {
+ charsets.Add(
+ id,
+ charset,
+ bytesPerCharacter,
+ systemName);
+ }
+
+ #endregion
+ }
+}
View
96 FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/CharsetCollection.cs
@@ -0,0 +1,96 @@
+/*
+ * Firebird ADO.NET Data provider for .NET and Mono
+ *
+ * The contents of this file are subject to the Initial
+ * Developer's Public License Version 1.0 (the "License");
+ * you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ * http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ * Software distributed under the License is distributed on
+ * an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
+ * express or implied. See the License for the specific
+ * language governing rights and limitations under the License.
+ *
+ * Copyright (c) 2002, 2005 Carlos Guzman Alvarez
+ * All Rights Reserved.
+ */
+
+using System;
+using System.Text;
+using System.Collections;
+
+namespace FirebirdSql.Data.Common
+{
+ internal sealed class CharsetCollection : CollectionBase
+ {
+ #region Indexers
+
+ public Charset this[int index]
+ {
+ get { return (Charset)this.List[index]; }
+ }
+
+ public Charset this[string name]
+ {
+ get { return (Charset)this[this.IndexOf(name)]; }
+ }
+
+ #endregion
+
+ #region Methods
+
+ public int IndexOf(int id)
+ {
+ int index = 0;
+
+ foreach (Charset item in this)
+ {
+ if (item.ID == id)
+ {
+ return index;
+ }
+ index++;
+ }
+
+ return -1;
+ }
+
+ public int IndexOf(string name)
+ {
+ int index = 0;
+
+ foreach (Charset item in this)
+ {
+ if (GlobalizationHelper.CultureAwareCompare(item.Name, name))
+ {
+ return index;
+ }
+ index++;
+ }
+
+ return -1;
+ }
+
+ internal Charset Add(
+ int id,
+ string charset,
+ int bytesPerCharacter,
+ string systemCharset)
+ {
+ Charset charSet = new Charset(
+ id, charset, bytesPerCharacter, systemCharset);
+
+ return this.Add(charSet);
+ }
+
+ internal Charset Add(Charset charset)
+ {
+ this.List.Add(charset);
+
+ return charset;
+ }
+
+ #endregion
+ }
+}
View
77 FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/DatabaseParameterBuffer.cs
@@ -0,0 +1,77 @@
+/*
+ * Firebird ADO.NET Data provider for .NET and Mono
+ *
+ * The contents of this file are subject to the Initial
+ * Developer's Public License Version 1.0 (the "License");
+ * you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ * http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ * Software distributed under the License is distributed on
+ * an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
+ * express or implied. See the License for the specific
+ * language governing rights and limitations under the License.
+ *
+ * Copyright (c) 2002, 2005 Carlos Guzman Alvarez
+ * All Rights Reserved.
+ */
+
+using System;
+using System.IO;
+using System.Text;
+using System.Net;
+
+namespace FirebirdSql.Data.Common
+{
+ internal sealed class DatabaseParameterBuffer : ParameterBuffer
+ {
+ #region Constructors
+
+ public DatabaseParameterBuffer() : base()
+ {
+ }
+
+ public DatabaseParameterBuffer(bool isLittleEndian) : base(isLittleEndian)
+ {
+ }
+
+ #endregion
+
+ #region Methods
+
+ public void Append(int type, byte value)
+ {
+ this.WriteByte(type);
+ this.WriteByte(1);
+ this.Write(value);
+ }
+
+ public void Append(int type, short value)
+ {
+ this.WriteByte(type);
+ this.WriteByte(2);
+ this.Write(value);
+ }
+
+ public void Append(int type, int value)
+ {
+ this.WriteByte(type);
+ this.WriteByte((byte)4);
+ this.Write(value);
+ }
+
+ public void Append(int type, string content)
+ {
+ this.Append(type, Encoding.Default.GetBytes(content));
+ }
+
+ public void Append(int type, byte[] buffer)
+ {
+ this.WriteByte(type);
+ this.WriteByte(buffer.Length);
+ this.Write(buffer);
+ }
+
+ #endregion
+ }
+}
View
42 FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/DbDataType.cs
@@ -0,0 +1,42 @@
+/*
+ * Firebird ADO.NET Data provider for .NET and Mono
+ *
+ * The contents of this file are subject to the Initial
+ * Developer's Public License Version 1.0 (the "License");
+ * you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ * http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ * Software distributed under the License is distributed on
+ * an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
+ * express or implied. See the License for the specific
+ * language governing rights and limitations under the License.
+ *
+ * Copyright (c) 2002, 2005 Carlos Guzman Alvarez
+ * All Rights Reserved.
+ */
+
+using System;
+
+namespace FirebirdSql.Data.Common
+{
+ internal enum DbDataType
+ {
+ Array,
+ BigInt,
+ Binary,
+ Char,
+ Date,
+ Decimal,
+ Double,
+ Float,
+ Guid,
+ Integer,
+ Numeric,
+ SmallInt,
+ Text,
+ Time,
+ TimeStamp,
+ VarChar
+ }
+}
View
655 FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/DbField.cs
@@ -0,0 +1,655 @@
+/*
+ * Firebird ADO.NET Data provider for .NET and Mono
+ *
+ * The contents of this file are subject to the Initial
+ * Developer's Public License Version 1.0 (the "License");
+ * you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ * http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ * Software distributed under the License is distributed on
+ * an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
+ * express or implied. See the License for the specific
+ * language governing rights and limitations under the License.
+ *
+ * Copyright (c) 2002, 2005 Carlos Guzman Alvarez
+ * All Rights Reserved.
+ */
+
+using System;
+using System.Text;
+
+namespace FirebirdSql.Data.Common
+{
+ internal sealed class DbField
+ {
+ #region Fields
+
+ private short dataType;
+ private short numericScale;
+ private short subType;
+ private short length;
+ private short nullFlag;
+ private string name;
+ private string relation;
+ private string owner;
+ private string alias;
+ private int charCount;
+ private DbValue dbValue;
+ private Charset charset;
+ private ArrayBase arrayHandle;
+
+ #endregion
+
+ #region Properties
+
+ public DbDataType DbDataType
+ {
+ get { return this.GetDbDataType(); }
+ }
+
+ public int SqlType
+ {
+ get { return this.dataType & ~1; }
+ }
+
+ public short DataType
+ {
+ get { return this.dataType; }
+ set { this.dataType = value; }
+ }
+
+ public short NumericScale
+ {
+ get { return this.numericScale; }
+ set { this.numericScale = value; }
+ }
+
+ public short SubType
+ {
+ get { return this.subType; }
+ set
+ {
+ this.subType = value;
+ if (this.IsCharacter())
+ {
+ // Bits 0-7 of sqlsubtype is charset_id (127 is a special value -
+ // current attachment charset).
+ // Bits 8-17 hold collation_id for this value.
+ byte[] cs = BitConverter.GetBytes(value);
+
+ int index = Charset.SupportedCharsets.IndexOf(cs[0]);
+ if (index != -1)
+ {
+ this.charset = Charset.SupportedCharsets[index];
+ }
+ else
+ {
+ this.charset = Charset.SupportedCharsets[0];
+ }
+ }
+ }
+ }
+
+ public short Length
+ {
+ get { return this.length; }
+ set
+ {
+ this.length = value;
+ if (this.IsCharacter())
+ {
+ this.charCount = this.length / this.charset.BytesPerCharacter;
+ }
+ }
+ }
+
+ public short NullFlag
+ {
+ get { return this.nullFlag; }
+ set { this.nullFlag = value; }
+ }
+
+ public string Name
+ {
+ get { return this.name; }
+ set { this.name = value.Trim(); }
+ }
+
+ public string Relation
+ {
+ get { return this.relation; }
+ set { this.relation = value.Trim(); }
+ }
+
+ public string Owner
+ {
+ get { return this.owner; }
+ set { this.owner = value.Trim(); }
+ }
+
+ public string Alias
+ {
+ get { return this.alias; }
+ set { this.alias = value.Trim(); }
+ }
+
+ public Charset Charset
+ {
+ get { return this.charset; }
+ }
+
+ public int CharCount
+ {
+ get { return this.charCount; }
+ }
+
+ public ArrayBase ArrayHandle
+ {
+ get
+ {
+ if (this.IsArray())
+ {
+ return this.arrayHandle;
+ }
+ else
+ {
+ throw new IscException("Field is not an array type");
+ }
+ }
+
+ set
+ {
+ if (this.IsArray())
+ {
+ this.arrayHandle = value;
+ }
+ else
+ {
+ throw new IscException("Field is not an array type");
+ }
+ }
+ }
+
+ public DbValue DbValue
+ {
+ get { return this.dbValue; }
+ }
+
+ public object Value
+ {
+ get { return this.dbValue.Value; }
+ set { this.dbValue.Value = value; }
+ }
+
+ #endregion
+
+ #region Constructors
+
+ public DbField()
+ {
+ this.charCount = -1;
+ this.name = String.Empty;
+ this.relation = String.Empty;
+ this.owner = String.Empty;
+ this.alias = String.Empty;
+ this.dbValue = new DbValue(this, DBNull.Value);
+ }
+
+ #endregion
+
+ #region Methods
+
+ public bool IsNumeric()
+ {
+ if (this.dataType == 0)
+ {
+ return false;
+ }
+
+ switch (this.DbDataType)
+ {
+ case DbDataType.SmallInt:
+ case DbDataType.Integer:
+ case DbDataType.BigInt:
+ case DbDataType.Numeric:
+ case DbDataType.Decimal:
+ case DbDataType.Float:
+ case DbDataType.Double:
+ return true;
+
+ default:
+ return false;
+ }
+ }
+
+ public bool IsDecimal()
+ {
+ if (this.dataType == 0)
+ {
+ return false;
+ }
+
+ switch (this.DbDataType)
+ {
+ case DbDataType.Numeric:
+ case DbDataType.Decimal:
+ return true;
+
+ default:
+ return false;
+ }
+ }
+
+ public bool IsLong()
+ {
+ if (this.dataType == 0)
+ {
+ return false;
+ }
+
+ switch (this.DbDataType)
+ {
+ case DbDataType.Binary:
+ case DbDataType.Text:
+ return true;
+
+ default:
+ return false;
+ }
+ }
+
+ public bool IsCharacter()
+ {
+ if (this.dataType == 0)
+ {
+ return false;
+ }
+
+ switch (this.DbDataType)
+ {
+ case DbDataType.Char:
+ case DbDataType.VarChar:
+ case DbDataType.Text:
+ return true;
+
+ default:
+ return false;
+ }
+ }
+
+ public bool IsArray()
+ {
+ if (this.dataType == 0)
+ {
+ return false;
+ }
+
+ switch (this.DbDataType)
+ {
+ case DbDataType.Array:
+ return true;
+
+ default:
+ return false;
+ }
+ }
+
+ public bool IsAliased()
+ {
+ return (this.Name != this.Alias) ? true : false;
+ }
+
+ public bool IsExpression()
+ {
+ return this.Name.Length == 0 ? true : false;
+ }
+
+ public int GetSize()
+ {
+ if (this.IsLong())
+ {
+ return System.Int32.MaxValue;
+ }
+ else
+ {
+ if (this.IsCharacter())
+ {
+ return this.CharCount;
+ }
+ else
+ {
+ return this.Length;
+ }
+ }
+ }
+
+ public bool AllowDBNull()
+ {
+ return ((this.DataType & 1) == 1);
+ }
+
+ public void SetValue(byte[] buffer)
+ {
+ if (buffer == null || this.NullFlag == -1)
+ {
+ this.Value = System.DBNull.Value;
+ }
+ else
+ {
+ switch (this.SqlType)
+ {
+ case IscCodes.SQL_TEXT:
+ case IscCodes.SQL_VARYING:
+ if (this.DbDataType == DbDataType.Guid)
+ {
+ this.Value = new Guid(buffer);
+ }
+ else
+ {
+ string s = this.Charset.GetString(buffer, 0, buffer.Length);
+
+ if ((this.Length % this.Charset.BytesPerCharacter) == 0 &&
+ s.Length > this.CharCount)
+ {
+ s = s.Substring(0, this.CharCount);
+ }
+
+ this.Value = s;
+ }
+ break;
+
+ case IscCodes.SQL_SHORT:
+ if (this.numericScale < 0)
+ {
+ this.Value = TypeDecoder.DecodeDecimal(
+ BitConverter.ToInt16(buffer, 0),
+ this.numericScale,
+ this.dataType);
+ }
+ else
+ {
+ this.Value = BitConverter.ToInt16(buffer, 0);
+ }
+ break;
+
+ case IscCodes.SQL_LONG:
+ if (this.NumericScale < 0)
+ {
+ this.Value = TypeDecoder.DecodeDecimal(
+ BitConverter.ToInt32(buffer, 0),
+ this.numericScale,
+ this.dataType);
+ }
+ else
+ {
+ this.Value = BitConverter.ToInt32(buffer, 0);
+ }
+ break;
+
+ case IscCodes.SQL_FLOAT:
+ this.Value = BitConverter.ToSingle(buffer, 0);
+ break;
+
+ case IscCodes.SQL_DOUBLE:
+ case IscCodes.SQL_D_FLOAT:
+ this.Value = BitConverter.ToDouble(buffer, 0);
+ break;
+
+ case IscCodes.SQL_QUAD:
+ case IscCodes.SQL_INT64:
+ case IscCodes.SQL_BLOB:
+ case IscCodes.SQL_ARRAY:
+ if (this.NumericScale < 0)
+ {
+ this.Value = TypeDecoder.DecodeDecimal(
+ BitConverter.ToInt64(buffer, 0),
+ this.numericScale,
+ this.dataType);
+ }
+ else
+ {
+ this.Value = BitConverter.ToInt64(buffer, 0);
+ }
+ break;
+
+ case IscCodes.SQL_TIMESTAMP:
+ DateTime date = TypeDecoder.DecodeDate(
+ BitConverter.ToInt32(buffer, 0));
+
+ DateTime time = TypeDecoder.DecodeTime(
+ BitConverter.ToInt32(buffer, 4));
+
+ this.Value = new System.DateTime(
+ date.Year, date.Month, date.Day,
+ time.Hour, time.Minute, time.Second, time.Millisecond);
+ break;
+
+ case IscCodes.SQL_TYPE_TIME:
+ this.Value = TypeDecoder.DecodeTime(BitConverter.ToInt32(buffer, 0));
+ break;
+
+ case IscCodes.SQL_TYPE_DATE:
+ this.Value = TypeDecoder.DecodeDate(BitConverter.ToInt32(buffer, 0));
+ break;
+
+ default:
+ throw new NotSupportedException("Unknown data type");
+ }
+ }
+ }
+
+ public void FixNull()
+ {
+ if (this.NullFlag == -1 && this.dbValue.IsDBNull())
+ {
+ switch (this.DbDataType)
+ {
+ case DbDataType.Char:
+ case DbDataType.VarChar:
+ this.Value = String.Empty;
+ break;
+
+ case DbDataType.Guid:
+ this.Value = Guid.Empty;
+ break;
+
+ case DbDataType.SmallInt:
+ this.Value = (short)0;
+ break;
+
+ case DbDataType.Integer:
+ this.Value = (int)0;
+ break;
+
+ case DbDataType.BigInt:
+ case DbDataType.Binary:
+ case DbDataType.Array:
+ case DbDataType.Text:
+ this.Value = (long)0;
+ break;
+
+ case DbDataType.Numeric:
+ case DbDataType.Decimal:
+ this.Value = (decimal)0;
+ break;
+
+ case DbDataType.Float:
+ this.Value = (float)0;
+ break;
+
+ case DbDataType.Double:
+ this.Value = (double)0;
+ break;
+
+ case DbDataType.Date:
+ case DbDataType.Time:
+ case DbDataType.TimeStamp:
+ this.Value = new System.DateTime(0 * 10000L + 621355968000000000);
+ break;
+
+ default:
+ throw new IscException("Unknown sql data type: " + this.DataType);
+ }
+ }
+ }
+
+ public Type GetSystemType()
+ {
+ switch (this.DbDataType)
+ {
+ case DbDataType.Char:
+ case DbDataType.VarChar:
+ case DbDataType.Text:
+ return Type.GetType("System.String");
+
+ case DbDataType.SmallInt:
+ return Type.GetType("System.Int16");
+
+ case DbDataType.Integer:
+ return Type.GetType("System.Int32");
+
+ case DbDataType.BigInt:
+ return Type.GetType("System.Int64");
+
+ case DbDataType.Numeric:
+ case DbDataType.Decimal:
+ return Type.GetType("System.Decimal");
+
+ case DbDataType.Float:
+ return Type.GetType("System.Single");
+
+ case DbDataType.Guid:
+ return Type.GetType("System.Guid");
+
+ case DbDataType.Double:
+ return Type.GetType("System.Double");
+
+ case DbDataType.Date:
+ case DbDataType.Time:
+ case DbDataType.TimeStamp:
+ return Type.GetType("System.DateTime");
+
+ case DbDataType.Binary:
+ return typeof(byte[]);
+
+ case DbDataType.Array:
+ return Type.GetType("System.Array");
+
+ default:
+ throw new SystemException("Invalid data type");
+ }
+ }
+
+ #endregion
+
+ #region Private Methods
+
+ private DbDataType GetDbDataType()
+ {
+ // Special case for Guid handling
+ if (this.SqlType == IscCodes.SQL_TEXT && this.Length == 16 &&
+ (this.Charset != null && this.Charset.Name == "OCTETS"))
+ {
+ return DbDataType.Guid;
+ }
+
+ switch (this.SqlType)
+ {
+ case IscCodes.SQL_TEXT:
+ return DbDataType.Char;
+
+ case IscCodes.SQL_VARYING:
+ return DbDataType.VarChar;
+
+ case IscCodes.SQL_SHORT:
+ if (this.subType == 2)
+ {
+ return DbDataType.Decimal;
+ }
+ else if (subType == 1)
+ {
+ return DbDataType.Numeric;
+ }
+ else
+ {
+ return DbDataType.SmallInt;
+ }
+
+ case IscCodes.SQL_LONG:
+ if (this.subType == 2)
+ {
+ return DbDataType.Decimal;
+ }
+ else if (subType == 1)
+ {
+ return DbDataType.Numeric;
+ }
+ else
+ {
+ return DbDataType.Integer;
+ }
+
+ case IscCodes.SQL_QUAD:
+ case IscCodes.SQL_INT64:
+ if (this.subType == 2)
+ {
+ return DbDataType.Decimal;
+ }
+ else if (subType == 1)
+ {
+ return DbDataType.Numeric;
+ }
+ else
+ {
+ return DbDataType.BigInt;
+ }
+
+ case IscCodes.SQL_FLOAT:
+ return DbDataType.Float;
+
+ case IscCodes.SQL_DOUBLE:
+ case IscCodes.SQL_D_FLOAT:
+ if (this.subType == 2)
+ {
+ return DbDataType.Decimal;
+ }
+ else if (subType == 1)
+ {
+ return DbDataType.Numeric;
+ }
+ else
+ {
+ return DbDataType.Double;
+ }
+
+ case IscCodes.SQL_BLOB:
+ if (this.subType == 1)
+ {
+ return DbDataType.Text;
+ }
+ else
+ {
+ return DbDataType.Binary;
+ }
+
+ case IscCodes.SQL_TIMESTAMP:
+ return DbDataType.TimeStamp;
+
+ case IscCodes.SQL_TYPE_TIME:
+ return DbDataType.Time;
+
+ case IscCodes.SQL_TYPE_DATE:
+ return DbDataType.Date;
+
+ case IscCodes.SQL_ARRAY:
+ return DbDataType.Array;
+
+ default:
+ throw new SystemException("Invalid data type");
+ }
+ }
+
+ #endregion
+ }
+}
View
41 FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/DbStatementType.cs
@@ -0,0 +1,41 @@
+/*
+ * Firebird ADO.NET Data provider for .NET and Mono
+ *
+ * The contents of this file are subject to the Initial
+ * Developer's Public License Version 1.0 (the "License");
+ * you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ * http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ * Software distributed under the License is distributed on
+ * an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
+ * express or implied. See the License for the specific
+ * language governing rights and limitations under the License.
+ *
+ * Copyright (c) 2002, 2005 Carlos Guzman Alvarez
+ * All Rights Reserved.
+ */
+
+using System;
+
+namespace FirebirdSql.Data.Common
+{
+ internal enum DbStatementType : int
+ {
+ None = 0,
+ Select = IscCodes.isc_info_sql_stmt_select,
+ Insert = IscCodes.isc_info_sql_stmt_insert,
+ Update = IscCodes.isc_info_sql_stmt_update,
+ Delete = IscCodes.isc_info_sql_stmt_delete,
+ DDL = IscCodes.isc_info_sql_stmt_ddl,
+ GetSegment = IscCodes.isc_info_sql_stmt_get_segment,
+ PutSegment = IscCodes.isc_info_sql_stmt_put_segment,
+ StoredProcedure = IscCodes.isc_info_sql_stmt_exec_procedure,
+ StartTrans = IscCodes.isc_info_sql_stmt_start_trans,
+ Commit = IscCodes.isc_info_sql_stmt_commit,
+ Rollback = IscCodes.isc_info_sql_stmt_rollback,
+ SelectForUpdate = IscCodes.isc_info_sql_stmt_select_for_upd,
+ SetGenerator = IscCodes.isc_info_sql_stmt_set_generator,
+ SavePoint = IscCodes.isc_info_sql_stmt_savepoint
+ }
+}
View
270 FirebirdSql.Data.Firebird/FirebirdSql.Data.Common/DbValue.cs
@@ -0,0 +1,270 @@
+/*
+ * Firebird ADO.NET Data provider for .NET and Mono
+ *
+ * The contents of this file are subject to the Initial
+ * Developer's Public License Version 1.0 (the "License");
+ * you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ * http://www.firebirdsql.org/index.php?op=doc&id=idpl
+ *
+ * Software distributed under the License is distributed on
+ * an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
+ * express or implied. See the License for the specific
+ * language governing rights and limitations under the License.
+ *
+ * Copyright (c) 2002, 2005 Carlos Guzman Alvarez
+ * All Rights Reserved.
+ */
+
+using System;
+using System.Globalization;
+
+namespace FirebirdSql.Data.Common
+{
+ internal sealed class DbValue
+ {
+ #region Fields
+
+ private StatementBase statement;
+ private DbField field;
+ private object value;
+
+ #endregion
+
+ #region Properties
+
+ public DbField Field
+ {
+ get { return this.field; }
+ }
+
+ public object Value
+ {
+ get { return this.GetValue(); }
+ set { this.value = value; }
+ }
+
+ #endregion
+
+ #region Constructor
+
+ public DbValue(DbField field, object value)
+ {
+ this.field = field;
+ this.value = (value == null) ? System.DBNull.Value : value;
+ }
+
+ public DbValue(StatementBase statement, DbField field)
+ {
+ this.statement = statement;
+ this.field = field;
+ this.value = field.Value;
+ }
+
+ public DbValue(StatementBase statement, DbField field, object value)
+ {
+ this.statement = statement;
+ this.field = field;
+ this.value = (value == null) ? System.DBNull.Value : value;
+ }
+
+ #endregion
+
+ #region Methods
+
+ public bool IsDBNull()
+ {
+ if (this.value == null || this.value == System.DBNull.Value)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ public string GetString()
+ {
+ if (this.Field.DbDataType == DbDataType.Text && this.value is long)
+ {
+ this.value = this.GetClobData((long)this.value);
+ }
+
+ return this.value.ToString();
+ }
+
+ public char GetChar()
+ {
+ return Convert.ToChar(this.value, CultureInfo.CurrentCulture);
+ }
+
+ public bool GetBoolean()
+ {
+ return Convert.ToBoolean(this.value, CultureInfo.InvariantCulture);
+ }
+
+ public byte GetByte()
+ {
+ return Convert.ToByte(this.value, CultureInfo.InvariantCulture);
+ }
+
+ public short GetInt16()
+ {
+ return Convert.ToInt16(this.value, CultureInfo.InvariantCulture);
+ }
+
+ public int GetInt32()
+ {
+ return Convert.ToInt32(this.value, CultureInfo.InvariantCulture);
+ }
+
+ public long GetInt64()
+ {
+ return Convert.ToInt64(this.value, CultureInfo.InvariantCulture);
+ }
+
+ public decimal GetDecimal()
+ {
+ return Convert.ToDecimal(this.value, CultureInfo.InvariantCulture);
+ }
+
+ public float GetFloat()
+ {
+ return Convert.ToSingle(this.value, CultureInfo.InvariantCulture);
+ }
+
+ public Guid GetGuid()
+ {
+ if (this.Value is Guid)
+ {
+ return (Guid)this.Value;
+ }
+ else if (this.Value is byte[])
+ {
+ return new Guid((byte[])this.value);
+ }
+
+ throw new InvalidOperationException("Incorrect Guid value");
+ }
+
+ public double GetDouble()
+ {
+ return Convert.ToDouble(this.value, CultureInfo.InvariantCulture);
+ }
+
+ public DateTime GetDateTime()
+ {
+ return Convert.ToDateTime(this.value, CultureInfo.CurrentCulture.DateTimeFormat);
+ }
+
+ public Array GetArray()
+ {
+ if (this.value is long)
+ {
+ this.value = this.GetArrayData((long)this.value);
+ }
+
+ return (Array)this.value;
+ }
+
+ public byte[] GetBinary()
+ {
+ if (this.value is long)
+ {
+ this.value = this.GetBlobData((long)this.value);
+ }
+ return (byte[])this.value;
+ }
+
+ public int EncodeDate()
+ {
+ return TypeEncoder.EncodeDate(this.GetDateTime());
+ }
+
+ public int EncodeTime()
+ {
+ return TypeEncoder.EncodeTime(this.GetDateTime());
+ }
+
+ #endregion
+
+ #region Private Methods
+
+ private object GetValue()
+ {
+ if (this.IsDBNull())
+ {
+ return System.DBNull.Value;
+ }
+
+ switch (this.field.DbDataType)
+ {
+ case DbDataType.Text:
+ if (this.statement == null)
+ {
+ return this.GetInt64();
+ }
+ else
+ {
+ return this.GetString();
+ }
+
+ case DbDataType.Binary:
+ if (this.statement == null)
+ {
+ return this.GetInt64();
+ }
+ else
+ {
+ return this.GetBinary();
+ }
+
+ case DbDataType.Array:
+ if (this.statement == null)
+ {
+ return this.GetInt64();
+ }
+ else
+ {
+ return this.GetArray();
+ }
+
+ default:
+ return this.value;
+ }
+ }
+
+ private string GetClobData(long blobId)
+ {
+ BlobBase clob = this.statement.CreateBlob(blobId);
+
+ return clob.ReadString();
+ }
+
+ private byte[] GetBlobData(long blobId)
+ {
+ BlobBase blob = this.statement.CreateBlob(blobId);
+
+ return blob.Read();
+ }
+
+ private Array GetArrayData(long handle)
+ {
+ if (this.field.ArrayHandle == null)