Skip to content
Browse files

Moved deprecated library

svn path=/old-code/; revision=152778
  • Loading branch information...
1 parent e8e4194 commit 77a478339e29869630cd74b370efd58ead55aa86 @migueldeicaza migueldeicaza committed Mar 2, 2010
Showing with 11,559 additions and 0 deletions.
  1. +38 −0 ByteFX.Data/AssemblyInfo.cs
  2. +43 −0 ByteFX.Data/ByteFX.Data.dll.sources
  3. +66 −0 ByteFX.Data/ChangeLog
  4. +386 −0 ByteFX.Data/ChangeLog.txt
  5. +53 −0 ByteFX.Data/Common/BitStream.cs
  6. +129 −0 ByteFX.Data/Common/Connection.cs
  7. +185 −0 ByteFX.Data/Common/ConnectionString.cs
  8. +189 −0 ByteFX.Data/Common/DBConnectionString.cs
  9. +59 −0 ByteFX.Data/Common/DBParametersEditor.cs
  10. +61 −0 ByteFX.Data/Common/Field.cs
  11. +76 −0 ByteFX.Data/Common/HuffmanTree.cs
  12. +37 −0 ByteFX.Data/Common/Inflater.cs
  13. +212 −0 ByteFX.Data/Common/MultiHostStream.cs
  14. +208 −0 ByteFX.Data/Common/NamedPipeStream.cs
  15. +41 −0 ByteFX.Data/Common/Platform.cs
  16. +25 −0 ByteFX.Data/Common/Security.cs
  17. +244 −0 ByteFX.Data/Common/SqlCommandEditorDlg.cs
  18. +105 −0 ByteFX.Data/Common/SqlCommandEditorDlg.resx
  19. +63 −0 ByteFX.Data/Common/SqlCommandTextEditor.cs
  20. +148 −0 ByteFX.Data/Common/StreamCreator.cs
  21. +67 −0 ByteFX.Data/Common/StringUtility.cs
  22. +68 −0 ByteFX.Data/Common/Version.cs
  23. +20 −0 ByteFX.Data/Makefile
  24. +339 −0 ByteFX.Data/MySqlClient.csproj
  25. +504 −0 ByteFX.Data/lgpl.txt
  26. +88 −0 ByteFX.Data/mysqlclient/CharSetMap.cs
  27. +420 −0 ByteFX.Data/mysqlclient/CommandBuilder.cs
  28. +141 −0 ByteFX.Data/mysqlclient/CommandResult.cs
  29. +155 −0 ByteFX.Data/mysqlclient/CompressedStream.cs
  30. +386 −0 ByteFX.Data/mysqlclient/Connection.cs
  31. +42 −0 ByteFX.Data/mysqlclient/Connection.resx
  32. +117 −0 ByteFX.Data/mysqlclient/ConnectionInternal.cs
  33. +286 −0 ByteFX.Data/mysqlclient/ConnectionString.cs
  34. +310 −0 ByteFX.Data/mysqlclient/Designers/EditConnectionString.cs
  35. +102 −0 ByteFX.Data/mysqlclient/Designers/EditConnectionString.resx
  36. +55 −0 ByteFX.Data/mysqlclient/Designers/MySqlConnectionDesign.cs
  37. BIN ByteFX.Data/mysqlclient/Designers/command.bmp
  38. BIN ByteFX.Data/mysqlclient/Designers/connection.bmp
  39. BIN ByteFX.Data/mysqlclient/Designers/dataadapter.bmp
  40. +589 −0 ByteFX.Data/mysqlclient/Driver.cs
  41. +63 −0 ByteFX.Data/mysqlclient/Exception.cs
  42. +463 −0 ByteFX.Data/mysqlclient/Field.cs
  43. +250 −0 ByteFX.Data/mysqlclient/MySqlError.cs
  44. +343 −0 ByteFX.Data/mysqlclient/MySqlHelper.cs
  45. +135 −0 ByteFX.Data/mysqlclient/MySqlPool.cs
  46. +63 −0 ByteFX.Data/mysqlclient/MySqlPoolManager.cs
  47. +165 −0 ByteFX.Data/mysqlclient/MySqlStream.cs
  48. +158 −0 ByteFX.Data/mysqlclient/MysqlDefs.cs
  49. +223 −0 ByteFX.Data/mysqlclient/Packet.cs
  50. +516 −0 ByteFX.Data/mysqlclient/command.cs
  51. +42 −0 ByteFX.Data/mysqlclient/command.resx
  52. +289 −0 ByteFX.Data/mysqlclient/dataadapter.cs
  53. +679 −0 ByteFX.Data/mysqlclient/datareader.cs
  54. +106 −0 ByteFX.Data/mysqlclient/docs/MySqlCommand.xml
  55. +138 −0 ByteFX.Data/mysqlclient/docs/MySqlCommandBuilder.xml
  56. +312 −0 ByteFX.Data/mysqlclient/docs/MySqlConnection.xml
  57. +90 −0 ByteFX.Data/mysqlclient/docs/MySqlDataAdapter.xml
  58. +78 −0 ByteFX.Data/mysqlclient/docs/MySqlDataReader.xml
  59. +54 −0 ByteFX.Data/mysqlclient/docs/MySqlException.xml
  60. +54 −0 ByteFX.Data/mysqlclient/docs/MySqlHelper.xml
  61. +45 −0 ByteFX.Data/mysqlclient/docs/MySqlParameter.xml
  62. +45 −0 ByteFX.Data/mysqlclient/docs/MySqlParameterCollection.xml
  63. +111 −0 ByteFX.Data/mysqlclient/docs/MySqlTransaction.xml
  64. +598 −0 ByteFX.Data/mysqlclient/parameter.cs
  65. +316 −0 ByteFX.Data/mysqlclient/parameter_collection.cs
  66. BIN ByteFX.Data/mysqlclient/resources/command.bmp
  67. BIN ByteFX.Data/mysqlclient/resources/connection.bmp
  68. BIN ByteFX.Data/mysqlclient/resources/dataadapter.bmp
  69. +1 −0 ByteFX.Data/mysqlclient/todo.txt
  70. +106 −0 ByteFX.Data/mysqlclient/transaction.cs
  71. +59 −0 ByteFX.Data/readme.txt
View
38 ByteFX.Data/AssemblyInfo.cs
@@ -0,0 +1,38 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+//
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+//
+[assembly: AssemblyTitle("ByteFX.Data.dll")]
+[assembly: AssemblyDescription("ADO.Net drivers for MySql & PostgreSQL")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("ByteFX, Inc.")]
+[assembly: AssemblyProduct("")]
+[assembly: AssemblyCopyright("Copyright 2002-2003, ByteFX, Inc.")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+//
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Revision and Build Numbers
+// by using the '*' as shown below:
+
+#if (NET_2_0)
+ [assembly: AssemblyVersion ("0.7.6.2")]
+#elif (NET_1_1)
+ [assembly: AssemblyVersion ("0.7.6.1")]
+#else
+ [assembly: AssemblyVersion ("0.7.6.0")]
+#endif
+
+[assembly: AssemblyDelaySign (true)]
+[assembly: AssemblyKeyFile ("../mono.pub")]
View
43 ByteFX.Data/ByteFX.Data.dll.sources
@@ -0,0 +1,43 @@
+./AssemblyInfo.cs
+./Common/BitStream.cs
+./Common/Connection.cs
+./Common/ConnectionString.cs
+./Common/DBConnectionString.cs
+./Common/DBParametersEditor.cs
+./Common/Field.cs
+./Common/HuffmanTree.cs
+./Common/Inflater.cs
+./Common/MultiHostStream.cs
+./Common/NamedPipeStream.cs
+./Common/Platform.cs
+./Common/Security.cs
+./Common/SqlCommandEditorDlg.cs
+./Common/SqlCommandTextEditor.cs
+./Common/StreamCreator.cs
+./Common/StringUtility.cs
+./Common/Version.cs
+./mysqlclient/CharSetMap.cs
+./mysqlclient/CommandBuilder.cs
+./mysqlclient/CommandResult.cs
+./mysqlclient/CompressedStream.cs
+./mysqlclient/Connection.cs
+./mysqlclient/ConnectionInternal.cs
+./mysqlclient/ConnectionString.cs
+./mysqlclient/Designers/EditConnectionString.cs
+./mysqlclient/Designers/MySqlConnectionDesign.cs
+./mysqlclient/Driver.cs
+./mysqlclient/Exception.cs
+./mysqlclient/Field.cs
+./mysqlclient/MySqlError.cs
+./mysqlclient/MySqlHelper.cs
+./mysqlclient/MySqlPool.cs
+./mysqlclient/MySqlPoolManager.cs
+./mysqlclient/MySqlStream.cs
+./mysqlclient/MysqlDefs.cs
+./mysqlclient/Packet.cs
+./mysqlclient/command.cs
+./mysqlclient/dataadapter.cs
+./mysqlclient/datareader.cs
+./mysqlclient/parameter.cs
+./mysqlclient/parameter_collection.cs
+./mysqlclient/transaction.cs
View
66 ByteFX.Data/ChangeLog
@@ -0,0 +1,66 @@
+2005-09-27 Kornél Pál <kornelpal@hotmail.com>
+
+ * Makefile: Removed /codepage:28591 as it is the default.
+
+2005-08-25 Atsushi Enomoto <atsushi@ximian.com>
+
+ * Makefile : /codepage:28591 (otherwise the build is broken on utf8
+ environment).
+
+2004-11-26 Raja R Harinath <rharinath@novell.com>
+
+ * Makefile (OTHER_RES): New. List of resources.
+ (EXTRA_DISTFILES): Distribute them.
+
+2004-05-18 Duncan Mak <duncan@ximian.com>
+
+ * AssemblyInfo.cs: Gonzalo reminded me that I need to update the
+ version number as well. We're at 0.7.6 now.
+
+ * Common/StreamCreator.cs (CreateUnixSocketStream): Instead of
+ hostList [0], which is a char, use hostList directly. This fixes
+ the build.
+
+2004-05-18 Duncan Mak <duncan@ximian.com>
+
+ * Makefile: Add reference to Mono.Posix.dll.
+
+ * ByteFX.Data.dll.sources: Update to latest listing of source
+ files.
+
+ * AssemblyInfo.cs: Revert back to the previous version, because we
+ don't have bytefx.snk.
+
+ * mysqlclient/transcaction.cs: Removed, replaced by the new
+ transaction.cs.
+
+2004-05-18 Duncan Mak <duncan@ximian.com>
+
+ * Update to the latest version:
+ http://www.bytefx.com/releases/ByteFX.MySqlClient.76.src.zip
+
+ * Common/Connection.cs:
+ * Common/ConnectionString.cs:
+ * Common/Inflater.cs:
+ * Common/Platform.cs:
+ * Common/StreamCreater.cs:
+ * Common/CommandResult.cs:
+ * Common/CompressedStream.cs:
+ * mysqlclient/MySqlError.cs:
+ * mysqlclient/transaction.cs: New source files.
+
+2003-10-06 Nick Drochak <ndrochak@gol.com>
+
+ * AssemblyInfo.cs: Fix the build by ignoring assembly signing for now.
+
+2003-03-15 Daniel Morgan <danmorg@sc.rr.com>
+
+ * mysqlclient/datareader.cs: in GetSchemaTable(),
+ "BaseColumnName" should be set to the ColumnName,
+ not null
+
+2003-03-14 Daniel Morgan <danmorg@sc.rr.com>
+
+ Imported the ByteFX.Data MySQL 0.6.5 data provider. See
+ ChangeLog at the root of mcs for this date.
+
View
386 ByteFX.Data/ChangeLog.txt
@@ -0,0 +1,386 @@
+3/11/2004
+MySql - Changed command editor to point to MySqlClient.Design
+
+3/4/2004
+Common - Fixed bug in Version.isAtLeast
+Common - Changed DBConnectionString to support changes done to MySqlConnectionString
+Common - Removed SqlCommandEditor and DataAdapterPreviewDialog
+
+3/3/2004
+MySql - Using new long return values in many places
+MySql - Integrated new CompressedStream class
+
+3/2/2004
+MySql - Changed ConnectionString and added attributes to allow it to be used in MySqlClient.Design
+MySql - Changed packet.cs to support newer lengths in ReadLenInteger
+MySql - changed other classes to use new properties and fields of MySqlConnectionString
+MySql - ConnectionInternal is now using PING to see if the server is alive
+
+3/1/2004
+MySql - Moved toolbox bitmaps into resource/
+MySql - Changed field.cs to allow values to come directly from row buffer
+
+2/25/2004
+MySql - Changed to use the new driver.Send syntax
+MySql - Using a new packet queueing system
+MySql - started work handling the "broken" compression packet handling
+
+2/20/2004
+Common - Fixed bug in StreamCreator where failure to connect to a host would continue
+to loop infinitly (thanks Kevin Casella)
+
+2/8/2004
+MySql - Improved connectstring handling
+MySql - Moved designers into Pro product
+
+2/4/2004
+MySql - Removed some old commented out code from command.cs
+MySql - Fixed a problem with compression
+
+2/2/2004
+MySql - Fixed connection object where an exception throw prior to the connection opening would not leave
+ the connection in the connecting state (thanks Chris Cline )
+
+1/31/2004
+MySql - Added GUID support
+MySql - Fixed sequence out of order bug (thanks Mark Reay)
+
+1/26/2004
+MySql - Enum values now supported as parameter values (thanks Philipp Sumi)
+1/22/2004
+MySql - Year datatype now supported
+
+1/21/2004
+MySql - fixed compression
+
+1/20/2004
+MySql - Fixed bug where a parameter with a TimeSpan as the value would not serialize properly
+MySql,Common - Fixed bug where default ctor would not set default connection string values
+MySql - Added some XML comments to some members
+MySql - Work to fix/improve compression handling
+
+1/13/2004
+MySql,Common - Improved ConnectionString handling so that it better matches the standard set by SqlClient.
+MySql - A MySqlException is now thrown if a username is not included in the connection string
+MySql- Localhost is now used as the default if not specified on the connection string
+MySql - An exception is now thrown if an attempt is made to set the connection string while the connection is open
+MySql - Small changes to ConnectionString docs
+MySql,common - Removed MultiHostStream and MySqlStream. Replaced it with Common/StreamCreator
+MySql - Added support for Use Pipe connection string value
+MySql - Added Platform class for easier access to platform utility functions
+MySql - Fixed small pooling bug where new connection was not getting created after IsAlive fails
+Common - Added Platform.cs and StreamCreator.cs
+
+12/30/2003
+MySql - Fixed Field.cs to properly handle 4.1 style timestamps
+MySql - Changed Common.Version to Common.DBVersion to avoid name conflict
+
+
+12/29/2003
+MySql - Fixed field.cs so that text columns return the right field type (thanks beni27@gmx.net)
+
+12/22/2003
+MySql - Added MySqlError class to provide some reference for error codes (thanks Geert Veenstra)
+
+------------0.74 ------------------------
+
+12/6/2003
+MySql - Added Unix socket support (thanks Mohammad DAMT [md@mt.web.id])
+
+12/4/2003
+MySql - only calling Thread.Sleep when no data is available
+MySql - improved escaping of quote characters in parameter data
+MySql - removed misleading comments from parameter.cs
+
+12/1/2003
+Mysql -fixed pooling bug
+MySql - same pooling bug fixed again!! ;-)
+
+11/30/2003
+MySql - Fixed ConnectionSTring editor dialog (thanks marco p (pomarc))
+Common - UserId now supported in connection strings (thanks Jeff Neeley)
+MySql - Attempting to create a parameter that is not input throws an exception (thanks Ryan Gregg)
+
+11/29/2003
+MySql - Added much documentation
+
+11/26/2003
+MySql - checked in new MultiHostStream capability. Big thanks to Dan Guisinger for this. he originally submitted the code and idea of supporting multiple machines on the connect string.
+
+11/25/2003
+MySql - Added alot of documentation. Still alot to do.
+
+11/24/2003
+MySql - Fixed speed issue with 0.73
+
+11/14/2003
+MySql - changed to Thread.Sleep(0) in MySqlDataStream to help optimize the case where it doesn't need to wait (thanks Todd German)
+11/1/2003
+MySql - Prepopulating the idlepools to MinPoolSize
+
+10/31/2003
+MySql - Fixed MySqlPool deadlock condition as well as stupid bug where CreateNewPooledConnection
+ was not ever adding new connections to the pool.
+ Also fixed MySqlStream.ReadBytes and ReadByte to not use TicksPerSecond which does not appear
+ to always be right.
+ (thanks Matthew J. Peddlesden)
+MySql - Fix for precision and scale (thanks Matthew J. Peddlesden)
+
+10/28/2003
+MySql - Added Thread.Sleep(1) to stream reading methods to be more cpu friendly (thanks Sean McGinnis)
+
+10/24/2003
+MySql - Fixed problem where ExecuteReader would sometime return null (thanks Lloyd Dupont )
+
+10/17/2003
+MySql - Fixed major bug with null field handling (thanks Naucki)
+
+10/15/2003
+MySql - enclosed queries for max_allowed_packet and characterset inside try catch (and set defaults)
+MySql - fixed problem where socket was not getting closed properly (thanks Steve!)
+
+10/14/2003
+MySql - Fixed problem where ExecuteNonQuery was not always returning the right value
+
+10/13/2003
+MySql - Fixed InternalConnection to not use @@session.max_allowed_packet but use @@max_allowed_packet. (Thanks Miguel)
+
+10/12/2003
+MySql - Added many new XML doc lines
+
+10/10/2003
+MySql - Fixed sql parsing to not send empty queries (thanks Rory)
+MySql - Fixed problem where the reader was not unpeeking the packet on close
+MySql - Fixed problem where user variables were not being handled (thanks Sami Vaaraniemi)
+MySql - Fixed loop checking in the MySqlPool (thanks Steve M. Brown)
+
+10/7/2003
+MySql - Fixed ParameterCollection.Add method to match SqlClient (thanks Joshua Mouch)
+Common & MySql - Fixed ConnectionSTring parsing to handle no and yes for boolean and not lowercase values (thanks Naucki)
+
+10/3/2003
+MySql - Added InternalConnection class, changes to pooling
+Common - Implemented Persist Security Info
+
+9/26/2003
+Common - Added security.cs and version.cs to project
+
+9/25/2003
+MySql - Fixed DateTime handling in Parameter.cs (thanks Burkhard Perkens-Golomb)
+MySql - Fixed parameter serialization where some types would throw a cast exception
+MySql - Fixed DataReader to convert all returned values to prevent casting errors (thanks Keith Murray)
+MySql - Added code to Command.ExecuteReader to return null if the initial SQL command throws an exception (thanks Burkhard Perkens-Golomb)
+
+9/24/2003
+MySql - Fixed ExecuteScalar bug introduced with restructure
+
+9/23/2003
+MySql - Restructure to allow for LOCAL DATA INFILE and better sequencing of packets
+MySql - Fixed several bugs related to restructure.
+
+9/10/2003
+MySql - Early work done to support more secure passwords in Mysql 4.1. Old passwords in 4.1 not supported yet
+
+8/22/2003
+MySql- Parameters appearing after system parameters are now handled correctly (Adam M. (adammil))
+MySql - strings can now be assigned directly to blob fields (Adam M.)
+
+8/20/2003
+MySql - Fixed float parameters (thanks Pent)
+
+8/7/2003
+MySql - Improved Parameter ctor and ParameterCollection.Add methods to better match SqlClient (thx Joshua Mouch )
+MySql - Corrected Connection.CreateCommand to return a MySqlCommand type
+MySql - Fixed connection string designer dialog box problem (thanks Abraham Guyt)
+
+7/24/2003
+MySql - Fixed problem with sending commands not always reading the response packet (thanks Joshua Mouch )
+MySql - Fixed parameter serialization where some blobs types were not being handled (thanks Sean McGinnis )
+
+7/22/2003
+MySql - Removed spurious MessageBox.show from DataReader code (thanks Joshua Mouch )
+
+7/17/2003
+MySql - Fixed a nasty bug in the split sql code (thanks everyone! :-) )
+
+*************Released 0.71***********************
+7/15/2003
+MySql - Fixed bug in MySqlStream where too much data could attempt to be read (thanks Peter Belbin)
+
+7/11/2003
+MySql - Implemented HasRows (thanks Nash Pherson)
+MySql - Fixed bug where tables with more than 252 columns cause an exception ( thanks Joshua Kessler )
+MySql - Fixed bug where SQL statements ending in ; would cause a problem ( thanks Shane Krueger )
+MySql - Fixed bug in driver where error messsages were getting truncated by 1 character (thanks Shane Krueger)
+
+7/6/2003
+========MySql===============
+* Made MySqlException serializable (thanks Mathias Hasselmann)
+
+========PgSql===============
+* Made PgSqlException serializable (thanks Mathias Hasselmann)
+
+***********Released 0.70*********************
+
+6/25/2003
+========MySql===============
+* Updated some of the character code pages to be more accurate
+* Fixed problem where readers could be opened on connections that had readers open
+* Release of 0.70
+
+6/20/2003
+========MySql===============
+* Moved test to separate assembly MySqlClientTests
+
+6/19/2003
+========MySql===============
+* Fixed stupid problem in driver with sequence out of order (Thanks Peter Belbin)
+
+6/18/2003
+========MySql===============
+* Added some pipe tests
+* Increased default max pool size to 50
+* Compiles with Mono 0-24
+
+6/17/2003
+========MySql===============
+* Fixed connection and data reader dispose problems
+* Added String datatype handling to parameter serialization
+
+6/13/2003
+========MySql===============
+* Fixed sequence problem in driver that occured after thrown exception
+ (thanks Burkhard Perkens-Golomb)
+
+6/10/2003
+========MySql===============
+* Added support for CommandBehavior.SingleRow to DataReader
+* Fixed command sql processing so quotes are better handled (thanks Theo Spears)
+
+6/9/2003
+========MySQL===============
+* Fixed parsing of double, single, and decimal values to account for non-English separators.
+ You still have to use the right syntax if you using hard coded sql, but if you use parameters
+ the code will convert floating point types to use '.' appropriately internal both into the server
+ and out.
+ [ Thanks anonymous ]
+* Added MySqlStream class to simplify timeOuts and driver coding.
+* Fixed DataReader so that it is closed properly when the associated connection is closed.
+ [thanks smishra]
+* Made client more SqlClient compliant so that DataReaders have to be closed before the connection
+ can be used to run another command
+* Improved DBNull.Value handling in the fields
+* Added several unit tests
+* Fixed MySqlException so that the base class is actually called :-o
+* Improved driver coding
+
+=============PgSql=================
+* Too many changes to document. Still basic structuring of driver. Driver not really usable yet.
+
+
+
+5/28/2003
+* Fixed bug where NextResult was returning false on the last resultset
+* Added more tests for MySQL
+* Improved casting problems by equating unsigned 32bit values to Int64 and usigned 16bit values to Int32, etc
+
+5/6/2003
+* Added new ctor for MySqlParameter for (name, type, size, srccol)
+* Fixed bug in MySqlDataReader where it didn't check for null fieldlist before returning field count
+
+4/23/2003
+* Started adding MySqlClient unit tests (added MySqlClient/Tests folder and some test cases)
+* Fixed some things in Connection String handling
+
+4/7/2003
+* Moved INIT_DB to MySqlPool. I may move it again, this is in preparation of the conference.
+
+4/6/2003
+* Fixed bug inside CommandBuilder that prevented inserts from happening properly
+* Reworked some of the internals so that all three execute methods of Command worked properly
+* FIxed many small bugs found during benchmarking
+
+4/5/2003
+* The first cut of CoonectionPooling is working. "min pool size" and "max pool size" are respected.
+
+4/3/2003
+* Work to enable multiple resultsets to be returned
+* Character sets are handled much more intelligently now. The driver queries MySQL at startup for the default character set.
+ That character set is then used for conversions if that code page can be loaded. If not, then the default code
+ page for the current OS is used.
+
+3/31/2003
+* Added code to save the inferred type in the name,value ctor of Parameter
+* Also, inferred type if value of null parameter is changed using Value property
+* Converted all files to use proper Camel case. MySQL is now MySql in all files. PgSQL is now PgSql
+* Added attribute to PgSql code to prevent designer from trying to show
+
+3/17/2003
+* Added MySQLDbType property to Parameter object and added proper conversion code to convert from DbType to MySQLDbType)
+* Removed unused ObjectToString method from MySQLParameter.cs
+* Fixed Add(..) method in ParameterCollection so that it doesn't use Add(name, value) instead.
+* Fixed IndexOf and Contains in ParameterCollection to be aware that parameter names are now stored without @
+* Fixed Command.ConvertSQLToBytes so it only allows characters that can be in MySQL variable names
+* Fixed DataReader and Field so that blob fields read their data from Field.cs and GetBytes works right
+* Added simple query builder editor to CommandText property of MySQLCommand
+* Fixed CommandBuilder and Parameter serialization to account for Parameters not storing @ in their names
+* Removed MySQLFieldType enum from Field.cs. Now using MySQLDbType enum
+
+3/15/2003
+* Added Designer attribute to several classes to prevent designer view when using VS.Net
+
+3/13/2003
+* Fixed Initial catalog typo in ConnectionString designer
+* Removed 3 parameter ctor for MySQLParameter that conflicted with (name, type, value)
+* changed MySQLParameter so paramName is now stored without leading @ (this fixed null inserts when using designer)
+* Changed TypeConverter for MySQLParameter to use the ctor with all properties
+
+0.68
+========================================================================
+Note that this build has not been checked out with Mono.
+
+3/10/2003
+* Fixed sequence issue in driver
+
+3/9/2003
+* Added DbParametersEditor to make parameter editing more like SqlClient
+* Fixed Command class so that parameters can be edited using the designer
+
+3/7/2003
+* Update connection string designer to support Use Compression flag
+
+2/15/2003
+* Fixed string encoding so that European characters like � will work correctly
+
+2/9/2003
+* Creating base classes to aid in building new data providers
+* Added support for UID key in connection string
+
+2/10/2003
+* Field, parameter, command now using DBNull.Value instead of null
+* CommandBuilder using DBNull.Value
+* CommandBuilder now builds insert command correctly when an auto_insert field is not present
+* Field now uses typeof keyword to return System.Types (performance)
+
+0.65
+====================
+* MySQLCommandBuilder now implemented
+* Transaction support now implemented (not all table types support this)
+* GetSchemaTable fixed to not use xsd (for Mono)
+* Driver is now Mono-compatible!!
+* TIME data type now supported
+* More work to improve Timestamp data type handling
+* Changed signatures of all classes to match corresponding SqlClient classes
+
+0.60
+======================
+* Protocol compression using SharpZipLib (www.icsharpcode.net)
+* Named pipes on Windows now working properly
+* Work done to improve Timestamp data type handling
+* Implemented IEnumerable on DataReader so DataGrid would work
+
+0.50
+======================
+* Speed increased dramatically by removing bugging network sync code
+* Driver no longer buffers rows of data (more ADO.Net compliant)
+* Conversion bugs related to TIMESTAMP and DATETIME fields fixed
View
53 ByteFX.Data/Common/BitStream.cs
@@ -0,0 +1,53 @@
+using System;
+using System.IO;
+
+namespace ByteFX.Data.Common
+{
+ /// <summary>
+ /// Summary description for BitStream.
+ /// </summary>
+ public class BitStream : MemoryStream
+ {
+ private byte[] _input;
+ private int _start;
+ private int _end;
+ private int _bitindex;
+ private uint _bitbuffer;
+ private int _bits_in_buffer;
+
+ public BitStream(byte[] input, int index, int len)
+ {
+ _bitindex = 0;
+ _bitbuffer = 0;
+ _bits_in_buffer = 0;
+ _input = input;
+ _start = index;
+ _end = _start + len;
+ }
+
+ public int GetBits(int numbits)
+ {
+ return 0;
+ }
+
+ public int PeekBits(int numbits)
+ {
+ int val=0;
+
+ int index=_start;
+ while (numbits > 0)
+ {
+ val = (val << 8) | _input[index++];
+ numbits -= 8;
+ }
+
+ while (_bits_in_buffer < numbits)
+ {
+ if (_start == _end)
+ throw new Exception("Out of bits");
+ byte b = _input[_start++];
+ }
+ return 0;
+ }
+ }
+}
View
129 ByteFX.Data/Common/Connection.cs
@@ -0,0 +1,129 @@
+// ByteFX.Data data access components for .Net
+// Copyright (C) 2002-2003 ByteFX, Inc.
+//
+// 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.ComponentModel;
+using System.Collections.Specialized;
+using System.Data;
+
+namespace ByteFX.Data.Common
+{
+ /// <summary>
+ /// Summary description for Connection.
+ /// </summary>
+ [ToolboxItem(false)]
+ [System.ComponentModel.DesignerCategory("Code")]
+ public class Connection : Component
+ {
+ internal ConnectionString connString;
+ internal ConnectionState state;
+ internal IDataReader reader = null;
+
+
+ public Connection(System.ComponentModel.IContainer container)
+ {
+ /// <summary>
+ /// Required for Windows.Forms Class Composition Designer support
+ /// </summary>
+ container.Add(this);
+ Init();
+ }
+
+ public Connection()
+ {
+ Init();
+ }
+
+ protected void Init()
+ {
+ state = ConnectionState.Closed;
+ }
+
+
+ [Browsable(true)]
+ public string DataSource
+ {
+ get
+ {
+ String s = connString["data source"];
+ if (s == null || s.Length == 0)
+ return "localhost";
+ return s;
+ }
+ }
+
+ [Browsable(false)]
+ public string User
+ {
+ get
+ {
+ string s = connString["user id"];
+ if (s == null)
+ s = "";
+ return s;
+ }
+ }
+
+ [Browsable(false)]
+ public string Password
+ {
+ get
+ {
+ string pwd = connString["password"];
+ if (pwd == null)
+ pwd = "";
+ return pwd;
+ }
+ }
+
+ [Browsable(true)]
+ public int ConnectionTimeout
+ {
+ get
+ {
+ // Returns the connection time-out value set in the connection
+ // string. Zero indicates an indefinite time-out period.
+ if (connString == null)
+ return 30;
+ return connString.GetIntOption("connection timeout", 30);
+ }
+ }
+
+ [Browsable(true)]
+ public string Database
+ {
+ get
+ {
+ // Returns an initial database as set in the connection string.
+ // An empty string indicates not set - do not return a null reference.
+ return connString["database"];
+ }
+ }
+
+ [Browsable(false)]
+ public ConnectionState State
+ {
+ get { return state; }
+ }
+
+ internal IDataReader Reader
+ {
+ get { return reader; }
+ set { reader = value; }
+ }
+ }
+}
View
185 ByteFX.Data/Common/ConnectionString.cs
@@ -0,0 +1,185 @@
+// ByteFX.Data data access components for .Net
+// Copyright (C) 2002-2003 ByteFX, Inc.
+//
+// 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.Specialized;
+
+namespace ByteFX.Data.Common
+{
+ /// <summary>
+ /// Summary description for Utility.
+ /// </summary>
+ internal class ConnectionString
+ {
+ private StringDictionary elements;
+ private string connString;
+
+ public ConnectionString(string connString)
+ {
+ this.connString = connString;
+ elements = new StringDictionary();
+ Parse( connString );
+ }
+
+ public string Value
+ {
+ get { return connString; }
+ }
+
+ public string this[string key]
+ {
+ get
+ {
+ string val = elements[key];
+ return val;
+ }
+ }
+
+ public int GetIntOption( string key, int defaultvalue )
+ {
+ string val = this[ key ];
+ if (null == val) return defaultvalue;
+ return Convert.ToInt32( val );
+ }
+
+ public bool GetBoolOption( string key, bool defaultvalue )
+ {
+ string val = this[ key ];
+ if (null == val) return defaultvalue;
+ val = val.ToLower();
+ if (val == "true" || val == "yes") return true;
+ return false;
+ }
+
+ public bool Contains( string key )
+ {
+ return elements.ContainsKey(key);
+ }
+
+ public bool Equals( ConnectionString obj )
+ {
+ foreach (string key in elements.Keys)
+ {
+ if (! obj.Contains(key)) return false;
+ if ( ! this[key].Equals( obj[key] )) return false;
+ }
+ return true;
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="obj"></param>
+ /// <returns></returns>
+ public bool PoolingEquals( ConnectionString obj )
+ {
+ foreach (string key in elements.Keys)
+ {
+ // these connection string elements only affect pooling
+ // so we don't check them when making sure connection strings
+ // are alike
+ if (key.Equals("connection lifetime")) continue;
+ if (key.Equals("connection reset")) continue;
+ if (key.Equals("enlist")) continue;
+ if (key.Equals("max pool size")) continue;
+ if (key.Equals("min pool size")) continue;
+ if (key.Equals("pooling")) continue;
+
+ if (! obj.Contains(key)) return false;
+ if ( ! this[key].Equals( obj[key] )) return false;
+ }
+ return true;
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="s"></param>
+ public void Parse( String s )
+ {
+ String[] keyvalues = s.Split( ';' );
+ String[] newkeyvalues = new String[keyvalues.Length];
+ int x = 0;
+
+ elements.Clear();
+
+ // first run through the array and check for any keys that
+ // have ; in their value
+ foreach (String keyvalue in keyvalues)
+ {
+ // check for trailing ; at the end of the connection string
+ if (keyvalue.Length == 0) continue;
+
+ // this value has an '=' sign so we are ok
+ if (keyvalue.IndexOf('=') >= 0)
+ {
+ newkeyvalues[x++] = keyvalue;
+ }
+ else
+ {
+ newkeyvalues[x-1] += ";";
+ newkeyvalues[x-1] += keyvalue;
+ }
+ }
+
+ // now we run through our normalized key-values, splitting on equals
+ for (int y=0; y < x; y++)
+ {
+ String[] parts = newkeyvalues[y].Split( '=' );
+
+ // first trim off any space and lowercase the key
+ parts[0] = parts[0].Trim().ToLower();
+ parts[1] = parts[1].Trim();
+
+ // normalize the keys going in. We want to support the same synonyms that
+ // SqlClient supports
+ switch (parts[0])
+ {
+ case "uid": parts[0] = "user id"; break;
+ case "pwd": parts[0] = "password"; break;
+ case "user": parts[0] = "user id"; break;
+ case "initial catalog": parts[0] = "database"; break;
+ case "server": parts[0] = "data source"; break;
+ }
+
+ // we also want to clear off any quotes
+ String newvalue = parts[1].Trim( '\'' );
+ if (newvalue.Length == parts[1].Length)
+ {
+ newvalue = parts[1].Trim('"');
+ }
+ parts[1] = newvalue;
+
+ // make sure we don't get dupliate keys
+ if (elements.ContainsKey(parts[0]))
+ {
+ throw new ArgumentException("Duplicate key in connection string", parts[0]);
+ }
+
+ elements.Add( parts[0], parts[1] );
+
+ // now put the correct parsed string into the connection string !! (AG 4/8/2003)
+ connString="";
+ foreach(string key in elements.Keys)
+ {
+ connString=connString+key+"="+elements[key]+"; ";
+ }
+ connString=connString.Substring(0,connString.Length-2);
+ }
+ }
+ }
+}
View
189 ByteFX.Data/Common/DBConnectionString.cs
@@ -0,0 +1,189 @@
+// ByteFX.Data data access components for .Net
+// Copyright (C) 2002-2003 ByteFX, Inc.
+//
+// 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.Text;
+
+namespace ByteFX.Data.Common
+{
+ /// <summary>
+ /// Summary description for Utility.
+ /// </summary>
+ internal abstract class DBConnectionString
+ {
+ protected Hashtable keyValues = new Hashtable();
+ protected string connectionName = String.Empty;
+ protected string connectString;
+
+ public DBConnectionString()
+ {
+ keyValues = GetDefaultValues();
+ }
+
+ public void SetConnectionString(string value)
+ {
+ Hashtable ht = Parse( value );
+ connectString = value;
+ keyValues = ht;
+ }
+
+ protected string GetString(string name)
+ {
+ if (! keyValues.ContainsKey(name)) return String.Empty;
+ return (keyValues[name] as string);
+ }
+
+ protected int GetInt( string name )
+ {
+ return Convert.ToInt32(keyValues[name]);
+ }
+
+ protected bool GetBool( string name )
+ {
+ return Convert.ToBoolean(keyValues[name]);
+ }
+
+ protected virtual bool ConnectionParameterParsed(Hashtable hash, string key, string value)
+ {
+ switch (key.ToLower())
+ {
+ case "persist security info":
+ hash["persist security info"] =
+ value.ToLower() == "yes" || value.ToLower() == "true";
+ return true;
+
+ case "uid":
+ case "username":
+ case "user id":
+ case "user name":
+ case "userid":
+ hash["user id"] = value;
+ return true;
+
+ case "password":
+ case "pwd":
+ hash["password"] = value;
+ return true;
+
+ case "host":
+ case "server":
+ case "data source":
+ case "datasource":
+ case "address":
+ case "addr":
+ case "network address":
+ hash["host"] = value;
+ return true;
+
+ case "initial catalog":
+ case "database":
+ hash["database"] = value;
+ return true;
+
+ case "connection timeout":
+ case "connect timeout":
+ hash["connect timeout"] = Int32.Parse( value );
+ return true;
+
+ case "port":
+ hash["port"] = Int32.Parse( value );
+ return true;
+
+ case "pooling":
+ hash["pooling"] =
+ value.ToLower() == "yes" || value.ToLower() == "true";
+ return true;
+
+ case "min pool size":
+ hash["min pool size"] = Int32.Parse(value);
+ return true;
+
+ case "max pool size":
+ hash["max pool size"] = Int32.Parse(value);
+ return true;
+
+ case "connection lifetime":
+ hash["connect lifetime"] = Int32.Parse(value);
+ return true;
+ }
+ return false;
+ }
+
+ protected virtual Hashtable GetDefaultValues()
+ {
+ return null;
+ }
+
+ protected Hashtable ParseKeyValuePairs( string src )
+ {
+ String[] keyvalues = src.Split( ';' );
+ String[] newkeyvalues = new String[keyvalues.Length];
+ int x = 0;
+
+ // first run through the array and check for any keys that
+ // have ; in their value
+ foreach (String keyvalue in keyvalues)
+ {
+ // check for trailing ; at the end of the connection string
+ if (keyvalue.Length == 0) continue;
+
+ // this value has an '=' sign so we are ok
+ if (keyvalue.IndexOf('=') >= 0)
+ {
+ newkeyvalues[x++] = keyvalue;
+ }
+ else
+ {
+ newkeyvalues[x-1] += ";";
+ newkeyvalues[x-1] += keyvalue;
+ }
+ }
+
+ Hashtable hash = new Hashtable();
+
+ // now we run through our normalized key-values, splitting on equals
+ for (int y=0; y < x; y++)
+ {
+ String[] parts = newkeyvalues[y].Split( '=' );
+
+ // first trim off any space and lowercase the key
+ parts[0] = parts[0].Trim().ToLower();
+ parts[1] = parts[1].Trim();
+
+ // we also want to clear off any quotes
+ parts[0] = parts[0].Trim('\'', '"');
+ parts[1] = parts[1].Trim('\'', '"');
+
+ hash.Add( parts[0], parts[1] );
+ }
+ return hash;
+ }
+
+ protected virtual Hashtable Parse(string newConnectString)
+ {
+ Hashtable hash = ParseKeyValuePairs( newConnectString );
+ Hashtable newHash = GetDefaultValues();
+
+ foreach (object key in hash.Keys)
+ ConnectionParameterParsed( newHash, (string)key, (string)hash[key] );
+ return newHash;
+ }
+
+
+ }
+}
View
59 ByteFX.Data/Common/DBParametersEditor.cs
@@ -0,0 +1,59 @@
+// ByteFX.Data data access components for .Net
+// Copyright (C) 2002-2003 ByteFX, Inc.
+//
+// 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.ComponentModel.Design;
+using ByteFX.Data.MySqlClient;
+
+namespace ByteFX.Data.Common
+{
+ /// <summary>
+ /// Summary description for DBParametersEditor.
+ /// </summary>
+ internal class DBParametersEditor : CollectionEditor
+ {
+ public DBParametersEditor(Type t) : base(t)
+ {
+ }
+
+ protected override object CreateInstance(Type itemType)
+ {
+ object[] items = base.GetItems(null);
+
+ int i = 1;
+ while (true)
+ {
+ bool found = false;
+ foreach (object obj in items)
+ {
+ MySqlParameter p = (MySqlParameter)obj;
+ if (p.ParameterName.Equals( "parameter" + i ))
+ {
+ found = true;
+ break;
+ }
+ }
+ if (! found) break;
+ i ++;
+ }
+
+ MySqlParameter parm = new MySqlParameter("parameter"+i, MySqlDbType.VarChar);
+ return parm;
+ }
+
+ }
+}
View
61 ByteFX.Data/Common/Field.cs
@@ -0,0 +1,61 @@
+using System;
+using System.Data;
+using System.Data.SqlTypes;
+
+namespace ByteFX.Data.Common
+{
+ /// <summary>
+ /// Summary description for Field.
+ /// </summary>
+ internal class Field
+ {
+/* protected SqlByte byteValue;
+ protected SqlDateTime dateValue;
+ protected SqlString stringValue;
+ protected SqlInt32 int32Value;
+ protected SqlInt64 int64Value;
+ protected SqlDouble doubleValue;
+ protected SqlSingle singleValue;
+ protected SqlMoney moneyValue;
+ protected SqlDecimal decimalValue;
+ protected SqlBinary binaryValue;*/
+ protected object value;
+
+ protected string tableName;
+ protected string colName;
+ protected int colLen;
+ protected string catalogName;
+ protected DbType dbType;
+ protected bool hasValue;
+
+ public Field()
+ {
+ hasValue = false;
+ }
+
+ public string ColumnName
+ {
+ get { return colName; }
+ set { colName = value; }
+ }
+
+ public int ColumnLength
+ {
+ get { return colLen; }
+ set { colLen = value; }
+ }
+
+ public string TableName
+ {
+ get { return tableName; }
+ set { tableName = value; }
+ }
+
+ public string CatalogName
+ {
+ get { return catalogName; }
+ set { catalogName = value; }
+ }
+
+ }
+}
View
76 ByteFX.Data/Common/HuffmanTree.cs
@@ -0,0 +1,76 @@
+using System;
+
+namespace ByteFX.Data.Common
+{
+ /// <summary>
+ /// Summary description for HuffmanTree.
+ /// </summary>
+ public class HuffmanTree
+ {
+ const int MAX_BITS = 15;
+ int[] codes;
+
+ public HuffmanTree(bool lit)
+ {
+ if (lit)
+ BuildLitTree();
+ else
+ BuildLenTree();
+ }
+
+ private void BuildLitTree()
+ {
+ codes = new int[288];
+
+ // fill the code slots with code lengths first
+ for (int x=0; x < 144; x++)
+ codes[x] = 8;
+ for (int x=144; x < 256; x++)
+ codes[x] = 9;
+ for (int x=256; x < 280; x++)
+ codes[x] = 7;
+ for (int x=280; x < 288; x++)
+ codes[x] = 8;
+
+ BuildTreeCommon();
+ }
+
+
+ private void BuildLenTree()
+ {
+ BuildTreeCommon();
+ }
+
+ private void BuildTreeCommon()
+ {
+ int[] codecounts = new int[MAX_BITS];
+ int[] codebase = new int[MAX_BITS];
+
+ for (int i = 0; i < codes.Length; i++)
+ {
+ int bit_len = codes[i];
+ if (bit_len > 0)
+ codecounts[bit_len]++;
+ }
+
+ // now we compute the intial value for each code length
+ int code = 0;
+ codecounts[0] = 0;
+ for (int bits = 1; bits <= MAX_BITS; bits++)
+ {
+ code = (code + codecounts[bits-1]) << 1;
+ codebase[bits] = code;
+ }
+
+ // next we assign numerical values to each code
+ for (int x=0; x <= codes.Length; x++)
+ {
+ if (codes[x] == 0) continue;
+ int blen = codes[x];
+ codes[x] = codebase[ blen ];
+ codebase[ blen ] ++;
+ }
+ }
+
+ }
+}
View
37 ByteFX.Data/Common/Inflater.cs
@@ -0,0 +1,37 @@
+using System;
+using System.IO;
+
+namespace ByteFX.Data.Common
+{
+ /// <summary>
+ /// Summary description for Inflater.
+ /// </summary>
+ public class Inflater
+ {
+ private BitStream _input;
+
+ public Inflater()
+ {
+ }
+
+ public void SetInput(byte[] input, int offset, int len)
+ {
+ _input = new BitStream(input, offset, len);
+ }
+
+ public void Inflate(byte[] output, int offset, int size)
+ {
+ byte cmf = (byte)_input.GetBits(8);
+ byte flag = (byte)_input.GetBits(8);
+
+ if ((cmf & 0x0f) != 8)
+ throw new Exception("Only deflate format data is supported");
+
+ if (((cmf*256+flag) % 31) != 0)
+ throw new Exception("Data is not in proper deflate format");
+
+
+
+ }
+ }
+}
View
212 ByteFX.Data/Common/MultiHostStream.cs
@@ -0,0 +1,212 @@
+using System;
+using System.Net;
+using System.IO;
+using System.Collections;
+using System.Threading;
+
+namespace ByteFX.Data.Common
+{
+ internal enum MultiHostStreamErrorType
+ {
+ Connecting,
+ Reading,
+ Writing
+ }
+
+ /// <summary>
+ /// Summary description for MultiHostStream.
+ /// </summary>
+ internal abstract class MultiHostStream : Stream
+ {
+ protected Stream stream;
+ protected int readTimeOut;
+ protected Exception baseException;
+
+ /// <summary>
+ /// Constructs a new MultiHostStream object with the given parameters
+ /// </summary>
+ /// <param name="hostList"></param>
+ /// <param name="port"></param>
+ /// <param name="readTimeOut"></param>
+ /// <param name="connectTimeOut"></param>
+ public MultiHostStream(string hostList, int port, int readTimeOut, int connectTimeOut)
+ {
+ this.readTimeOut = readTimeOut;
+ ProcessHosts( hostList, port, connectTimeOut );
+ }
+
+ // abstract members
+ protected abstract void TimeOut(MultiHostStreamErrorType error);
+ protected abstract void Error(string msg);
+ protected abstract bool CreateStream( IPAddress ip, string host, int port );
+ protected abstract bool CreateStream (string fileName);
+ protected abstract bool DataAvailable
+ {
+ get;
+ }
+
+ private void ProcessHosts( string hostList, int port, int connectTimeOut )
+ {
+ int startTime = Environment.TickCount;
+
+ int toTicks = connectTimeOut * 1000;
+
+ // support Unix sockets
+ if (hostList.StartsWith ("/"))
+ {
+ CreateStream (hostList);
+ return;
+ }
+
+ //
+ // Host name can contain multiple hosts, seperated by &.
+ string [] dnsHosts = hostList.Split('&');
+ Hashtable ips = new Hashtable();
+
+ //
+ // Each host name specified may contain multiple IP addresses
+ // Lets look at the DNS entries for each host name
+ foreach(string h in dnsHosts)
+ {
+ IPHostEntry hostAddress = Dns.GetHostByName(h);
+ foreach (IPAddress addr in hostAddress.AddressList)
+ ips.Add( addr, hostAddress.HostName );
+ }
+ IPAddress[] keys = new IPAddress[ ips.Count ];
+ ips.Keys.CopyTo( keys, 0 );
+
+ if ((Environment.TickCount - startTime) > toTicks)
+ {
+ TimeOut(MultiHostStreamErrorType.Connecting);
+ return;
+ }
+
+ // make sure they gave us at least one host
+ if (ips.Count == 0)
+ {
+ Error("You must specify at least one host");
+ return;
+ }
+
+ int index = 0;
+ // now choose a random server if there are more than one
+ if (ips.Count > 1)
+ {
+ System.Random random = new Random((int)DateTime.Now.Ticks);
+ index = random.Next(ips.Count-1);
+ }
+
+ //
+ // Lets step through our hosts until we get a connection
+ for (int i=0; i < ips.Count; i++)
+ {
+ if ((Environment.TickCount - startTime) > toTicks)
+ {
+ TimeOut(MultiHostStreamErrorType.Connecting);
+ return;
+ }
+ if (CreateStream( (IPAddress)keys[i], (string)ips[keys[i]], port ))
+ return;
+ }
+ }
+
+ public override int ReadByte()
+ {
+ int start = Environment.TickCount;
+ int ticks = readTimeOut * 1000;
+
+ while ((Environment.TickCount - start) < ticks)
+ {
+ if (DataAvailable)
+ {
+ int b = stream.ReadByte();
+ return b;
+ }
+ else
+ Thread.Sleep(0);
+ }
+
+ TimeOut(MultiHostStreamErrorType.Reading);
+ return -1;
+ }
+
+ public override int Read(byte[] buffer, int offset, int count)
+ {
+ int numToRead = count;
+ int start = Environment.TickCount;
+ int ticks = readTimeOut * 1000;
+
+ try
+ {
+ while (numToRead > 0 && (Environment.TickCount - start) < ticks)
+ {
+ if (DataAvailable)
+ {
+ int bytes_read = stream.Read( buffer, offset, numToRead);
+ if (bytes_read == 0)
+ return (count - numToRead);
+ offset += bytes_read;
+ numToRead -= bytes_read;
+ }
+ else
+ Thread.Sleep(0);
+ }
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine(ex.Message);
+ }
+
+ if (numToRead > 0)
+ TimeOut(MultiHostStreamErrorType.Reading);
+ return count;
+ }
+
+ public override bool CanRead
+ {
+ get { return stream.CanRead; }
+ }
+
+ public override bool CanWrite
+ {
+ get { return stream.CanWrite; }
+ }
+
+ public override bool CanSeek
+ {
+ get { return stream.CanSeek; }
+ }
+
+ public override long Length
+ {
+ get { return stream.Length; }
+ }
+
+ public override long Position
+ {
+ get { return stream.Position; }
+ set { stream.Position = value; }
+ }
+
+ public override void Flush()
+ {
+ stream.Flush();
+ }
+
+ public override void SetLength(long length)
+ {
+ stream.SetLength( length );
+ }
+
+ public override void Write(byte[] buffer, int offset, int count)
+ {
+ stream.Write( buffer, offset, count );
+ }
+
+ public override long Seek( long offset, SeekOrigin origin )
+ {
+ return stream.Seek( offset, origin );
+ }
+
+ }
+}
View
208 ByteFX.Data/Common/NamedPipeStream.cs
@@ -0,0 +1,208 @@
+// ByteFX.Data data access components for .Net
+// Copyright (C) 2002-2003 ByteFX, Inc.
+//
+// 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.IO;
+using System.Runtime.InteropServices;
+
+
+namespace ByteFX.Data.Common
+{
+ /// <summary>
+ /// Summary description for API.
+ /// </summary>
+ internal class NamedPipeStream : Stream
+ {
+ [DllImport("kernel32.dll", EntryPoint="CreateFile", SetLastError=true)]
+ private static extern IntPtr CreateFile(String lpFileName,
+ UInt32 dwDesiredAccess, UInt32 dwShareMode,
+ IntPtr lpSecurityAttributes, UInt32 dwCreationDisposition,
+ UInt32 dwFlagsAndAttributes,
+ IntPtr hTemplateFile);
+ [DllImport("kernel32.dll", EntryPoint="PeekNamedPipe", SetLastError=true)]
+ private static extern bool PeekNamedPipe( IntPtr handle,
+ byte[] buffer, uint nBufferSize, ref uint bytesRead,
+ ref uint bytesAvail, ref uint BytesLeftThisMessage);
+ [DllImport("kernel32.dll", SetLastError=true)]
+ private static extern bool ReadFile( IntPtr handle,
+ byte[] buffer, uint toRead, ref uint read, IntPtr lpOverLapped);
+ [DllImport("kernel32.dll", SetLastError=true)]
+ private static extern bool WriteFile( IntPtr handle,
+ byte[] buffer, uint count, ref uint written, IntPtr lpOverlapped );
+ [DllImport("kernel32.dll", SetLastError=true)]
+ private static extern bool CloseHandle( IntPtr handle );
+ [DllImport("kernel32.dll", SetLastError=true)]
+ private static extern bool FlushFileBuffers( IntPtr handle );
+
+ //Constants for dwDesiredAccess:
+ private const UInt32 GENERIC_READ = 0x80000000;
+ private const UInt32 GENERIC_WRITE = 0x40000000;
+
+ //Constants for return value:
+ private const Int32 INVALID_HANDLE_VALUE = -1;
+
+ //Constants for dwFlagsAndAttributes:
+ private const UInt32 FILE_FLAG_OVERLAPPED = 0x40000000;
+ private const UInt32 FILE_FLAG_NO_BUFFERING = 0x20000000;
+
+ //Constants for dwCreationDisposition:
+ private const UInt32 OPEN_EXISTING = 3;
+
+ IntPtr _handle;
+ FileAccess _mode;
+
+ public NamedPipeStream(string host, FileAccess mode)
+ {
+ _handle = IntPtr.Zero;
+ Open(host, mode);
+ }
+
+ public void Open( string host, FileAccess mode )
+ {
+ _mode = mode;
+ uint pipemode = 0;
+
+ if ((mode & FileAccess.Read) > 0)
+ pipemode |= GENERIC_READ;
+ if ((mode & FileAccess.Write) > 0)
+ pipemode |= GENERIC_WRITE;
+ _handle = CreateFile( host, pipemode,
+ 0, IntPtr.Zero, OPEN_EXISTING, 0, IntPtr.Zero );
+ }
+
+ public bool DataAvailable
+ {
+ get
+ {
+ uint bytesRead=0, avail=0, thismsg=0;
+
+ bool result = PeekNamedPipe( _handle,
+ null, 0, ref bytesRead, ref avail, ref thismsg );
+ return (result == true && avail > 0);
+ }
+ }
+
+ public override bool CanRead
+ {
+ get { return (_mode & FileAccess.Read) > 0; }
+ }
+
+ public override bool CanWrite
+ {
+ get { return (_mode & FileAccess.Write) > 0; }
+ }
+
+ public override bool CanSeek
+ {
+ get { throw new NotSupportedException("NamedPipeStream does not support seeking"); }
+ }
+
+ public override long Length
+ {
+ get { throw new NotSupportedException("NamedPipeStream does not support seeking"); }
+ }
+
+ public override long Position
+ {
+ get { throw new NotSupportedException("NamedPipeStream does not support seeking"); }
+ set { }
+ }
+
+ public override void Flush()
+ {
+ if (_handle == IntPtr.Zero)
+ throw new ObjectDisposedException("NamedPipeStream", "The stream has already been closed");
+ FlushFileBuffers(_handle);
+ }
+
+ public override int Read(byte[] buffer, int offset, int count)
+ {
+ if (buffer == null)
+ throw new ArgumentNullException("buffer", "The buffer to read into cannot be null");
+ if (buffer.Length < (offset + count))
+ throw new ArgumentException("Buffer is not large enough to hold requested data", "buffer");
+ if (offset < 0)
+ throw new ArgumentOutOfRangeException("offset", offset, "Offset cannot be negative");
+ if (count < 0)
+ throw new ArgumentOutOfRangeException("count", count, "Count cannot be negative");
+ if (! CanRead)
+ throw new NotSupportedException("The stream does not support reading");
+ if (_handle == IntPtr.Zero)
+ throw new ObjectDisposedException("NamedPipeStream", "The stream has already been closed");
+
+ // first read the data into an internal buffer since ReadFile cannot read into a buf at
+ // a specified offset
+ uint read=0;
+ byte[] buf = new Byte[count];
+ ReadFile( _handle, buf, (uint)count, ref read, IntPtr.Zero );
+
+ for (int x=0; x < read; x++)
+ {
+ buffer[offset+x] = buf[x];
+ }
+ return (int)read;
+ }
+
+ public override void Close()
+ {
+ CloseHandle(_handle);
+ _handle = IntPtr.Zero;
+ }
+
+ public override void SetLength(long length)
+ {
+ throw new NotSupportedException("NamedPipeStream doesn't support SetLength");
+ }
+
+ public override void Write(byte[] buffer, int offset, int count)
+ {
+ if (buffer == null)
+ throw new ArgumentNullException("buffer", "The buffer to write into cannot be null");
+ if (buffer.Length < (offset + count))
+ throw new ArgumentException("Buffer does not contain amount of requested data", "buffer");
+ if (offset < 0)
+ throw new ArgumentOutOfRangeException("offset", offset, "Offset cannot be negative");
+ if (count < 0)
+ throw new ArgumentOutOfRangeException("count", count, "Count cannot be negative");
+ if (! CanWrite)
+ throw new NotSupportedException("The stream does not support writing");
+ if (_handle == IntPtr.Zero)
+ throw new ObjectDisposedException("NamedPipeStream", "The stream has already been closed");
+
+ // copy data to internal buffer to allow writing from a specified offset
+ byte[] buf = new Byte[count];
+ for (int x=0; x < count; x++)
+ {
+ buf[x] = buffer[offset+x];
+ }
+ uint written=0;
+ bool result = WriteFile( _handle, buf, (uint)count, ref written, IntPtr.Zero );
+
+ if (! result)
+ throw new IOException("Writing to the stream failed");
+ if (written < count)
+ throw new IOException("Unable to write entire buffer to stream");
+ }
+
+ public override long Seek( long offset, SeekOrigin origin )
+ {
+ throw new NotSupportedException("NamedPipeStream doesn't support seeking");
+ }
+ }
+}
+
+
View
41 ByteFX.Data/Common/Platform.cs
@@ -0,0 +1,41 @@
+using System;
+
+// ByteFX.Data data access components for .Net
+// Copyright (C) 2002-2004 ByteFX, Inc.
+//
+// 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
+
+namespace ByteFX.Data.Common
+{
+ /// <summary>
+ /// Summary description for Platform.
+ /// </summary>
+ internal class Platform
+ {
+ public static bool IsWindows()
+ {
+ OperatingSystem os = Environment.OSVersion;
+ switch (os.Platform)
+ {
+ case PlatformID.Win32NT:
+ case PlatformID.Win32S:
+ case PlatformID.Win32Windows:
+ case PlatformID.WinCE:
+ return true;
+ }
+ return false;
+ }
+ }
+}
View
25 ByteFX.Data/Common/Security.cs
@@ -0,0 +1,25 @@
+using System;
+
+namespace ByteFX.Data.Common
+{
+ /// <summary>
+ /// Summary description for Security.
+ /// </summary>
+ internal class Security
+ {
+ public Security()
+ {
+ }
+
+ public static void ArrayCrypt( byte[] src, int srcoff, byte[] dst, int dstoff, byte[] key, int length )
+ {
+ int idx = 0;
+
+ while ( (idx+srcoff) < src.Length && idx < length )
+ {
+ dst[idx+dstoff] = (byte)(src[idx+srcoff] ^ key[idx]);
+ idx++;
+ }
+ }
+ }
+}
View
244 ByteFX.Data/Common/SqlCommandEditorDlg.cs
@@ -0,0 +1,244 @@
+// ByteFX.Data data access components for .Net
+// Copyright (C) 2002-2003 ByteFX, Inc.
+//
+// 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.Windows.Forms;
+using System.Data;
+using ByteFX.Data.MySqlClient;
+
+namespace ByteFX.Data.Common
+{
+ /// <summary>
+ /// Summary description for SqlCommandEditorDlg.
+ /// </summary>
+ internal class SqlCommandEditorDlg : System.Windows.Forms.Form
+ {
+ private System.Windows.Forms.TextBox sqlText;
+ private System.Windows.Forms.Button CancelBtn;
+ private System.Windows.Forms.Button OKBtn;
+ private System.Windows.Forms.Panel panel1;
+ private System.Windows.Forms.Splitter splitter1;
+ private System.Windows.Forms.DataGrid dataGrid;
+ private System.Windows.Forms.ContextMenu sqlMenu;
+ private System.Windows.Forms.MenuItem runMenuItem;
+ private IDbCommand command;
+ private System.Windows.Forms.DataGridTableStyle dataGridTableStyle1;
+
+ /// <summary>
+ /// Required designer variable.
+ /// </summary>
+ private System.ComponentModel.Container components = null;
+
+ public SqlCommandEditorDlg(object o)
+ {
+ command = (IDbCommand)o;
+
+ InitializeComponent();
+ }
+
+ /// <summary>
+ /// Clean up any resources being used.
+ /// </summary>
+ protected override void Dispose( bool disposing )
+ {
+ if( disposing )
+ {
+ if(components != null)
+ {
+ components.Dispose();
+ }
+ }
+ base.Dispose( disposing );
+ }
+
+ public string SQL
+ {
+ get { return sqlText.Text; }
+ set { sqlText.Text = value; }
+ }
+
+ #region Windows Form Designer generated code
+ /// <summary>
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ /// </summary>
+ private void InitializeComponent()
+ {
+ this.sqlText = new System.Windows.Forms.TextBox();
+ this.sqlMenu = new System.Windows.Forms.ContextMenu();
+ this.runMenuItem = new System.Windows.Forms.MenuItem();
+ this.CancelBtn = new System.Windows.Forms.Button();
+ this.OKBtn = new System.Windows.Forms.Button();
+ this.panel1 = new System.Windows.Forms.Panel();
+ this.splitter1 = new System.Windows.Forms.Splitter();
+ this.dataGrid = new System.Windows.Forms.DataGrid();
+ this.dataGridTableStyle1 = new System.Windows.Forms.DataGridTableStyle();
+ this.panel1.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.dataGrid)).BeginInit();
+ this.SuspendLayout();
+ //
+ // sqlText
+ //
+ this.sqlText.ContextMenu = this.sqlMenu;
+ this.sqlText.Dock = System.Windows.Forms.DockStyle.Top;
+ this.sqlText.Location = new System.Drawing.Point(10, 10);
+ this.sqlText.Multiline = true;
+ this.sqlText.Name = "sqlText";
+ this.sqlText.Size = new System.Drawing.Size(462, 144);
+ this.sqlText.TabIndex = 0;
+ this.sqlText.Text = "";
+ //
+ // sqlMenu
+ //
+ this.sqlMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
+ this.runMenuItem});
+ //
+ // runMenuItem
+ //
+ this.runMenuItem.Index = 0;
+ this.runMenuItem.Text = "Run";
+ this.runMenuItem.Click += new System.EventHandler(this.runMenuItem_Click);
+ //
+ // CancelBtn
+ //
+ this.CancelBtn.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
+ this.CancelBtn.DialogResult = System.Windows.Forms.DialogResult.Cancel;
+ this.CancelBtn.Location = new System.Drawing.Point(400, 350);
+ this.CancelBtn.Name = "CancelBtn";
+ this.CancelBtn.TabIndex = 3;
+ this.CancelBtn.Text = "Cancel";
+ this.CancelBtn.Click += new System.EventHandler(this.CancelBtn_Click);
+ //
+ // OKBtn
+ //
+ this.OKBtn.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
+ this.OKBtn.DialogResult = System.Windows.Forms.DialogResult.OK;
+ this.OKBtn.Location = new System.Drawing.Point(316, 350);
+ this.OKBtn.Name = "OKBtn";
+ this.OKBtn.TabIndex = 4;
+ this.OKBtn.Text = "OK";
+ this.OKBtn.Click += new System.EventHandler(this.OKBtn_Click);
+ //
+ // panel1
+ //
+ this.panel1.Anchor = (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right);
+ this.panel1.Controls.AddRange(new System.Windows.Forms.Control[] {
+ this.splitter1,
+ this.dataGrid,
+ this.sqlText});
+ this.panel1.DockPadding.Bottom = 10;
+ this.panel1.DockPadding.Left = 10;
+ this.panel1.DockPadding.Right = 14;
+ this.panel1.DockPadding.Top = 10;
+ this.panel1.Location = new System.Drawing.Point(2, 2);
+ this.panel1.Name = "panel1";
+ this.panel1.Size = new System.Drawing.Size(486, 344);
+ this.panel1.TabIndex = 5;
+ //
+ // splitter1
+ //
+ this.splitter1.Dock = System.Windows.Forms.DockStyle.Top;
+ this.splitter1.Location = new System.Drawing.Point(10, 154);
+ this.splitter1.Name = "splitter1";
+ this.splitter1.Size = new System.Drawing.Size(462, 3);
+ this.splitter1.TabIndex = 3;
+ this.splitter1.TabStop = false;
+ //
+ // dataGrid
+ //
+ this.dataGrid.CaptionVisible = false;
+ this.dataGrid.DataMember = "";
+ this.dataGrid.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.dataGrid.HeaderForeColor = System.Drawing.SystemColors.ControlText;
+ this.dataGrid.Location = new System.Drawing.Point(10, 154);
+ this.dataGrid.Name = "dataGrid";
+ this.dataGrid.Size = new System.Drawing.Size(462, 180);
+ this.dataGrid.TabIndex = 2;
+ this.dataGrid.TableStyles.AddRange(new System.Windows.Forms.DataGridTableStyle[] {
+ this.dataGridTableStyle1});
+ //
+ // dataGridTableStyle1
+ //
+ this.dataGridTableStyle1.AllowSorting = false;
+ this.dataGridTableStyle1.DataGrid = this.dataGrid;
+ this.dataGridTableStyle1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
+ this.dataGridTableStyle1.MappingName = "";
+ //
+ // SqlCommandEditorDlg
+ //
+ this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
+ this.ClientSize = new System.Drawing.Size(486, 384);
+ this.ControlBox = false;
+ this.Controls.AddRange(new System.Windows.Forms.Control[] {
+ this.panel1,
+ this.OKBtn,
+ this.CancelBtn});
+ this.DockPadding.Bottom = 10;
+ this.DockPadding.Left = 10;
+ this.DockPadding.Right = 12;
+ this.DockPadding.Top = 10;
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
+ this.Name = "SqlCommandEditorDlg";
+ this.Text = "Query Builder";
+ this.panel1.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)(this.dataGrid)).EndInit();
+ this.ResumeLayout(false);
+
+ }
+ #endregion
+
+ private void CancelBtn_Click(object sender, System.EventArgs e)
+ {
+ this.Close();
+ }
+
+ private void OKBtn_Click(object sender, System.EventArgs e)
+ {
+ this.Close();
+ }
+
+ private void runMenuItem_Click(object sender, System.EventArgs e)
+ {
+ if (command is MySqlCommand)
+ {
+ RunMySql();
+ }
+ }
+
+ private void RunMySql()
+ {
+ try
+ {
+ MySqlDataAdapter da = new MySqlDataAdapter((MySqlCommand)command);
+ command.CommandText = sqlText.Text;
+ command.Connection.Open();
+ DataTable dt = new DataTable();
+ da.Fill(dt);
+ dataGrid.DataSource = dt;
+ command.Connection.Close();
+ dataGrid.Expand(-1);
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message);
+ }
+ }
+
+ }
+}
View
105 ByteFX.Data/Common/SqlCommandEditorDlg.resx
@@ -0,0 +1,105 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 1.3
+
+ The primary goals of this format is to allow a simple XML format
+ that is mostly human readable. The generation and parsing of the
+ various data types are done through the TypeConverter classes
+ associated with the data types.
+
+ Example:
+
+ ... ado.net/XML headers & schema ...
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
+ <resheader name="version">1.3</resheader>
+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+ <data name="Name1">this is my long string</data>
+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+ [base64 mime encoded serialized .NET Framework object]
+ </data>
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ [base64 mime encoded string representing a byte array form of the .NET Framework object]
+ </data>
+
+ There are any number of "resheader" rows that contain simple
+ name/value pairs.
+
+ Each data row contains a name, and value. The row also contains a
+ type or mimetype. Type corresponds to a .NET class that support
+ text/value conversion through the TypeConverter architecture.
+ Classes that don't support this are serialized and stored with the
+ mimetype set.
+
+ The mimetype is used for serialized objects, and tells the
+ ResXResourceReader how to depersist the object. This is currently not
+ extensible. For a given mimetype the value must be set accordingly:
+
+ Note - application/x-microsoft.net.object.binary.base64 is the format
+ that the ResXResourceWriter will generate, however the reader can
+ read any of the formats listed below.
+
+ mimetype: application/x-microsoft.net.object.binary.base64
+ value : The object must be serialized with
+ : System.Serialization.Formatters.Binary.BinaryFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.soap.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+ : and then encoded with base64 encoding.
+ mimetype: application/x-microsoft.net.object.bytearray.base64
+ value : The object must be serialized into a byte array
+ : using a System.ComponentModel.TypeConverter
+ : and then encoded with base64 encoding.
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>1.3</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <data name="sqlMenu.Location" type="System.Drawing.Point, System.Drawing, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+ <value>17, 17</value>
+ </data>
+ <data name="$this.Name">
+ <value>SqlCommandEditorDlg</value>
+ </data>
+</root>
View
63 ByteFX.Data/Common/SqlCommandTextEditor.cs
@@ -0,0 +1,63 @@
+// ByteFX.Data data access components for .Net
+// Copyright (C) 2002-2003 ByteFX, Inc.
+//
+// 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
+
+#if WINDOWS
+using System;
+using System.Windows.Forms;
+using System.Drawing.Design;
+
+namespace ByteFX.Data.Common
+{
+ /// <summary>
+ /// Summary description for MySqlConnectionDesign.
+ /// </summary>
+ internal class SqlCommandTextEditor : UITypeEditor
+ {
+ public override System.Drawing.Design.UITypeEditorEditStyle GetEditStyle(System.ComponentModel.ITypeDescriptorContext context)
+ {
+ return System.Drawing.Design.UITypeEditorEditStyle.Modal;
+ }
+
+ public override bool GetPaintValueSupported(System.ComponentModel.ITypeDescriptorContext context)
+ {
+ return false;
+ }
+
+ public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value)
+ {
+ System.Data.IDbCommand command = (System.Data.IDbCommand)context.Instance;
+
+ if (command.Connection == null)
+ {
+ MessageBox.Show("Connection property not set to a valid connection.\n"+
+ "Please set and try again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return value;
+ }
+
+ SqlCommandEditorDlg dlg = new SqlCommandEditorDlg( command );
+
+ dlg.SQL = (string)value;
+ if(dlg.ShowDialog() == DialogResult.OK)
+ {
+ return dlg.SQL;
+ }
+ else
+ return value;
+ }
+ }
+}
+#endif
View
148 ByteFX.Data/Common/StreamCreator.cs
@@ -0,0 +1,148 @@
+// ByteFX.Data data access components for .Net
+// Copyright (C) 2002-2004 ByteFX, Inc.
+//
+// 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.IO;
+using System.Net;
+using System.Net.Sockets;
+using System.Collections;
+#if __MonoCS__
+using Mono.Posix;
+#endif
+
+namespace ByteFX.Data.Common
+{
+ /// <summary>
+ /// Summary description for StreamCreator.
+ /// </summary>
+ internal class StreamCreator
+ {
+ string hostList;
+ int port;
+ string pipeName;
+ int timeOut;
+
+ public StreamCreator( string hosts, int port, string pipeName)
+ {
+ hostList = hosts;
+ this.port = port;
+ this.pipeName = pipeName;
+ }
+
+ public Stream GetStream(int timeOut)
+ {
+ this.timeOut = timeOut;
+
+ if (hostList.StartsWith("/"))
+ return CreateUnixSocketStream();
+
+ string [] dnsHosts = hostList.Split('&');
+ ArrayList ipAddresses = new ArrayList();
+ ArrayList hostNames = new ArrayList();
+
+ //
+ // Each host name specified may contain multiple IP addresses
+ // Lets look at the DNS entries for each host name
+ foreach (string h in dnsHosts)
+ {
+ IPHostEntry hostAddress = Dns.GetHostByName(h);
+ foreach (IPAddress addr in hostAddress.AddressList)
+ {
+ ipAddresses.Add( addr );
+ hostNames.Add( hostAddress.HostName );
+ }
+ }
+
+ System.Random random = new Random((int)DateTime.Now.Ticks);
+ int index = random.Next(ipAddresses.Count-1);
+
+ bool usePipe = pipeName != String.Empty;
+ Stream stream = null;
+ for (int i=0; i < ipAddresses.Count; i++)
+ {
+ if (usePipe)
+ stream = CreateNamedPipeStream( (string)hostNames[index] );
+ else
+ stream = CreateSocketStream( (IPAddress)ipAddresses[index], port );
+ if (stream != null) return stream;
+
+ index++;
+ if (index == ipAddresses.Count) index = 0;
+ }
+
+ return stream;
+ }
+
+ private Stream CreateUnixSocketStream()
+ {
+#if __MonoCS__ && !WINDOWS
+
+ Socket socket = new Socket (AddressFamily.Unix, SocketType.Stream, ProtocolType.IP);
+
+ try
+ {
+ UnixEndPoint endPoint = new UnixEndPoint (hostList);
+ socket.Connect (endPoint);
+ return new NetworkStream (socket, true);
+ }
+ catch (Exception ex)
+ {
+ return null;
+ }
+#else
+ throw new PlatformNotSupportedException ("Unix sockets are only supported on this platform");
+#endif
+ }
+
+ private Stream CreateNamedPipeStream( string hostname )
+ {
+ string pipePath;
+ if (hostname.ToLower().Equals("localhost"))
+ pipePath = @"\\.\pipe\" + pipeName;
+ else
+ pipePath = String.Format(@"\\{0}\pipe\{1}", hostname.ToString(), pipeName);
+ return new NamedPipeStream(pipePath, FileAccess.ReadWrite);
+ }
+
+ private void ConnectSocketCallback( IAsyncResult iar )
+ {
+ }
+
+ private Stream CreateSocketStream( IPAddress ip, int port )
+ {
+ Socket socket = new Socket(AddressFamily.InterNetwork,
+ SocketType.Stream, ProtocolType.Tcp);
+
+ try
+ {
+ //
+ // Lets try to connect
+ IPEndPoint endPoint = new IPEndPoint( ip, port);
+// IAsyncResult iar = socket.BeginConnect( endPoint,
+// new AsyncCallback(ConnectSocketCallback), socket );
+
+ socket.Connect(endPoint);
+ socket.SetSocketOption( SocketOptionLevel.Tcp, SocketOptionName.NoDelay, 1 );
+ return new NetworkStream( socket, true );
+ }
+ catch (Exception)