mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-17 19:10:23 -10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
395708bec9 |
No files matched your search
-51
@@ -1,51 +0,0 @@
|
||||
/* config.h.in. Generated automatically from configure.in by autoheader 2.13. */
|
||||
|
||||
/* Define if you have the ANSI C header files. */
|
||||
#undef STDC_HEADERS
|
||||
|
||||
#undef HAVE_INET_PTON
|
||||
#undef HAVE_INET_ATON
|
||||
#undef HAVE_SOL_IP
|
||||
#undef HAVE_SOL_TCP
|
||||
#undef HAVE_IP_PKTINFO
|
||||
#undef HAVE_STRUCT_IP_MREQN
|
||||
#undef HAVE_PTHREAD
|
||||
#undef HAVE_PTHREAD_MUTEX_TIMEDLOCK
|
||||
#undef USE_MONO_MUTEX
|
||||
#undef HAVE_LARGE_FILE_SUPPORT
|
||||
#undef PLATFORM_WIN32
|
||||
#undef HAVE_NEW_ICONV
|
||||
#undef NAME_DEV_RANDOM
|
||||
#undef HAVE_CRYPT_RNG
|
||||
#undef HAVE_BOEHM_GC
|
||||
|
||||
/* The number of bytes in a void *. */
|
||||
#undef SIZEOF_VOID_P
|
||||
|
||||
/* Define if you have the inet_aton function. */
|
||||
#undef HAVE_INET_ATON
|
||||
|
||||
/* Define if you have the inet_pton function. */
|
||||
#undef HAVE_INET_PTON
|
||||
|
||||
/* Define if you have the <dlfcn.h> header file. */
|
||||
#undef HAVE_DLFCN_H
|
||||
|
||||
/* Define if you have the <netdb.h> header file. */
|
||||
#undef HAVE_NETDB_H
|
||||
|
||||
/* Define if you have the <sys/filio.h> header file. */
|
||||
#undef HAVE_SYS_FILIO_H
|
||||
|
||||
/* Define if you have the <sys/sockio.h> header file. */
|
||||
#undef HAVE_SYS_SOCKIO_H
|
||||
|
||||
/* Define if you have the <utime.h> header file. */
|
||||
#undef HAVE_UTIME_H
|
||||
|
||||
/* Name of package */
|
||||
#undef PACKAGE
|
||||
|
||||
/* Version number of package */
|
||||
#undef VERSION
|
||||
|
||||
@@ -1,246 +0,0 @@
|
||||
System.Object
|
||||
System.Exception
|
||||
System.ValueType
|
||||
System.Delegate
|
||||
System.MulticastDelegate
|
||||
System.Enum
|
||||
System.Activator
|
||||
System.ArgIterator
|
||||
System.__ComObject
|
||||
System.TypedReference
|
||||
System.Security.AllowPartiallyTrustedCallersAttribute
|
||||
System.Runtime.Serialization.Formatter
|
||||
System.Runtime.Serialization.FormatterConverter
|
||||
System.Runtime.Serialization.FormatterServices
|
||||
System.Runtime.Serialization.ObjectIDGenerator
|
||||
System.Runtime.Serialization.ObjectManager
|
||||
System.Reflection.ModuleResolveEventHandler
|
||||
System.Reflection.Pointer
|
||||
System.Globalization.CompareInfo
|
||||
System.Globalization.HebrewCalendar
|
||||
System.Globalization.HijriCalendar
|
||||
System.Globalization.JapaneseCalendar
|
||||
System.Globalization.KoreanCalendar
|
||||
System.Globalization.SortKey
|
||||
System.Globalization.StringInfo
|
||||
System.Globalization.TaiwanCalendar
|
||||
System.Globalization.TextElementEnumerator
|
||||
System.Globalization.TextInfo
|
||||
System.Globalization.ThaiBuddhistCalendar
|
||||
System.IO.IsolatedStorage.IsolatedStorageFile
|
||||
System.Reflection.Emit.MethodRental
|
||||
System.Runtime.CompilerServices.AccessedThroughPropertyAttribute
|
||||
System.Runtime.CompilerServices.CallConvCdecl
|
||||
System.Runtime.CompilerServices.CallConvStdcall
|
||||
System.Runtime.CompilerServices.CallConvThiscall
|
||||
System.Runtime.CompilerServices.CallConvFastcall
|
||||
System.Runtime.CompilerServices.CustomConstantAttribute
|
||||
System.Runtime.CompilerServices.DateTimeConstantAttribute
|
||||
System.Runtime.CompilerServices.DiscardableAttribute
|
||||
System.Runtime.CompilerServices.DecimalConstantAttribute
|
||||
System.Runtime.CompilerServices.CompilationRelaxationsAttribute
|
||||
System.Runtime.CompilerServices.CompilerGlobalScopeAttribute
|
||||
System.Runtime.CompilerServices.IDispatchConstantAttribute
|
||||
System.Runtime.CompilerServices.IsVolatile
|
||||
System.Runtime.CompilerServices.IUnknownConstantAttribute
|
||||
System.Runtime.CompilerServices.RequiredAttributeAttribute
|
||||
System.Runtime.InteropServices.ArrayWithOffset
|
||||
System.Runtime.InteropServices.DispIdAttribute
|
||||
System.Runtime.InteropServices.ClassInterfaceType
|
||||
System.Runtime.InteropServices.ClassInterfaceAttribute
|
||||
System.Runtime.InteropServices.ComVisibleAttribute
|
||||
System.Runtime.InteropServices.LCIDConversionAttribute
|
||||
System.Runtime.InteropServices.ComRegisterFunctionAttribute
|
||||
System.Runtime.InteropServices.ComUnregisterFunctionAttribute
|
||||
System.Runtime.InteropServices.ProgIdAttribute
|
||||
System.Runtime.InteropServices.ImportedFromTypeLibAttribute
|
||||
System.Runtime.InteropServices.IDispatchImplType
|
||||
System.Runtime.InteropServices.IDispatchImplAttribute
|
||||
System.Runtime.InteropServices.ComSourceInterfacesAttribute
|
||||
System.Runtime.InteropServices.ComConversionLossAttribute
|
||||
System.Runtime.InteropServices.TypeLibTypeFlags
|
||||
System.Runtime.InteropServices.TypeLibFuncFlags
|
||||
System.Runtime.InteropServices.TypeLibVarFlags
|
||||
System.Runtime.InteropServices.TypeLibTypeAttribute
|
||||
System.Runtime.InteropServices.TypeLibFuncAttribute
|
||||
System.Runtime.InteropServices.TypeLibVarAttribute
|
||||
System.Runtime.InteropServices.ComImportAttribute
|
||||
System.Runtime.InteropServices.PreserveSigAttribute
|
||||
System.Runtime.InteropServices.ComAliasNameAttribute
|
||||
System.Runtime.InteropServices.AutomationProxyAttribute
|
||||
System.Runtime.InteropServices.PrimaryInteropAssemblyAttribute
|
||||
System.Runtime.InteropServices.CoClassAttribute
|
||||
System.Runtime.InteropServices.ComEventInterfaceAttribute
|
||||
System.Runtime.InteropServices.COMException
|
||||
System.Runtime.InteropServices.ComMemberType
|
||||
System.Runtime.InteropServices.CurrencyWrapper
|
||||
System.Runtime.InteropServices.DispatchWrapper
|
||||
System.Runtime.InteropServices.ErrorWrapper
|
||||
System.Runtime.InteropServices.ExtensibleClassFactory
|
||||
System.Runtime.InteropServices.HandleRef
|
||||
System.Runtime.InteropServices.InvalidComObjectException
|
||||
System.Runtime.InteropServices.InvalidOleVariantTypeException
|
||||
System.Runtime.InteropServices.TypeLibImporterFlags
|
||||
System.Runtime.InteropServices.ExporterEventKind
|
||||
System.Runtime.InteropServices.ITypeLibExporterNotifySink
|
||||
System.Runtime.InteropServices.ITypeLibConverter
|
||||
System.Runtime.InteropServices.MarshalDirectiveException
|
||||
System.Runtime.InteropServices.ObjectCreationDelegate
|
||||
System.Runtime.InteropServices.RuntimeEnvironment
|
||||
System.Runtime.InteropServices.RegistrationServices
|
||||
System.Runtime.InteropServices.SafeArrayRankMismatchException
|
||||
System.Runtime.InteropServices.SafeArrayTypeMismatchException
|
||||
System.Runtime.InteropServices.SEHException
|
||||
System.Runtime.InteropServices.TypeLibConverter
|
||||
System.Runtime.InteropServices.BIND_OPTS
|
||||
System.Runtime.InteropServices.UCOMIBindCtx
|
||||
System.Runtime.InteropServices.UCOMIConnectionPointContainer
|
||||
System.Runtime.InteropServices.UCOMIConnectionPoint
|
||||
System.Runtime.InteropServices.UCOMIEnumMoniker
|
||||
System.Runtime.InteropServices.CONNECTDATA
|
||||
System.Runtime.InteropServices.UCOMIEnumConnections
|
||||
System.Runtime.InteropServices.UCOMIEnumConnectionPoints
|
||||
System.Runtime.InteropServices.UCOMIEnumString
|
||||
System.Runtime.InteropServices.UCOMIEnumVARIANT
|
||||
System.Runtime.InteropServices.FILETIME
|
||||
System.Runtime.InteropServices.UCOMIMoniker
|
||||
System.Runtime.InteropServices.UCOMIPersistFile
|
||||
System.Runtime.InteropServices.UCOMIRunningObjectTable
|
||||
System.Runtime.InteropServices.STATSTG
|
||||
System.Runtime.InteropServices.UCOMIStream
|
||||
System.Runtime.InteropServices.DESCKIND
|
||||
System.Runtime.InteropServices.BINDPTR
|
||||
System.Runtime.InteropServices.UCOMITypeComp
|
||||
System.Runtime.InteropServices.TYPEKIND
|
||||
System.Runtime.InteropServices.TYPEFLAGS
|
||||
System.Runtime.InteropServices.IMPLTYPEFLAGS
|
||||
System.Runtime.InteropServices.TYPEATTR
|
||||
System.Runtime.InteropServices.FUNCDESC
|
||||
System.Runtime.InteropServices.IDLFLAG
|
||||
System.Runtime.InteropServices.IDLDESC
|
||||
System.Runtime.InteropServices.PARAMFLAG
|
||||
System.Runtime.InteropServices.PARAMDESC
|
||||
System.Runtime.InteropServices.TYPEDESC
|
||||
System.Runtime.InteropServices.ELEMDESC
|
||||
System.Runtime.InteropServices.VARDESC
|
||||
System.Runtime.InteropServices.DISPPARAMS
|
||||
System.Runtime.InteropServices.EXCEPINFO
|
||||
System.Runtime.InteropServices.FUNCKIND
|
||||
System.Runtime.InteropServices.INVOKEKIND
|
||||
System.Runtime.InteropServices.CALLCONV
|
||||
System.Runtime.InteropServices.FUNCFLAGS
|
||||
System.Runtime.InteropServices.VARFLAGS
|
||||
System.Runtime.InteropServices.UCOMITypeInfo
|
||||
System.Runtime.InteropServices.SYSKIND
|
||||
System.Runtime.InteropServices.LIBFLAGS
|
||||
System.Runtime.InteropServices.TYPELIBATTR
|
||||
System.Runtime.InteropServices.UCOMITypeLib
|
||||
System.Runtime.InteropServices.UnknownWrapper
|
||||
System.Runtime.Remoting.IObjectHandle
|
||||
System.Runtime.Remoting.IRemotingTypeInfo
|
||||
System.Runtime.Remoting.IChannelInfo
|
||||
System.Runtime.Remoting.IEnvoyInfo
|
||||
System.Runtime.Remoting.RemotingConfiguration
|
||||
System.Runtime.Remoting.TypeEntry
|
||||
System.Runtime.Remoting.ActivatedClientTypeEntry
|
||||
System.Runtime.Remoting.ActivatedServiceTypeEntry
|
||||
System.Runtime.Remoting.WellKnownClientTypeEntry
|
||||
System.Runtime.Remoting.WellKnownServiceTypeEntry
|
||||
System.Runtime.Remoting.RemotingException
|
||||
System.Runtime.Remoting.ServerException
|
||||
System.Runtime.Remoting.RemotingTimeoutException
|
||||
System.Runtime.Remoting.RemotingServices
|
||||
System.Runtime.Remoting.InternalRemotingServices
|
||||
System.Runtime.Remoting.SoapServices
|
||||
System.Runtime.Remoting.Activation.UrlAttribute
|
||||
System.Runtime.Remoting.Messaging.IMessageSink
|
||||
System.Runtime.Remoting.Messaging.AsyncResult
|
||||
System.Runtime.Remoting.Messaging.CallContext
|
||||
System.Runtime.Remoting.Messaging.ILogicalThreadAffinative
|
||||
System.Runtime.Remoting.Messaging.InternalMessageWrapper
|
||||
System.Runtime.Remoting.Messaging.IMethodCallMessage
|
||||
System.Runtime.Remoting.Messaging.MethodCallMessageWrapper
|
||||
System.Runtime.Remoting.Messaging.HeaderHandler
|
||||
System.Runtime.Remoting.Messaging.IMessageCtrl
|
||||
System.Runtime.Remoting.Messaging.IRemotingFormatter
|
||||
System.Runtime.Remoting.Messaging.ReturnMessage
|
||||
System.Runtime.Remoting.Messaging.MethodCall
|
||||
System.Runtime.Remoting.Messaging.ConstructionCall
|
||||
System.Runtime.Remoting.Messaging.MethodResponse
|
||||
System.Runtime.Remoting.Messaging.ConstructionResponse
|
||||
System.Runtime.Remoting.Messaging.MethodReturnMessageWrapper
|
||||
System.Runtime.Remoting.Messaging.OneWayAttribute
|
||||
System.Runtime.Remoting.Messaging.MessageSurrogateFilter
|
||||
System.Runtime.Remoting.Messaging.RemotingSurrogateSelector
|
||||
System.Runtime.Remoting.Contexts.CrossContextDelegate
|
||||
System.Runtime.Remoting.Contexts.ContextProperty
|
||||
System.Runtime.Remoting.Contexts.IContextPropertyActivator
|
||||
System.Runtime.Remoting.Contexts.IContributeClientContextSink
|
||||
System.Runtime.Remoting.Contexts.IContributeDynamicSink
|
||||
System.Runtime.Remoting.Contexts.IContributeEnvoySink
|
||||
System.Runtime.Remoting.Contexts.IContributeObjectSink
|
||||
System.Runtime.Remoting.Contexts.IContributeServerContextSink
|
||||
System.Runtime.Serialization.Formatters.InternalRM
|
||||
System.Runtime.Serialization.Formatters.InternalST
|
||||
System.Runtime.Serialization.Formatters.SoapMessage
|
||||
System.Runtime.Serialization.Formatters.SoapFault
|
||||
System.Runtime.Serialization.Formatters.ServerFault
|
||||
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
System.Security.Cryptography.CryptoConfig
|
||||
System.Security.Cryptography.KeyedHashAlgorithm
|
||||
System.Security.Cryptography.HMACSHA1
|
||||
System.Security.Cryptography.MACTripleDES
|
||||
System.Security.Cryptography.MaskGenerationMethod
|
||||
System.Security.Cryptography.PasswordDeriveBytes
|
||||
System.Security.Cryptography.PKCS1MaskGenerationMethod
|
||||
System.Security.Cryptography.RC2
|
||||
System.Security.Cryptography.RC2CryptoServiceProvider
|
||||
System.Security.Cryptography.RSACryptoServiceProvider
|
||||
System.Security.Cryptography.RSAOAEPKeyExchangeDeformatter
|
||||
System.Security.Cryptography.RSAOAEPKeyExchangeFormatter
|
||||
System.Security.Cryptography.RSAPKCS1KeyExchangeDeformatter
|
||||
System.Security.Cryptography.RSAPKCS1KeyExchangeFormatter
|
||||
System.Security.Cryptography.RSAPKCS1SignatureDeformatter
|
||||
System.Security.Cryptography.RSAPKCS1SignatureFormatter
|
||||
System.Security.Cryptography.SHA1Managed
|
||||
System.Security.Cryptography.TripleDES
|
||||
System.Security.Cryptography.TripleDESCryptoServiceProvider
|
||||
System.Security.Permissions.EnvironmentPermission
|
||||
System.Security.Permissions.FileDialogPermission
|
||||
System.Security.Permissions.IsolatedStorageFilePermission
|
||||
System.Security.Permissions.PrincipalPermissionAttribute
|
||||
System.Security.Permissions.SecurityPermissionAttribute
|
||||
System.Security.Permissions.PublisherIdentityPermissionAttribute
|
||||
System.Security.Permissions.PublisherIdentityPermission
|
||||
System.Security.Permissions.ReflectionPermission
|
||||
System.Security.Permissions.RegistryPermission
|
||||
System.Security.Permissions.PrincipalPermission
|
||||
System.Security.Permissions.SiteIdentityPermission
|
||||
System.Security.Permissions.StrongNameIdentityPermission
|
||||
System.Security.Permissions.StrongNamePublicKeyBlob
|
||||
System.Security.Permissions.UIPermission
|
||||
System.Security.Permissions.UrlIdentityPermission
|
||||
System.Security.Permissions.ZoneIdentityPermission
|
||||
System.Security.Policy.ApplicationDirectory
|
||||
System.Security.Policy.ApplicationDirectoryMembershipCondition
|
||||
System.Security.Policy.FirstMatchCodeGroup
|
||||
System.Security.Policy.Hash
|
||||
System.Security.Policy.HashMembershipCondition
|
||||
System.Security.Policy.NetCodeGroup
|
||||
System.Security.Policy.PermissionRequestEvidence
|
||||
System.Security.Policy.Publisher
|
||||
System.Security.Policy.PublisherMembershipCondition
|
||||
System.Security.Policy.Site
|
||||
System.Security.Policy.SiteMembershipCondition
|
||||
System.Security.Policy.StrongName
|
||||
System.Security.Policy.StrongNameMembershipCondition
|
||||
System.Security.Policy.UnionCodeGroup
|
||||
System.Security.Policy.Url
|
||||
System.Security.Policy.UrlMembershipCondition
|
||||
System.Security.Policy.Zone
|
||||
System.Security.Policy.ZoneMembershipCondition
|
||||
System.Security.Principal.WindowsIdentity
|
||||
System.Security.Principal.WindowsImpersonationContext
|
||||
System.Security.Principal.WindowsPrincipal
|
||||
System.Threading.CompressedStack
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
Currently you can read our plans for <a
|
||||
href="ado-net.html">ADO.NET</a>, <a
|
||||
href="asp-net.html">ASP.NET</a>, <a href="java.html">Java</a> and
|
||||
href="asp-net">ASP.NET</a>, <a href="java.html">Java</a> and
|
||||
<a href="winforms.html">WinForms</a>.
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -82,7 +82,7 @@
|
||||
{
|
||||
string connectionString = "URI=file:SqliteTest.db";
|
||||
IDbConnection dbcon;
|
||||
dbcon = new SqliteConnection(connectionString);
|
||||
dbcon = new MySQLConnection(connectionString);
|
||||
dbcon.Open();
|
||||
IDbCommand dbcmd = dbcon.CreateCommand();
|
||||
// requires a table to be created named employee
|
||||
|
||||
+1
-3
@@ -271,8 +271,6 @@ Visit http://mail.ximian.com/mailman/mono-list for details.
|
||||
.SH WEB SITE
|
||||
Visit: http://www.go-mono.com for details
|
||||
.SH SEE ALSO
|
||||
.BR mcs(1), mint(1), monodis(1), mono-config(5).
|
||||
.PP
|
||||
For ASP.NET-related documentation, see the xsp(1) manual page
|
||||
.BR mcs(1), mint(1), monodis(1), mono-config(5)
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ using System.Runtime.CompilerServices;
|
||||
// You can specify all the values or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
|
||||
[assembly: AssemblyVersion("0.7.4.*")]
|
||||
[assembly: AssemblyVersion("0.7.2.*")]
|
||||
|
||||
//
|
||||
// In order to sign your assembly you must specify a key to use. Refer to the
|
||||
@@ -53,6 +53,6 @@ using System.Runtime.CompilerServices;
|
||||
// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
|
||||
// documentation for more information on this.
|
||||
//
|
||||
[assembly: AssemblyDelaySign(false)]
|
||||
[assembly: AssemblyKeyFile("..\\..\\bytefx.snk")]
|
||||
[assembly: AssemblyKeyName("")]
|
||||
//[assembly: AssemblyDelaySign(false)]
|
||||
//[assembly: AssemblyKeyFile("..\\..\\bytefx.snk")]
|
||||
//[assembly: AssemblyKeyName("")]
|
||||
@@ -10,7 +10,6 @@
|
||||
./Common/SqlCommandTextEditor.cs
|
||||
./Common/StringUtility.cs
|
||||
./Common/Version.cs
|
||||
./Common/MultiHostStream.cs
|
||||
./mysqlclient/CharSetMap.cs
|
||||
./mysqlclient/CommandBuilder.cs
|
||||
./mysqlclient/command.cs
|
||||
|
||||
@@ -1,39 +1,3 @@
|
||||
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)
|
||||
|
||||
|
||||
@@ -119,10 +119,7 @@ namespace ByteFX.Data.Common
|
||||
!persistSecurityInfo) continue;
|
||||
str.AppendFormat("{0}={1};", key, keyValues[key]);
|
||||
}
|
||||
|
||||
if (str.Length > 0)
|
||||
str.Remove( str.Length-1, 1 );
|
||||
|
||||
str.Remove( str.Length-1, 1 );
|
||||
return str.ToString();
|
||||
}
|
||||
|
||||
@@ -141,7 +138,6 @@ namespace ByteFX.Data.Common
|
||||
case "username":
|
||||
case "user id":
|
||||
case "user name":
|
||||
case "userid":
|
||||
username = value;
|
||||
break;
|
||||
|
||||
@@ -220,8 +216,6 @@ namespace ByteFX.Data.Common
|
||||
}
|
||||
}
|
||||
|
||||
keyValues.Clear();
|
||||
|
||||
// now we run through our normalized key-values, splitting on equals
|
||||
for (int y=0; y < x; y++)
|
||||
{
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace ByteFX.Data.Common
|
||||
/// <summary>
|
||||
/// Summary description for DBParametersEditor.
|
||||
/// </summary>
|
||||
internal class DBParametersEditor : CollectionEditor
|
||||
public class DBParametersEditor : CollectionEditor
|
||||
{
|
||||
public DBParametersEditor(Type t) : base(t)
|
||||
{
|
||||
|
||||
@@ -1,194 +0,0 @@
|
||||
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 );
|
||||
}
|
||||
|
||||
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 DataAvailable
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
private void ProcessHosts( string hostList, int port, int connectTimeOut )
|
||||
{
|
||||
int startTime = Environment.TickCount;
|
||||
|
||||
int toTicks = connectTimeOut * 1000;
|
||||
//
|
||||
// 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(1);
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
}
|
||||
Thread.Sleep(1);
|
||||
}
|
||||
|
||||
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 );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,7 @@ namespace ByteFX.Data.Common
|
||||
/// <summary>
|
||||
/// Summary description for API.
|
||||
/// </summary>
|
||||
internal class NamedPipeStream : Stream
|
||||
public class NamedPipeStream : Stream
|
||||
{
|
||||
[DllImport("kernel32.dll", EntryPoint="CreateFile", SetLastError=true)]
|
||||
private static extern IntPtr CreateFile(String lpFileName,
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace ByteFX.Data.Common
|
||||
/// <summary>
|
||||
/// Summary description for Security.
|
||||
/// </summary>
|
||||
internal class Security
|
||||
public class Security
|
||||
{
|
||||
public Security()
|
||||
{
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace ByteFX.Data.Common
|
||||
/// <summary>
|
||||
/// Summary description for MySqlConnectionDesign.
|
||||
/// </summary>
|
||||
internal class SqlCommandTextEditor : UITypeEditor
|
||||
public class SqlCommandTextEditor : UITypeEditor
|
||||
{
|
||||
public override System.Drawing.Design.UITypeEditorEditStyle GetEditStyle(System.ComponentModel.ITypeDescriptorContext context)
|
||||
{
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace ByteFX.Data.Common
|
||||
/// <summary>
|
||||
/// Summary description for Version.
|
||||
/// </summary>
|
||||
internal struct Version
|
||||
public struct Version
|
||||
{
|
||||
private int major;
|
||||
private int minor;
|
||||
|
||||
@@ -23,9 +23,8 @@ using System.Text;
|
||||
namespace ByteFX.Data.MySqlClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Automatically generates single-table commands used to reconcile changes made to a DataSet with the associated MySQL database. This class cannot be inherited.
|
||||
/// Summary description for CommandBuilder.
|
||||
/// </summary>
|
||||
/// <include file='docs/MySqlCommandBuilder.xml' path='MyDocs/MyMembers[@name="Class"]/*'/>
|
||||
[ToolboxItem(false)]
|
||||
[System.ComponentModel.DesignerCategory("Code")]
|
||||
public sealed class MySqlCommandBuilder : Component
|
||||
@@ -41,16 +40,10 @@ namespace ByteFX.Data.MySqlClient
|
||||
private MySqlCommand _deleteCmd;
|
||||
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// Overloaded. Initializes a new instance of the SqlCommandBuilder class.
|
||||
/// </summary>
|
||||
public MySqlCommandBuilder()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overloaded. Initializes a new instance of the SqlCommandBuilder class.
|
||||
/// </summary>
|
||||
public MySqlCommandBuilder( MySqlDataAdapter adapter )
|
||||
{
|
||||
_adapter = adapter;
|
||||
@@ -97,12 +90,6 @@ namespace ByteFX.Data.MySqlClient
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
/// <summary>
|
||||
/// Retrieves parameter information from the stored procedure specified in the MySqlCommand and populates the Parameters collection of the specified MySqlCommand object.
|
||||
/// This method is not currently supported since stored procedures are not available in MySql.
|
||||
/// </summary>
|
||||
/// <param name="command">The MySqlCommand referencing the stored procedure from which the parameter information is to be derived. The derived parameters are added to the Parameters collection of the MySqlCommand.</param>
|
||||
/// <exception cref="InvalidOperationException">The command text is not a valid stored procedure name.</exception>
|
||||
public static void DeriveParameters(MySqlCommand command)
|
||||
{
|
||||
throw new MySqlException("DeriveParameters is not supported (due to MySql not supporting SP)");
|
||||
|
||||
@@ -37,12 +37,9 @@ namespace ByteFX.Data.MySqlClient
|
||||
internal ConnectionState state;
|
||||
private MySqlInternalConnection internalConnection;
|
||||
private MySqlDataReader dataReader;
|
||||
private NumberFormatInfo numberFormat;
|
||||
private MySqlConnectionString settings;
|
||||
private NumberFormatInfo numberFormat;
|
||||
private MySqlConnectionString settings;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when the state of the connection changes.
|
||||
/// </summary>
|
||||
public event StateChangeEventHandler StateChange;
|
||||
|
||||
|
||||
@@ -152,17 +149,17 @@ namespace ByteFX.Data.MySqlClient
|
||||
[Browsable(false)]
|
||||
public string ServerVersion
|
||||
{
|
||||
get { return internalConnection.Driver.Version; }
|
||||
get { return ""; } //internalConnection.GetServerVersion(); }
|
||||
}
|
||||
|
||||
internal Encoding Encoding
|
||||
{
|
||||
get
|
||||
{
|
||||
if (internalConnection == null)
|
||||
//TODO if (encoding == null)
|
||||
return System.Text.Encoding.Default;
|
||||
else
|
||||
return internalConnection.Driver.Encoding;
|
||||
// else
|
||||
// return encoding;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,7 +167,6 @@ namespace ByteFX.Data.MySqlClient
|
||||
/// <summary>
|
||||
/// Gets or sets the string used to connect to a MySQL Server database.
|
||||
/// </summary>
|
||||
/// <include file='docs/MySqlConnection.xml' path='MyDocs/MyMembers[@name="ConnectionString"]/*'/>
|
||||
#if WINDOWS
|
||||
[Editor(typeof(Designers.ConnectionStringEditor), typeof(System.Drawing.Design.UITypeEditor))]
|
||||
#endif
|
||||
@@ -344,11 +340,7 @@ namespace ByteFX.Data.MySqlClient
|
||||
}
|
||||
|
||||
#region ICloneable
|
||||
/// <summary>
|
||||
/// Creates a new MySqlConnection object with the exact same ConnectionString value
|
||||
/// </summary>
|
||||
/// <returns>A cloned MySqlConnection object</returns>
|
||||
object ICloneable.Clone()
|
||||
public object Clone()
|
||||
{
|
||||
MySqlConnection clone = new MySqlConnection();
|
||||
clone.ConnectionString = this.ConnectionString;
|
||||
|
||||
@@ -40,13 +40,12 @@ namespace ByteFX.Data.MySqlClient
|
||||
Packet packet;
|
||||
try
|
||||
{
|
||||
byte[] bytes = driver.Encoding.GetBytes("show status like 'uptime'");
|
||||
packet = driver.SendSql( bytes );
|
||||
packet = driver.SendSql( "show status like 'uptime'" );
|
||||
// we have to read for two last packets since MySql sends
|
||||
// us a last packet after schema and again after rows
|
||||
// I will likely change this later to have the driver just
|
||||
// return schema in one very large packet.
|
||||
while (! packet.IsLastPacket())
|
||||
while (packet.Type != PacketType.Last)
|
||||
packet = driver.ReadPacket();
|
||||
}
|
||||
catch
|
||||
@@ -75,13 +74,10 @@ namespace ByteFX.Data.MySqlClient
|
||||
if (serverVariablesSet) return;
|
||||
|
||||
// retrieve the encoding that should be used for character data
|
||||
MySqlCommand cmd = new MySqlCommand("show variables like 'max_allowed_packet'", connection);
|
||||
MySqlCommand cmd = new MySqlCommand("select @@max_allowed_packet", connection);
|
||||
try
|
||||
{
|
||||
MySqlDataReader reader = cmd.ExecuteReader();
|
||||
reader.Read();
|
||||
driver.MaxPacketSize = reader.GetInt64( 1 );
|
||||
reader.Close();
|
||||
driver.MaxPacketSize = Convert.ToInt64(cmd.ExecuteScalar());
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -98,10 +94,7 @@ namespace ByteFX.Data.MySqlClient
|
||||
driver.Encoding = CharSetMap.GetEncoding( reader.GetString(1) );
|
||||
reader.Close();
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw new MySqlException("Failure to initialize connection");
|
||||
}
|
||||
catch { }
|
||||
|
||||
serverVariablesSet = true;
|
||||
}
|
||||
@@ -109,7 +102,8 @@ namespace ByteFX.Data.MySqlClient
|
||||
public void Open()
|
||||
{
|
||||
driver = new Driver();
|
||||
driver.Open( settings );
|
||||
driver.Open( settings.Host, settings.Port, settings.Username, settings.Password,
|
||||
settings.UseCompression, settings.ConnectTimeout );
|
||||
|
||||
createTime = DateTime.Now;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace ByteFX.Data.MySqlClient
|
||||
/// </summary>
|
||||
internal sealed class MySqlConnectionString : DBConnectionString
|
||||
{
|
||||
private bool useCompression = false;
|
||||
private bool useCompression;
|
||||
|
||||
public MySqlConnectionString()
|
||||
{
|
||||
|
||||
@@ -37,11 +37,11 @@ namespace ByteFX.Data.MySqlClient
|
||||
protected MySqlStream stream;
|
||||
protected Encoding encoding;
|
||||
protected byte packetSeq;
|
||||
protected int timeOut;
|
||||
protected long maxPacketSize;
|
||||
protected Packet peekedPacket = null;
|
||||
protected ByteFX.Data.Common.Version serverVersion;
|
||||
protected bool isOpen;
|
||||
protected string versionString;
|
||||
|
||||
int protocol;
|
||||
uint threadID;
|
||||
@@ -69,33 +69,41 @@ namespace ByteFX.Data.MySqlClient
|
||||
set { maxPacketSize = value; }
|
||||
}
|
||||
|
||||
public string Version
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="host"></param>
|
||||
/// <param name="port"></param>
|
||||
/// <param name="userid"></param>
|
||||
/// <param name="password"></param>
|
||||
public void Open( String host, int port, String userid, String password,
|
||||
bool UseCompression, int connectTimeout )
|
||||
{
|
||||
get { return versionString; }
|
||||
}
|
||||
|
||||
public void Open( MySqlConnectionString settings )
|
||||
{
|
||||
stream = new MySqlStream( settings.Host, settings.Port, 30, settings.ConnectTimeout );
|
||||
timeOut = connectTimeout;
|
||||
stream = new MySqlStream( host, port, timeOut );
|
||||
|
||||
Packet packet = ReadPacket();
|
||||
|
||||
// read off the protocol version
|
||||
protocol = packet.ReadByte();
|
||||
versionString = packet.ReadString();
|
||||
serverVersion = ByteFX.Data.Common.Version.Parse( versionString );
|
||||
serverVersion = ByteFX.Data.Common.Version.Parse( packet.ReadString() );
|
||||
threadID = (uint)packet.ReadInteger(4);
|
||||
encryptionSeed = packet.ReadString();
|
||||
|
||||
// read in Server capabilities if they are provided
|
||||
serverCaps = 0;
|
||||
if (packet.HasMoreData)
|
||||
if (packet.CanRead)
|
||||
serverCaps = (int)packet.ReadInteger(2);
|
||||
|
||||
Authenticate( settings.Username, settings.Password, settings.UseCompression );
|
||||
Authenticate( userid, password, UseCompression );
|
||||
isOpen = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="userid"></param>
|
||||
/// <param name="password"></param>
|
||||
private void Authenticate( String userid, String password, bool UseCompression )
|
||||
{
|
||||
ClientParam clientParam = ClientParam.CLIENT_FOUND_ROWS | ClientParam.CLIENT_LONG_FLAG;
|
||||
@@ -148,8 +156,7 @@ namespace ByteFX.Data.MySqlClient
|
||||
/// <summary>
|
||||
/// AuthenticateSecurity implements the new 4.1 authentication scheme
|
||||
/// </summary>
|
||||
/// <param name="packet">The in-progress packet we use to complete the authentication</param>
|
||||
/// <param name="password">The password of the user to use</param>
|
||||
/// <param name="password"></param>
|
||||
private void AuthenticateSecurely( Packet packet, string password )
|
||||
{
|
||||
packet.WriteString("xxxxxxxx", encoding );
|
||||
@@ -162,7 +169,7 @@ namespace ByteFX.Data.MySqlClient
|
||||
SHA1 sha = new SHA1CryptoServiceProvider();
|
||||
byte[] firstPassBytes = sha.ComputeHash( System.Text.Encoding.Default.GetBytes(newPass));
|
||||
|
||||
byte[] salt = packet.GetBuffer();
|
||||
byte[] salt = packet.GetBytes();
|
||||
byte[] input = new byte[ firstPassBytes.Length + 4 ];
|
||||
salt.CopyTo( input, 0 );
|
||||
firstPassBytes.CopyTo( input, 4 );
|
||||
@@ -176,10 +183,11 @@ namespace ByteFX.Data.MySqlClient
|
||||
|
||||
// send the packet
|
||||
packet = new Packet();
|
||||
packet.Write( firstPassBytes, 0, 20 );
|
||||
packet.WriteBytes( firstPassBytes, 0, 20 );
|
||||
SendPacket(packet);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
@@ -264,18 +272,38 @@ namespace ByteFX.Data.MySqlClient
|
||||
|
||||
Packet packet = ReadRawPacket();
|
||||
|
||||
// if this is an error packet, then throw the exception
|
||||
if (packet[0] == 0xff)
|
||||
if (packet.Type == PacketType.Error)
|
||||
{
|
||||
packet.ReadByte();
|
||||
int errorCode = (int)packet.ReadInteger(2);
|
||||
string msg = packet.ReadString();
|
||||
throw new MySqlException( msg, errorCode );
|
||||
}
|
||||
else if (packet.Type != PacketType.UpdateOrOk)
|
||||
packet.Position = 0;
|
||||
|
||||
return packet;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="packet"></param>
|
||||
private Packet LoadSchemaIntoPacket( Packet packet, int count )
|
||||
{
|
||||
for (int i=0; i < count; i++)
|
||||
{
|
||||
Packet colPacket = ReadRawPacket();
|
||||
packet.AppendPacket( colPacket );
|
||||
}
|
||||
Packet lastPacket = ReadRawPacket();
|
||||
if (lastPacket.Type != PacketType.Last)
|
||||
throw new MySqlException("Last packet not received when expected");
|
||||
|
||||
packet.Type = PacketType.ResultSchema;
|
||||
packet.Position = 0;
|
||||
return packet;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
@@ -310,7 +338,7 @@ namespace ByteFX.Data.MySqlClient
|
||||
|
||||
byte[] compressed_buffer = new byte[packet.Length * 2];
|
||||
Deflater deflater = new Deflater();
|
||||
deflater.SetInput( packet.GetBuffer(), 0, packet.Length );
|
||||
deflater.SetInput( packet.GetBytes(), 0, packet.Length );
|
||||
deflater.Finish();
|
||||
int comp_len = deflater.Deflate( compressed_buffer, 0, compressed_buffer.Length );
|
||||
if (comp_len > packet.Length) return null;
|
||||
@@ -340,7 +368,7 @@ namespace ByteFX.Data.MySqlClient
|
||||
header.WriteInteger( packet.Length + HEADER_LEN, 3 );
|
||||
header.WriteByte( packetSeq );
|
||||
header.WriteInteger( 0, 3 );
|
||||
buffer = packet.GetBuffer();
|
||||
buffer = packet.GetBytes();
|
||||
}
|
||||
// now write the internal header
|
||||
header.WriteInteger( packet.Length, 3 );
|
||||
@@ -348,14 +376,16 @@ namespace ByteFX.Data.MySqlClient
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer = packet.GetBytes( packetSeq );
|
||||
header = new Packet();
|
||||
header.WriteInteger( packet.Length, 3 );
|
||||
header.WriteByte( packetSeq );
|
||||
buffer = packet.GetBytes();
|
||||
}
|
||||
packetSeq++;
|
||||
|
||||
// send the data to eth server
|
||||
int start = 0;
|
||||
if (! useCompression) start = 3;
|
||||
stream.Write( buffer, start, packet.Length - start );
|
||||
stream.Write( header.GetBytes(), 0, header.Length );
|
||||
stream.Write( buffer, 0, buffer.Length );
|
||||
stream.Flush();
|
||||
}
|
||||
|
||||
@@ -382,7 +412,7 @@ namespace ByteFX.Data.MySqlClient
|
||||
SendPacket(packet);
|
||||
|
||||
packet = ReadPacket();
|
||||
if (packet[0] != 0)
|
||||
if (packet.Type != PacketType.UpdateOrOk)
|
||||
throw new MySqlException("SendCommand failed for command " + text );
|
||||
}
|
||||
|
||||
@@ -393,28 +423,42 @@ namespace ByteFX.Data.MySqlClient
|
||||
/// <returns>A packet containing the bytes returned by the server</returns>
|
||||
public Packet SendQuery( byte[] sql )
|
||||
{
|
||||
string s = encoding.GetString(sql);
|
||||
|
||||
Packet packet = new Packet();
|
||||
packetSeq = 0;
|
||||
packet.WriteByte( (byte)DBCmd.QUERY );
|
||||
packet.Write( sql, 0, sql.Length );
|
||||
packet.WriteBytes( sql, 0, sql.Length );
|
||||
|
||||
SendPacket( packet );
|
||||
return ReadPacket();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Packet SendSql( byte[] bytes )
|
||||
public Packet SendSql( string sql )
|
||||
{
|
||||
byte[] bytes = encoding.GetBytes(sql);
|
||||
|
||||
Packet packet = new Packet();
|
||||
packetSeq = 0;
|
||||
packet.WriteByte( (byte)DBCmd.QUERY );
|
||||
packet.Write( bytes, 0, bytes.Length );
|
||||
packet.WriteBytes( bytes, 0, bytes.Length );
|
||||
|
||||
SendPacket( packet );
|
||||
packet = ReadPacket();
|
||||
|
||||
switch (packet.Type)
|
||||
{
|
||||
case PacketType.LoadDataLocal:
|
||||
SendFileToServer();
|
||||
return null;
|
||||
|
||||
case PacketType.Other:
|
||||
packet.Position = 0;
|
||||
int count = (int)packet.ReadLenInteger();
|
||||
if (count > 0)
|
||||
return LoadSchemaIntoPacket( packet, count );
|
||||
else
|
||||
return packet;
|
||||
}
|
||||
|
||||
return packet;
|
||||
}
|
||||
|
||||
@@ -428,11 +472,10 @@ namespace ByteFX.Data.MySqlClient
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Encrypts a password using the MySql encryption scheme
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="password">The password to encrypt</param>
|
||||
/// <param name="message">The encryption seed the server gave us</param>
|
||||
/// <param name="new_ver">Indicates if we should use the old or new encryption scheme</param>
|
||||
/// <param name="password"></param>
|
||||
/// <param name="seed"></param>
|
||||
/// <returns></returns>
|
||||
public static String EncryptPassword(String password, String message, bool new_ver)
|
||||
{
|
||||
|
||||
@@ -21,30 +21,25 @@ using System.Runtime.Serialization;
|
||||
namespace ByteFX.Data.MySqlClient
|
||||
{
|
||||
/// <summary>
|
||||
/// The exception that is thrown when MySQL returns an error. This class cannot be inherited.
|
||||
/// Summary description for MySqlException.
|
||||
/// </summary>
|
||||
/// <include file='docs/MySqlException.xml' path='MyDocs/MyMembers[@name="Class"]/*'/>
|
||||
[Serializable]
|
||||
public sealed class MySqlException : SystemException
|
||||
public sealed class MySqlException : Exception
|
||||
{
|
||||
internal MySqlException(string msg) : base(msg)
|
||||
{
|
||||
}
|
||||
|
||||
internal MySqlException( string msg, Exception ex ) : base(msg, ex)
|
||||
public MySqlException(string msg) : base(msg)
|
||||
{
|
||||
}
|
||||
|
||||
internal MySqlException()
|
||||
public MySqlException()
|
||||
{
|
||||
}
|
||||
|
||||
internal MySqlException(string msg, int errno) : base(msg)
|
||||
public MySqlException(string msg, int errno) : base(msg)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
internal MySqlException(SerializationInfo info,
|
||||
public MySqlException(SerializationInfo info,
|
||||
StreamingContext context) : base(info, context)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -81,14 +81,14 @@ namespace ByteFX.Data.MySqlClient
|
||||
public int NumericPrecision()
|
||||
{
|
||||
if (colType == MySqlDbType.Decimal)
|
||||
return colLen;
|
||||
return ((SqlDecimal)value).Precision;
|
||||
return -1;
|
||||
}
|
||||
|
||||
public int NumericScale()
|
||||
{
|
||||
if (colType == MySqlDbType.Decimal)
|
||||
return colDecimals;
|
||||
return ((SqlDecimal)value).Scale;
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ namespace ByteFX.Data.MySqlClient
|
||||
|
||||
// read in the data
|
||||
byte[] data = new byte[ len ];
|
||||
p.Read( data, 0, len );
|
||||
p.ReadBytes( data, 0, len );
|
||||
|
||||
// if it is a blob and binary, then GetBytes is the way to go
|
||||
if ( IsBlob() && IsBinary() )
|
||||
@@ -172,7 +172,7 @@ namespace ByteFX.Data.MySqlClient
|
||||
value = Int16.Parse( sValue );
|
||||
break;
|
||||
|
||||
case MySqlDbType.Int :
|
||||
case MySqlDbType.Long :
|
||||
case MySqlDbType.Int24:
|
||||
if (IsUnsigned())
|
||||
value = UInt32.Parse( sValue );
|
||||
@@ -180,7 +180,7 @@ namespace ByteFX.Data.MySqlClient
|
||||
value = Int32.Parse( sValue );
|
||||
break;
|
||||
|
||||
case MySqlDbType.BigInt:
|
||||
case MySqlDbType.LongLong:
|
||||
if (IsUnsigned())
|
||||
value = UInt64.Parse( sValue );
|
||||
else
|
||||
@@ -264,12 +264,12 @@ namespace ByteFX.Data.MySqlClient
|
||||
case MySqlDbType.Decimal: return "DECIMAL";
|
||||
case MySqlDbType.Byte: return "TINY";
|
||||
case MySqlDbType.Short: return "SHORT";
|
||||
case MySqlDbType.Int: return "INTEGER";
|
||||
case MySqlDbType.Long: return "LONG";
|
||||
case MySqlDbType.Float: return "FLOAT";
|
||||
case MySqlDbType.Double: return "DOUBLE";
|
||||
case MySqlDbType.Null: return "NULL";
|
||||
case MySqlDbType.Timestamp: return "TIMESTAMP";
|
||||
case MySqlDbType.BigInt: return "BIGINT";
|
||||
case MySqlDbType.LongLong: return "LONGLONG";
|
||||
case MySqlDbType.Int24: return "INT24";
|
||||
case MySqlDbType.Date: return "DATE";
|
||||
case MySqlDbType.Time: return "TIME";
|
||||
@@ -297,10 +297,10 @@ namespace ByteFX.Data.MySqlClient
|
||||
|
||||
case MySqlDbType.Short: return IsUnsigned() ? typeof(System.UInt16) : typeof(System.Int16);
|
||||
|
||||
case MySqlDbType.Int:
|
||||
case MySqlDbType.Long:
|
||||
case MySqlDbType.Int24: return IsUnsigned() ? typeof(System.UInt32) : typeof(System.Int32);
|
||||
|
||||
case MySqlDbType.BigInt: return IsUnsigned() ? typeof(System.UInt64) : typeof(System.Int64);
|
||||
case MySqlDbType.LongLong: return IsUnsigned() ? typeof(System.UInt64) : typeof(System.Int64);
|
||||
|
||||
case MySqlDbType.Float: return typeof(System.Single);
|
||||
case MySqlDbType.Double: return typeof(System.Double);
|
||||
@@ -343,7 +343,7 @@ namespace ByteFX.Data.MySqlClient
|
||||
else
|
||||
return DbType.Int16;
|
||||
|
||||
case MySqlDbType.Int:
|
||||
case MySqlDbType.Long:
|
||||
if (IsUnsigned())
|
||||
return DbType.UInt32;
|
||||
else
|
||||
@@ -353,7 +353,7 @@ namespace ByteFX.Data.MySqlClient
|
||||
case MySqlDbType.Double: return DbType.Double;
|
||||
case MySqlDbType.Null: return DbType.Object;
|
||||
|
||||
case MySqlDbType.BigInt:
|
||||
case MySqlDbType.LongLong:
|
||||
if (IsUnsigned())
|
||||
return DbType.UInt64;
|
||||
else
|
||||
|
||||
@@ -5,7 +5,7 @@ using ByteFX.Data.MySqlClient;
|
||||
namespace ByteFX.Data.MySqlClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Helper class that makes it easier to work with the provider.
|
||||
/// Summary description for MySqlHelper.
|
||||
/// </summary>
|
||||
public sealed class MySqlHelper
|
||||
{
|
||||
@@ -15,15 +15,6 @@ namespace ByteFX.Data.MySqlClient
|
||||
}
|
||||
|
||||
#region ExecuteNonQuery
|
||||
|
||||
/// <summary>
|
||||
/// Executes a single command against a MySQL database. The <see cref="MySqlConnection"/> is assumed to be
|
||||
/// open when the method is called and remains open after the method completes.
|
||||
/// </summary>
|
||||
/// <param name="connection"><see cref="MySqlConnection"/> object to use</param>
|
||||
/// <param name="commandText">SQL command to be executed</param>
|
||||
/// <param name="commandParameters">Array of <see cref="MySqlParameter"/> objects to use with the command.</param>
|
||||
/// <returns></returns>
|
||||
public static int ExecuteNonQuery( MySqlConnection connection, string commandText, params MySqlParameter[] commandParameters )
|
||||
{
|
||||
//create a command and prepare it for execution
|
||||
@@ -42,14 +33,6 @@ namespace ByteFX.Data.MySqlClient
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes a single command against a MySQL database. A new <see cref="MySqlConnection"/> is created
|
||||
/// using the <see cref="MySqlConnection.ConnectionString"/> given.
|
||||
/// </summary>
|
||||
/// <param name="connectionString"><see cref="MySqlConnection.ConnectionString"/> to use</param>
|
||||
/// <param name="commandText">SQL command to be executed</param>
|
||||
/// <param name="parms">Array of <see cref="MySqlParameter"/> objects to use with the command.</param>
|
||||
/// <returns></returns>
|
||||
public static int ExecuteNonQuery( string connectionString, string commandText, params MySqlParameter[] parms )
|
||||
{
|
||||
//create & open a SqlConnection, and dispose of it after we are done.
|
||||
@@ -64,15 +47,6 @@ namespace ByteFX.Data.MySqlClient
|
||||
#endregion
|
||||
|
||||
#region ExecuteDataSet
|
||||
|
||||
/// <summary>
|
||||
/// Executes a single SQL command and returns the first row of the resultset. A new MySqlConnection object
|
||||
/// is created, opened, and closed during this method.
|
||||
/// </summary>
|
||||
/// <param name="connectionString">Settings to be used for the connection</param>
|
||||
/// <param name="commandText">Command to execute</param>
|
||||
/// <param name="parms">Parameters to use for the command</param>
|
||||
/// <returns>DataRow containing the first row of the resultset</returns>
|
||||
public static DataRow ExecuteDatarow( string connectionString, string commandText, params MySqlParameter[] parms )
|
||||
{
|
||||
DataSet ds = ExecuteDataset( connectionString, commandText, parms );
|
||||
@@ -82,27 +56,12 @@ namespace ByteFX.Data.MySqlClient
|
||||
return ds.Tables[0].Rows[0];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes a single SQL command and returns the resultset in a <see cref="DataSet"/>.
|
||||
/// A new MySqlConnection object is created, opened, and closed during this method.
|
||||
/// </summary>
|
||||
/// <param name="connectionString">Settings to be used for the connection</param>
|
||||
/// <param name="commandText">Command to execute</param>
|
||||
/// <returns><see cref="DataSet"/> containing the resultset</returns>
|
||||
public static DataSet ExecuteDataset(string connectionString, string commandText)
|
||||
{
|
||||
//pass through the call providing null for the set of SqlParameters
|
||||
return ExecuteDataset(connectionString, commandText, (MySqlParameter[])null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes a single SQL command and returns the resultset in a <see cref="DataSet"/>.
|
||||
/// A new MySqlConnection object is created, opened, and closed during this method.
|
||||
/// </summary>
|
||||
/// <param name="connectionString">Settings to be used for the connection</param>
|
||||
/// <param name="commandText">Command to execute</param>
|
||||
/// <param name="commandParameters">Parameters to use for the command</param>
|
||||
/// <returns><see cref="DataSet"/> containing the resultset</returns>
|
||||
public static DataSet ExecuteDataset(string connectionString, string commandText, params MySqlParameter[] commandParameters)
|
||||
{
|
||||
//create & open a SqlConnection, and dispose of it after we are done.
|
||||
@@ -115,29 +74,13 @@ namespace ByteFX.Data.MySqlClient
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes a single SQL command and returns the resultset in a <see cref="DataSet"/>.
|
||||
/// The state of the <see cref="MySqlConnection"/> object remains unchanged after execution
|
||||
/// of this method.
|
||||
/// </summary>
|
||||
/// <param name="connection"><see cref="MySqlConnection"/> object to use</param>
|
||||
/// <param name="commandText">Command to execute</param>
|
||||
/// <returns><see cref="DataSet"/> containing the resultset</returns>
|
||||
public static DataSet ExecuteDataset(MySqlConnection connection, string commandText)
|
||||
{
|
||||
//pass through the call providing null for the set of SqlParameters
|
||||
return ExecuteDataset(connection, commandText, (MySqlParameter[])null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes a single SQL command and returns the resultset in a <see cref="DataSet"/>.
|
||||
/// The state of the <see cref="MySqlConnection"/> object remains unchanged after execution
|
||||
/// of this method.
|
||||
/// </summary>
|
||||
/// <param name="connection"><see cref="MySqlConnection"/> object to use</param>
|
||||
/// <param name="commandText">Command to execute</param>
|
||||
/// <param name="commandParameters">Parameters to use for the command</param>
|
||||
/// <returns><see cref="DataSet"/> containing the resultset</returns>
|
||||
|
||||
public static DataSet ExecuteDataset(MySqlConnection connection, string commandText, params MySqlParameter[] commandParameters)
|
||||
{
|
||||
//create a command and prepare it for execution
|
||||
@@ -164,13 +107,6 @@ namespace ByteFX.Data.MySqlClient
|
||||
return ds;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the given table with data from the given <see cref="DataSet"/>
|
||||
/// </summary>
|
||||
/// <param name="connectionString">Settings to use for the update</param>
|
||||
/// <param name="commandText">Command text to use for the update</param>
|
||||
/// <param name="ds"><see cref="DataSet"/> containing the new data to use in the update</param>
|
||||
/// <param name="tablename">Tablename in the dataset to update</param>
|
||||
public static void UpdateDataSet( string connectionString, string commandText, DataSet ds, string tablename )
|
||||
{
|
||||
MySqlConnection cn = new MySqlConnection( connectionString );
|
||||
@@ -184,16 +120,6 @@ namespace ByteFX.Data.MySqlClient
|
||||
#endregion
|
||||
|
||||
#region ExecuteDataReader
|
||||
|
||||
/// <summary>
|
||||
/// Executes a single command against a MySQL database, possibly inside an existing transaction.
|
||||
/// </summary>
|
||||
/// <param name="connection"><see cref="MySqlConnection"/> object to use for the command</param>
|
||||
/// <param name="transaction"><see cref="MySqlTransaction"/> object to use for the command</param>
|
||||
/// <param name="commandText">Command text to use</param>
|
||||
/// <param name="commandParameters">Array of <see cref="MySqlParameter"/> objects to use with the command</param>
|
||||
/// <param name="ExternalConn">True if the connection should be preserved, false if not</param>
|
||||
/// <returns><see cref="MySqlDataReader"/> object ready to read the results of the command</returns>
|
||||
private static MySqlDataReader ExecuteReader(MySqlConnection connection, MySqlTransaction transaction, string commandText, MySqlParameter[] commandParameters, bool ExternalConn )
|
||||
{
|
||||
//create a command and prepare it for execution
|
||||
@@ -226,25 +152,12 @@ namespace ByteFX.Data.MySqlClient
|
||||
return dr;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes a single command against a MySQL database.
|
||||
/// </summary>
|
||||
/// <param name="connectionString">Settings to use for this command</param>
|
||||
/// <param name="commandText">Command text to use</param>
|
||||
/// <returns><see cref="MySqlDataReader"/> object ready to read the results of the command</returns>
|
||||
public static MySqlDataReader ExecuteReader(string connectionString, string commandText)
|
||||
{
|
||||
//pass through the call providing null for the set of SqlParameters
|
||||
return ExecuteReader(connectionString, commandText, (MySqlParameter[])null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes a single command against a MySQL database.
|
||||
/// </summary>
|
||||
/// <param name="connectionString">Settings to use for this command</param>
|
||||
/// <param name="commandText">Command text to use</param>
|
||||
/// <param name="commandParameters">Array of <see cref="MySqlParameter"/> objects to use with the command</param>
|
||||
/// <returns><see cref="MySqlDataReader"/> object ready to read the results of the command</returns>
|
||||
public static MySqlDataReader ExecuteReader(string connectionString, string commandText, params MySqlParameter[] commandParameters)
|
||||
{
|
||||
//create & open a SqlConnection
|
||||
@@ -266,26 +179,12 @@ namespace ByteFX.Data.MySqlClient
|
||||
#endregion
|
||||
|
||||
#region ExecuteScalar
|
||||
|
||||
/// <summary>
|
||||
/// Execute a single command against a MySQL database.
|
||||
/// </summary>
|
||||
/// <param name="connectionString">Settings to use for the update</param>
|
||||
/// <param name="commandText">Command text to use for the update</param>
|
||||
/// <returns>The first column of the first row in the result set, or a null reference if the result set is empty.</returns>
|
||||
public static object ExecuteScalar(string connectionString, string commandText)
|
||||
{
|
||||
//pass through the call providing null for the set of MySqlParameters
|
||||
return ExecuteScalar(connectionString, commandText, (MySqlParameter[])null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Execute a single command against a MySQL database.
|
||||
/// </summary>
|
||||
/// <param name="connectionString">Settings to use for the command</param>
|
||||
/// <param name="commandText">Command text to use for the command</param>
|
||||
/// <param name="commandParameters">Parameters to use for the command</param>
|
||||
/// <returns>The first column of the first row in the result set, or a null reference if the result set is empty.</returns>
|
||||
public static object ExecuteScalar(string connectionString, string commandText, params MySqlParameter[] commandParameters)
|
||||
{
|
||||
//create & open a SqlConnection, and dispose of it after we are done.
|
||||
@@ -298,25 +197,12 @@ namespace ByteFX.Data.MySqlClient
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Execute a single command against a MySQL database.
|
||||
/// </summary>
|
||||
/// <param name="connection"><see cref="MySqlConnection"/> object to use</param>
|
||||
/// <param name="commandText">Command text to use for the command</param>
|
||||
/// <returns>The first column of the first row in the result set, or a null reference if the result set is empty.</returns>
|
||||
public static object ExecuteScalar(MySqlConnection connection, string commandText)
|
||||
{
|
||||
//pass through the call providing null for the set of MySqlParameters
|
||||
return ExecuteScalar(connection, commandText, (MySqlParameter[])null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Execute a single command against a MySQL database.
|
||||
/// </summary>
|
||||
/// <param name="connection"><see cref="MySqlConnection"/> object to use</param>
|
||||
/// <param name="commandText">Command text to use for the command</param>
|
||||
/// <param name="commandParameters">Parameters to use for the command</param>
|
||||
/// <returns>The first column of the first row in the result set, or a null reference if the result set is empty.</returns>
|
||||
public static object ExecuteScalar(MySqlConnection connection, string commandText, params MySqlParameter[] commandParameters)
|
||||
{
|
||||
//create a command and prepare it for execution
|
||||
|
||||
@@ -9,43 +9,26 @@ namespace ByteFX.Data.MySqlClient
|
||||
/// </summary>
|
||||
internal sealed class MySqlPool
|
||||
{
|
||||
private ArrayList inUsePool;
|
||||
private ArrayList idlePool;
|
||||
private MySqlConnectionString settings;
|
||||
private int minSize;
|
||||
private int maxSize;
|
||||
private ArrayList inUsePool;
|
||||
private ArrayList idlePool;
|
||||
private int minSize;
|
||||
private int maxSize;
|
||||
|
||||
public MySqlPool(MySqlConnectionString settings)
|
||||
{
|
||||
minSize = settings.MinPoolSize;
|
||||
maxSize = settings.MaxPoolSize;
|
||||
this.settings = settings;
|
||||
inUsePool =new ArrayList();
|
||||
idlePool = new ArrayList( settings.MinPoolSize );
|
||||
|
||||
// prepopulate the idle pool to minSize
|
||||
for (int i=0; i < minSize; i++)
|
||||
CreateNewPooledConnection();
|
||||
}
|
||||
|
||||
private void CheckOutConnection(MySqlInternalConnection conn)
|
||||
public MySqlPool(int minSize, int maxSize)
|
||||
{
|
||||
this.minSize = minSize;
|
||||
this.maxSize = maxSize;
|
||||
inUsePool =new ArrayList(minSize);
|
||||
idlePool = new ArrayList(minSize);
|
||||
}
|
||||
|
||||
private MySqlInternalConnection GetPooledConnection()
|
||||
{
|
||||
MySqlInternalConnection conn = null;
|
||||
|
||||
// if there are no idle connections and the in use pool is full
|
||||
// then return null to indicate that we cannot provide a connection
|
||||
// at this time.
|
||||
if (idlePool.Count == 0 && inUsePool.Count == maxSize) return null;
|
||||
|
||||
lock (idlePool.SyncRoot)
|
||||
{
|
||||
for (int i=idlePool.Count-1; i >=0; i--)
|
||||
{
|
||||
conn = (idlePool[i] as MySqlInternalConnection);
|
||||
MySqlInternalConnection conn = (idlePool[i] as MySqlInternalConnection);
|
||||
if (conn.IsAlive())
|
||||
{
|
||||
lock (inUsePool)
|
||||
@@ -62,44 +45,20 @@ namespace ByteFX.Data.MySqlClient
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if we couldn't get a pooled connection and there is still room
|
||||
// make a new one
|
||||
if (conn == null && (idlePool.Count+inUsePool.Count) < maxSize)
|
||||
{
|
||||
conn = CreateNewPooledConnection();
|
||||
if (conn == null) return null;
|
||||
|
||||
lock (idlePool.SyncRoot)
|
||||
lock (inUsePool.SyncRoot)
|
||||
{
|
||||
idlePool.Remove( conn );
|
||||
inUsePool.Add( conn );
|
||||
}
|
||||
}
|
||||
|
||||
return conn;
|
||||
return null;
|
||||
}
|
||||
|
||||
private MySqlInternalConnection CreateNewPooledConnection()
|
||||
private MySqlInternalConnection CreateNewPooledConnection( MySqlConnectionString settings )
|
||||
{
|
||||
lock(idlePool.SyncRoot)
|
||||
lock (inUsePool.SyncRoot)
|
||||
{
|
||||
// first we check if we are allowed to create another
|
||||
if ((inUsePool.Count + idlePool.Count) == maxSize) return null;
|
||||
|
||||
MySqlInternalConnection conn = new MySqlInternalConnection( settings );
|
||||
conn.Open();
|
||||
idlePool.Add( conn );
|
||||
return conn;
|
||||
}
|
||||
MySqlInternalConnection conn = new MySqlInternalConnection( settings );
|
||||
conn.Open();
|
||||
return conn;
|
||||
}
|
||||
|
||||
public void ReleaseConnection( MySqlInternalConnection connection )
|
||||
{
|
||||
lock (idlePool.SyncRoot)
|
||||
lock (inUsePool.SyncRoot)
|
||||
lock (inUsePool.SyncRoot)
|
||||
lock (idlePool.SyncRoot)
|
||||
{
|
||||
inUsePool.Remove( connection );
|
||||
if (connection.Settings.ConnectionLifetime != 0 && connection.IsTooOld())
|
||||
@@ -109,16 +68,20 @@ namespace ByteFX.Data.MySqlClient
|
||||
}
|
||||
}
|
||||
|
||||
public MySqlInternalConnection GetConnection()
|
||||
public MySqlInternalConnection GetConnection(MySqlConnectionString settings)
|
||||
{
|
||||
MySqlInternalConnection conn = null;
|
||||
MySqlInternalConnection conn;
|
||||
|
||||
int start = Environment.TickCount;
|
||||
int ticks = settings.ConnectTimeout * 1000;
|
||||
|
||||
// wait timeOut seconds at most to get a connection
|
||||
while (conn == null && (Environment.TickCount - start) < ticks)
|
||||
DateTime start = DateTime.Now;
|
||||
TimeSpan ts;
|
||||
do
|
||||
{
|
||||
conn = GetPooledConnection();
|
||||
if (conn == null)
|
||||
conn = CreateNewPooledConnection( settings );
|
||||
ts = DateTime.Now.Subtract( start );
|
||||
} while (conn == null && ts.Seconds < settings.ConnectTimeout );
|
||||
|
||||
|
||||
// if pool size is at maximum, then we must have reached our timeout so we simply
|
||||
// throw our exception
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace ByteFX.Data.MySqlClient
|
||||
MySqlPool pool;
|
||||
if (!pools.Contains( text ))
|
||||
{
|
||||
pool = new MySqlPool( settings );
|
||||
pool = new MySqlPool( settings.MinPoolSize, settings.MaxPoolSize );
|
||||
pools.Add( text, pool );
|
||||
}
|
||||
else
|
||||
@@ -44,7 +44,7 @@ namespace ByteFX.Data.MySqlClient
|
||||
pool = (pools[text] as MySqlPool);
|
||||
}
|
||||
|
||||
return pool.GetConnection();
|
||||
return pool.GetConnection( settings );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,89 +20,50 @@ using System.IO;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using ByteFX.Data.Common;
|
||||
using System.Threading;
|
||||
|
||||
namespace ByteFX.Data.MySqlClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for API.
|
||||
/// </summary>
|
||||
internal class MySqlStream : MultiHostStream
|
||||
internal class MySqlStream : Stream
|
||||
{
|
||||
public MySqlStream( string hostList, int port, int readTimeOut, int connectTimeOut ) :
|
||||
base( hostList, port, readTimeOut, connectTimeOut )
|
||||
Stream stream;
|
||||
Socket socket;
|
||||
int timeOut;
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
protected override void Error(string msg)
|
||||
{
|
||||
throw new MySqlException( msg, baseException );
|
||||
}
|
||||
|
||||
protected override void TimeOut(MultiHostStreamErrorType error)
|
||||
{
|
||||
switch (error)
|
||||
{
|
||||
case MultiHostStreamErrorType.Connecting:
|
||||
throw new MySqlException("Timed out creating a new MySqlConnection");
|
||||
case MultiHostStreamErrorType.Reading:
|
||||
throw new MySqlException("Timed out reading from MySql");
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool CreateStream( IPAddress ip, string hostname, int port )
|
||||
public MySqlStream( string host, int port, int timeout )
|
||||
{
|
||||
if (port == -1)
|
||||
return CreatePipeStream(ip, hostname);
|
||||
Create( host );
|
||||
else
|
||||
return CreateSocketStream(ip, port);
|
||||
Create( host, port );
|
||||
timeOut = timeout;
|
||||
}
|
||||
|
||||
private bool CreatePipeStream( IPAddress ip, string hostname )
|
||||
private void Create( string host, int port )
|
||||
{
|
||||
socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
||||
IPHostEntry he = Dns.GetHostByName( host );
|
||||
IPEndPoint serverAddr = new IPEndPoint(he.AddressList[0], port);
|
||||
|
||||
socket.Connect(serverAddr);
|
||||
stream = new NetworkStream(socket, true);
|
||||
}
|
||||
|
||||
private void Create( string host )
|
||||
{
|
||||
string pipeName;
|
||||
|
||||
if (hostname.ToLower().Equals("localhost"))
|
||||
if (host.ToLower().Equals("localhost"))
|
||||
pipeName = @"\\.\pipe\MySql";
|
||||
else
|
||||
pipeName = String.Format(@"\\{0}\pipe\MySql", ip.ToString());
|
||||
pipeName = String.Format(@"\\{0}\pipe\MySql", host);
|
||||
|
||||
try
|
||||
{
|
||||
stream = new NamedPipeStream(pipeName, FileAccess.ReadWrite);
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
baseException = ex;
|
||||
return false;
|
||||
}
|
||||
stream = new ByteFX.Data.Common.NamedPipeStream(pipeName, FileAccess.ReadWrite);
|
||||
}
|
||||
|
||||
private bool 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);
|
||||
socket.Connect(endPoint);
|
||||
socket.SetSocketOption( SocketOptionLevel.Tcp, SocketOptionName.NoDelay, 1 );
|
||||
stream = new NetworkStream( socket, true );
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
baseException = ex;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool DataAvailable
|
||||
public bool DataAvailable
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -110,6 +71,73 @@ namespace ByteFX.Data.MySqlClient
|
||||
return ((NetworkStream)stream).DataAvailable;
|
||||
else return (stream as NamedPipeStream).DataAvailable;
|
||||
}
|
||||
}
|
||||
|
||||
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 int ReadByte()
|
||||
{
|
||||
long start = Environment.TickCount;
|
||||
long timeout_ticks = timeOut * TimeSpan.TicksPerSecond;
|
||||
|
||||
while (((Environment.TickCount - start) < timeout_ticks))
|
||||
{
|
||||
if (DataAvailable)
|
||||
{
|
||||
int b = stream.ReadByte();
|
||||
return b;
|
||||
}
|
||||
}
|
||||
throw new Exception("Timeout waiting for response from server");
|
||||
}
|
||||
|
||||
public override int Read(byte[] buffer, int offset, int count)
|
||||
{
|
||||
long start = Environment.TickCount;
|
||||
int numToRead = count;
|
||||
long timeout_ticks = timeOut * TimeSpan.TicksPerSecond;
|
||||
|
||||
while (numToRead > 0 && ((Environment.TickCount - start) < timeout_ticks))
|
||||
{
|
||||
if (DataAvailable)
|
||||
{
|
||||
int bytes_read = stream.Read(buffer, offset, numToRead);
|
||||
offset += bytes_read;
|
||||
numToRead -= bytes_read;
|
||||
}
|
||||
}
|
||||
if (numToRead > 0)
|
||||
throw new Exception("Timeout waiting for response from server");
|
||||
return count;
|
||||
}
|
||||
|
||||
public int ReadInt24()
|
||||
@@ -124,6 +152,20 @@ namespace ByteFX.Data.MySqlClient
|
||||
stream.Close();
|
||||
}
|
||||
|
||||
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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -69,62 +69,30 @@ namespace ByteFX.Data.MySqlClient
|
||||
CHANGE_USER = 17,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Specifies MySQL specific data type of a field, property, for use in a <see cref="MySqlParameter"/>.
|
||||
/// </summary>
|
||||
public enum MySqlDbType
|
||||
{
|
||||
/// <summary> <see cref="Decimal"/><para>A fixed precision and scale numeric value between -1038 -1 and 10 38 -1.</para></summary>
|
||||
Decimal = 0,
|
||||
/// <summary> <see cref="Byte"/><para>The signed range is -128 to 127. The unsigned range is 0 to 255.</para></summary>
|
||||
Byte = 1,
|
||||
/// <summary><see cref="Int16"/><para>A 16-bit signed or unsigned integer. The signed range is -32768 to 32767. The unsigned range is 0 to 65535</para></summary>
|
||||
Decimal = 0,
|
||||
Byte = 1,
|
||||
Short = 2,
|
||||
/// <summary><see cref="Int32"/><para>A 32-bit signed or unsigned integer</para></summary>
|
||||
Int = 3,
|
||||
/// <summary><b>Obsolete</b> Please use Int for 32 bit values</summary>
|
||||
[Obsolete("Long is no longer the correct way of specifying a 32 bit value. Use Int")]
|
||||
Long = 3,
|
||||
/// <summary><see cref="Single"/><para>A small (single-precision) floating-point number. Allowable values are -3.402823466E+38 to -1.175494351E-38, 0, and 1.175494351E-38 to 3.402823466E+38.</para></summary>
|
||||
Float = 4,
|
||||
/// <summary><see cref="Double"/><para>A normal-size (double-precision) floating-point number. Allowable values are -1.7976931348623157E+308 to -2.2250738585072014E-308, 0, and 2.2250738585072014E-308 to 1.7976931348623157E+308.</para></summary>
|
||||
Double = 5,
|
||||
/// <summary>Specifies a null value</summary>
|
||||
Null = 6,
|
||||
/// <summary>A timestamp. The range is '1970-01-01 00:00:00' to sometime in the year 2037</summary>
|
||||
Timestamp = 7,
|
||||
/// <summary><see cref="Int64"/><para>A 64-bit signed or unsigned integer.</para></summary>
|
||||
BigInt = 8,
|
||||
/// <summary><b>Obsolete</b> Please use BigInt for 64 bit values</summary>
|
||||
[Obsolete("LongLong is no longer the correct way of specifying a 64 bit value. Use BigInt")]
|
||||
LongLong = 8,
|
||||
/// <summary>Specifies a 24 (3 byte) signed or unsigned value.</summary>
|
||||
Int24 = 9,
|
||||
///<summary>Date The supported range is '1000-01-01' to '9999-12-31'.</summary>
|
||||
Date = 10,
|
||||
/// <summary> Time <para>The range is '-838:59:59' to '838:59:59'.</para></summary>
|
||||
Time = 11,
|
||||
///<summary>DateTime The supported range is '1000-01-01 00:00:00' to '9999-12-31 23:59:59'.</summary>
|
||||
Datetime = 12,
|
||||
/// <summary>A year in 2- or 4-digit format (default is 4-digit). The allowable values are 1901 to 2155, 0000 in the 4-digit year format, and 1970-2069 if you use the 2-digit format (70-69)</summary>
|
||||
Datetime = 12,
|
||||
Year = 13,
|
||||
/// <summary><b>Obsolete</b> Use Datetime or Date type</summary>
|
||||
Newdate = 14,
|
||||
/// <summary>An enumeration. A string object that can have only one value, chosen from the list of values 'value1', 'value2', ..., NULL or the special "" error value. An ENUM can have a maximum of 65535 distinct values</summary>
|
||||
Enum = 247,
|
||||
/// <summary>A set. A string object that can have zero or more values, each of which must be chosen from the list of values 'value1', 'value2', ... A SET can have a maximum of 64 members.</summary>
|
||||
Set = 248,
|
||||
/// <summary>A BLOB or TEXT column with a maximum length of 255 (2^8 - 1) characters</summary>
|
||||
TinyBlob = 249,
|
||||
/// <summary>A BLOB or TEXT column with a maximum length of 16777215 (2^24 - 1) characters</summary>
|
||||
MediumBlob = 250,
|
||||
/// <summary>A BLOB or TEXT column with a maximum length of 4294967295 or 4G (2^32 - 1) characters</summary>
|
||||
LongBlob = 251,
|
||||
/// <summary>A BLOB or TEXT column with a maximum length of 65535 (2^16 - 1) characters</summary>
|
||||
Blob = 252,
|
||||
/// <summary>A variable-length string containing 0 to 255 characters</summary>
|
||||
VarChar = 253,
|
||||
/// <summary><b>Obsolete</b> Use VarChar type</summary>
|
||||
String = 254
|
||||
};
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ using System.Text;
|
||||
|
||||
namespace ByteFX.Data.MySqlClient
|
||||
{
|
||||
/* internal enum PacketType
|
||||
internal enum PacketType
|
||||
{
|
||||
None,
|
||||
UpdateOrOk,
|
||||
@@ -14,28 +14,32 @@ namespace ByteFX.Data.MySqlClient
|
||||
Error,
|
||||
LoadDataLocal,
|
||||
Other
|
||||
}*/
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Summary description for Packet.
|
||||
/// </summary>
|
||||
internal class Packet : MemoryStream
|
||||
internal class Packet
|
||||
{
|
||||
MemoryStream data;
|
||||
PacketType type = PacketType.None;
|
||||
Encoding encoding;
|
||||
private static int HEADER_LEN = 7;
|
||||
|
||||
public Packet() : base(256+HEADER_LEN)
|
||||
public Packet()
|
||||
{
|
||||
Position = HEADER_LEN;
|
||||
data = new MemoryStream();
|
||||
}
|
||||
|
||||
public Packet(int len) : base(len+HEADER_LEN)
|
||||
public Packet(int len)
|
||||
{
|
||||
Position = HEADER_LEN;
|
||||
data = new MemoryStream(len);
|
||||
}
|
||||
|
||||
public Packet(byte[] bytes) : base(bytes, 0, bytes.Length, true, true)
|
||||
public Packet(byte[] bytes)
|
||||
{
|
||||
data = new MemoryStream( bytes.Length );
|
||||
data.Write( bytes, 0, bytes.Length );
|
||||
data.Position = 0;
|
||||
}
|
||||
|
||||
public Encoding Encoding
|
||||
@@ -44,30 +48,73 @@ namespace ByteFX.Data.MySqlClient
|
||||
get { return encoding; }
|
||||
}
|
||||
|
||||
public byte this[int index]
|
||||
public int Length
|
||||
{
|
||||
get { return GetBuffer()[index]; }
|
||||
get { return (int)data.Length; }
|
||||
}
|
||||
|
||||
public new int Length
|
||||
public PacketType Type
|
||||
{
|
||||
get { return (int)base.Length; }
|
||||
get { if (type == PacketType.None) ParseType(); return type; }
|
||||
set { type = value; }
|
||||
}
|
||||
|
||||
public bool IsLastPacket()
|
||||
public long Position
|
||||
{
|
||||
if (Length == 1 && this[0] == 0xfe) return true;
|
||||
return false;
|
||||
get { return data.Position; }
|
||||
set { data.Position = value; }
|
||||
}
|
||||
|
||||
public byte[] GetBytes( byte packetSeq )
|
||||
public void AppendPacket( Packet newPacket )
|
||||
{
|
||||
long oldPos = Position;
|
||||
Position = 3;
|
||||
WriteInteger( Length-HEADER_LEN, 3 );
|
||||
WriteByte( packetSeq );
|
||||
Position = oldPos;
|
||||
return GetBuffer();
|
||||
data.Position = data.Length;
|
||||
byte[] bytes = newPacket.GetBytes();
|
||||
data.Write( bytes, 0, bytes.Length );
|
||||
}
|
||||
|
||||
private PacketType ParseType()
|
||||
{
|
||||
byte b = ReadByte();
|
||||
|
||||
// a 1 byte packet with byte 0xfe means last packet
|
||||
if ( data.Length == 1 && b == 0xfe)
|
||||
type = PacketType.Last;
|
||||
|
||||
// a first byte of 0xff means the packet is an error message
|
||||
else if ( b == 0xff )
|
||||
type = PacketType.Error;
|
||||
|
||||
// the first byte == 0 means an update packet or column count
|
||||
else if ( b == 0 )
|
||||
type = PacketType.UpdateOrOk;
|
||||
else
|
||||
type = PacketType.Other;
|
||||
return type;
|
||||
}
|
||||
|
||||
public byte[] GetBytes()
|
||||
{
|
||||
return data.ToArray();
|
||||
}
|
||||
|
||||
public void WriteByte( byte b )
|
||||
{
|
||||
data.WriteByte( b );
|
||||
}
|
||||
|
||||
public byte ReadByte()
|
||||
{
|
||||
return (byte)data.ReadByte();
|
||||
}
|
||||
|
||||
public void ReadBytes( byte[] buffer, int offset, int len )
|
||||
{
|
||||
data.Read( buffer, offset, len );
|
||||
}
|
||||
|
||||
public void WriteBytes( byte[] bytes, int offset, int len )
|
||||
{
|
||||
data.Write( bytes, offset, len );
|
||||
}
|
||||
|
||||
public int ReadNBytes()
|
||||
@@ -82,7 +129,7 @@ namespace ByteFX.Data.MySqlClient
|
||||
int len = ReadLenInteger();
|
||||
|
||||
byte[] buffer = new Byte[len];
|
||||
Read(buffer, 0, len);
|
||||
ReadBytes(buffer, 0, len);
|
||||
return encoding.GetString( buffer, 0, len);
|
||||
}
|
||||
|
||||
@@ -101,7 +148,7 @@ namespace ByteFX.Data.MySqlClient
|
||||
|
||||
for (int x=0; x < numbytes; x++)
|
||||
{
|
||||
WriteByte( (byte)(val&0xff) );
|
||||
data.WriteByte( (byte)(val&0xff) );
|
||||
val >>= 8;
|
||||
}
|
||||
}
|
||||
@@ -117,7 +164,7 @@ namespace ByteFX.Data.MySqlClient
|
||||
int raise = 1;
|
||||
for (int x=0; x < numbytes; x++)
|
||||
{
|
||||
int b = ReadByte();
|
||||
int b = data.ReadByte();
|
||||
val += (b*raise);
|
||||
raise *= 256;
|
||||
}
|
||||
@@ -142,9 +189,9 @@ namespace ByteFX.Data.MySqlClient
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasMoreData
|
||||
public bool CanRead
|
||||
{
|
||||
get { return Position < Length; }
|
||||
get { return data.Position < data.Length; }
|
||||
}
|
||||
|
||||
#region String Functions
|
||||
@@ -152,9 +199,9 @@ namespace ByteFX.Data.MySqlClient
|
||||
{
|
||||
System.Text.StringBuilder sb = new System.Text.StringBuilder();
|
||||
|
||||
while ( HasMoreData )
|
||||
while ( CanRead )
|
||||
{
|
||||
byte b = (byte)ReadByte();
|
||||
byte b = ReadByte();
|
||||
if (b == 0) break;
|
||||
sb.Append( Convert.ToChar( b ));
|
||||
}
|
||||
@@ -165,13 +212,13 @@ namespace ByteFX.Data.MySqlClient
|
||||
public void WriteString(string v, Encoding encoding)
|
||||
{
|
||||
WriteStringNoNull(v, encoding);
|
||||
WriteByte(0);
|
||||
data.WriteByte(0);
|
||||
}
|
||||
|
||||
public void WriteStringNoNull(string v, Encoding encoding)
|
||||
{
|
||||
byte[] bytes = encoding.GetBytes(v);
|
||||
Write(bytes, 0, bytes.Length);
|
||||
data.Write(bytes, 0, bytes.Length);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -22,13 +22,10 @@ using System.Collections;
|
||||
|
||||
namespace ByteFX.Data.MySqlClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a SQL statement to execute against a MySQL database. This class cannot be inherited.
|
||||
/// </summary>
|
||||
/// <include file='docs/MySqlCommand.xml' path='MyDocs/MyMembers[@name="Class"]/*'/>
|
||||
#if WINDOWS
|
||||
[System.Drawing.ToolboxBitmap( typeof(MySqlCommand), "Designers.command.bmp")]
|
||||
#endif
|
||||
|
||||
[System.ComponentModel.DesignerCategory("Code")]
|
||||
public sealed class MySqlCommand : Component, IDbCommand, ICloneable
|
||||
{
|
||||
@@ -47,43 +44,31 @@ namespace ByteFX.Data.MySqlClient
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overloaded. Initializes a new instance of the MySqlCommand class.
|
||||
/// </summary>
|
||||
// Implement other constructors here.
|
||||
public MySqlCommand(string cmdText)
|
||||
{
|
||||
this.cmdText = cmdText;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overloaded. Initializes a new instance of the MySqlCommand class.
|
||||
/// </summary>
|
||||
public MySqlCommand(System.ComponentModel.IContainer container)
|
||||
{
|
||||
// Required for Windows.Forms Class Composition Designer support
|
||||
/// <summary>
|
||||
/// Required for Windows.Forms Class Composition Designer support
|
||||
/// </summary>
|
||||
container.Add(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overloaded. Initializes a new instance of the MySqlCommand class.
|
||||
/// </summary>
|
||||
public MySqlCommand(string cmdText, MySqlConnection connection)
|
||||
{
|
||||
this.cmdText = cmdText;
|
||||
this.connection = connection;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disposes of this instance of MySqlCommand
|
||||
/// </summary>
|
||||
public new void Dispose()
|
||||
{
|
||||
base.Dispose();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overloaded. Initializes a new instance of the MySqlCommand class.
|
||||
/// </summary>
|
||||
public MySqlCommand(string cmdText, MySqlConnection connection, MySqlTransaction txn)
|
||||
{
|
||||
this.cmdText = cmdText;
|
||||
@@ -107,7 +92,7 @@ namespace ByteFX.Data.MySqlClient
|
||||
set { cmdText = value; }
|
||||
}
|
||||
|
||||
internal int UpdateCount
|
||||
public int UpdateCount
|
||||
{
|
||||
get { return updateCount; }
|
||||
}
|
||||
@@ -222,10 +207,6 @@ namespace ByteFX.Data.MySqlClient
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
/// <summary>
|
||||
/// Attempts to cancel the execution of a MySqlCommand. This operation is not supported.
|
||||
/// </summary>
|
||||
/// <exception cref="NotSupportedException">This operation is not supported.</exception>
|
||||
public void Cancel()
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
@@ -248,7 +229,7 @@ namespace ByteFX.Data.MySqlClient
|
||||
private ArrayList SplitSql(string sql)
|
||||
{
|
||||
ArrayList commands = new ArrayList();
|
||||
System.IO.MemoryStream ms = new System.IO.MemoryStream(sql.Length);
|
||||
System.IO.MemoryStream ms = new System.IO.MemoryStream();
|
||||
|
||||
// first we tack on a semi-colon, if not already there, to make our
|
||||
// sql processing code easier. Then we ask our encoder to give us
|
||||
@@ -311,7 +292,7 @@ namespace ByteFX.Data.MySqlClient
|
||||
if (cmdByte != ' ') { goodcmd = true; break; }
|
||||
|
||||
if (goodcmd)
|
||||
commands.Add( byteArray );
|
||||
commands.Add( ms.ToArray() );
|
||||
ms.SetLength(0);
|
||||
}
|
||||
else if (parm_start == -1)
|
||||
@@ -325,21 +306,6 @@ namespace ByteFX.Data.MySqlClient
|
||||
return commands;
|
||||
}
|
||||
|
||||
private void ReadOffResultSet()
|
||||
{
|
||||
Driver driver = connection.InternalConnection.Driver;
|
||||
|
||||
// first read off the schema
|
||||
Packet packet = driver.ReadPacket();
|
||||
while (! packet.IsLastPacket())
|
||||
packet = driver.ReadPacket();
|
||||
|
||||
// now read off the data
|
||||
packet = driver.ReadPacket();
|
||||
while (! packet.IsLastPacket())
|
||||
packet = driver.ReadPacket();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Internal function to execute the next command in an array of commands
|
||||
/// </summary>
|
||||
@@ -352,20 +318,16 @@ namespace ByteFX.Data.MySqlClient
|
||||
byte[] sql = (byte[])arraySql[0];
|
||||
arraySql.RemoveAt(0);
|
||||
|
||||
Packet packet = driver.SendSql( sql );
|
||||
byte b = (byte)packet.ReadByte();
|
||||
if (b == 0)
|
||||
{
|
||||
if (updateCount == -1) updateCount = 0;
|
||||
string s = connection.Encoding.GetString(sql);
|
||||
Packet packet = driver.SendSql( s );
|
||||
if (packet.Type == PacketType.UpdateOrOk)
|
||||
updateCount += (int)packet.ReadLenInteger();
|
||||
}
|
||||
else if (stopAtResultSet)
|
||||
{
|
||||
packet.Position--;
|
||||
else if (packet.Type == PacketType.ResultSchema && stopAtResultSet)
|
||||
return packet;
|
||||
}
|
||||
else
|
||||
ReadOffResultSet();
|
||||
else do
|
||||
{
|
||||
packet = driver.ReadPacket();
|
||||
} while (packet.Type != PacketType.Last);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -385,7 +347,7 @@ namespace ByteFX.Data.MySqlClient
|
||||
throw new MySqlException("There is already an open DataReader associated with this Connection which must be closed first.");
|
||||
|
||||
// execute any commands left in the queue from before.
|
||||
//ExecuteBatch(false);
|
||||
ExecuteBatch(false);
|
||||
|
||||
arraySql = SplitSql( cmdText );
|
||||
updateCount = 0;
|
||||
@@ -414,13 +376,14 @@ namespace ByteFX.Data.MySqlClient
|
||||
return ExecuteReader(CommandBehavior.Default);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Overloaded. Sends the CommandText to the Connection and builds a MySqlDataReader.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public MySqlDataReader ExecuteReader(CommandBehavior behavior)
|
||||
{
|
||||
/*
|
||||
* ExecuteReader should retrieve results from the data source
|
||||
* and return a DataReader that allows the user to process
|
||||
* the results.
|
||||
*/
|
||||
|
||||
// There must be a valid and open connection.
|
||||
if (connection == null || connection.State != ConnectionState.Open)
|
||||
throw new InvalidOperationException("Connection must be valid and open");
|
||||
@@ -452,15 +415,27 @@ namespace ByteFX.Data.MySqlClient
|
||||
sql = String.Format("SET SQL_SELECT_LIMIT=1;{0};SET sql_select_limit=-1;", cmdText);
|
||||
}
|
||||
|
||||
// execute any commands left in the queue from before.
|
||||
ExecuteBatch(false);
|
||||
|
||||
arraySql = SplitSql( sql );
|
||||
|
||||
updateCount = -1;
|
||||
MySqlDataReader reader = new MySqlDataReader(this, behavior);
|
||||
|
||||
// move to the first resultset
|
||||
reader.NextResult();
|
||||
connection.Reader = reader;
|
||||
return reader;
|
||||
try
|
||||
{
|
||||
if (reader.NextResult())
|
||||
{
|
||||
connection.Reader = reader;
|
||||
return reader;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.Diagnostics.Trace.WriteLine("Exception in ExecuteReader: " + e.Message);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -478,9 +453,11 @@ namespace ByteFX.Data.MySqlClient
|
||||
if (connection.Reader != null)
|
||||
throw new MySqlException("There is already an open DataReader associated with this Connection which must be closed first.");
|
||||
|
||||
// execute any commands left in the queue from before.
|
||||
ExecuteBatch(false);
|
||||
|
||||
arraySql = SplitSql( cmdText );
|
||||
|
||||
updateCount = -1;
|
||||
MySqlDataReader reader = new MySqlDataReader(this, 0);
|
||||
reader.NextResult();
|
||||
object val = null;
|
||||
@@ -500,17 +477,12 @@ namespace ByteFX.Data.MySqlClient
|
||||
#endregion
|
||||
|
||||
#region ICloneable
|
||||
/// <summary>
|
||||
/// Creates a clone of this MySqlCommand object. CommandText, Connection, and Transaction properties
|
||||
/// are included as well as the entire parameter list.
|
||||
/// </summary>
|
||||
/// <returns>The cloned MySqlCommand object</returns>
|
||||
public object Clone()
|
||||
{
|
||||
MySqlCommand clone = new MySqlCommand(cmdText, connection, curTransaction);
|
||||
foreach (MySqlParameter p in parameters)
|
||||
{
|
||||
clone.Parameters.Add((p as ICloneable).Clone());
|
||||
clone.Parameters.Add(p.Clone());
|
||||
}
|
||||
return clone;
|
||||
}
|
||||
|
||||
@@ -21,10 +21,6 @@ using System.ComponentModel;
|
||||
|
||||
namespace ByteFX.Data.MySqlClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a set of data commands and a database connection that are used to fill a dataset and update a MySQL database. This class cannot be inherited.
|
||||
/// </summary>
|
||||
/// <include file='docs/MySqlDataAdapter.xml' path='MyDocs/MyMembers[@name="Class"]/*'/>
|
||||
[System.Drawing.ToolboxBitmap( typeof(MySqlDataAdapter), "Designers.dataadapter.bmp")]
|
||||
[System.ComponentModel.DesignerCategory("Code")]
|
||||
public sealed class MySqlDataAdapter : DbDataAdapter, IDbDataAdapter
|
||||
@@ -44,79 +40,27 @@ namespace ByteFX.Data.MySqlClient
|
||||
static private readonly object EventRowUpdating = new object();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the MySqlDataAdapter class.
|
||||
/// </summary>
|
||||
public MySqlDataAdapter()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the MySqlDataAdapter class with the specified MySqlCommand as the SelectCommand property.
|
||||
/// </summary>
|
||||
/// <param name="selectCommand"></param>
|
||||
public MySqlDataAdapter( MySqlCommand selectCommand )
|
||||
{
|
||||
SelectCommand = selectCommand;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the MySqlDataAdapter class with a SelectCommand and a MySqlConnection object.
|
||||
/// </summary>
|
||||
/// <param name="selectCommandText"></param>
|
||||
/// <param name="conn"></param>
|
||||
public MySqlDataAdapter( string selectCommandText, MySqlConnection conn)
|
||||
{
|
||||
SelectCommand = new MySqlCommand( selectCommandText, conn );
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the MySqlDataAdapter class with a SelectCommand and a connection string.
|
||||
/// </summary>
|
||||
/// <param name="selectCommandText"></param>
|
||||
/// <param name="selectConnString"></param>
|
||||
public MySqlDataAdapter( string selectCommandText, string selectConnString)
|
||||
{
|
||||
SelectCommand = new MySqlCommand( selectCommandText,
|
||||
new MySqlConnection(selectConnString) );
|
||||
}
|
||||
|
||||
public MySqlDataAdapter( string selectCommandText, MySqlConnection conn)
|
||||
{
|
||||
SelectCommand = new MySqlCommand( selectCommandText, conn );
|
||||
}
|
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// Gets or sets a SQL statement to delete records from the data set.
|
||||
/// </summary>
|
||||
[DataSysDescription("Used during Update for deleted rows in Dataset.")]
|
||||
public MySqlCommand DeleteCommand
|
||||
{
|
||||
get { return m_deleteCommand; }
|
||||
set { m_deleteCommand = value; }
|
||||
}
|
||||
|
||||
IDbCommand IDbDataAdapter.DeleteCommand
|
||||
{
|
||||
get { return m_deleteCommand; }
|
||||
set { m_deleteCommand = (MySqlCommand)value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a SQL statement to insert new records into the data source.
|
||||
/// </summary>
|
||||
[DataSysDescription("Used during Update for new rows in Dataset.")]
|
||||
public MySqlCommand InsertCommand
|
||||
{
|
||||
get { return m_insertCommand; }
|
||||
set { m_insertCommand = value; }
|
||||
}
|
||||
|
||||
IDbCommand IDbDataAdapter.InsertCommand
|
||||
{
|
||||
get { return m_insertCommand; }
|
||||
set { m_insertCommand = (MySqlCommand)value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a SQL statement used to select records in the data source.
|
||||
/// </summary>
|
||||
[DataSysDescription("Used during Fill/FillSchema")]
|
||||
[Category("Fill")]
|
||||
public MySqlCommand SelectCommand
|
||||
@@ -131,9 +75,19 @@ namespace ByteFX.Data.MySqlClient
|
||||
set { m_selectCommand = (MySqlCommand)value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a SQL statement used to update records in the data source.
|
||||
/// </summary>
|
||||
[DataSysDescription("Used during Update for new rows in Dataset.")]
|
||||
public MySqlCommand InsertCommand
|
||||
{
|
||||
get { return m_insertCommand; }
|
||||
set { m_insertCommand = value; }
|
||||
}
|
||||
|
||||
IDbCommand IDbDataAdapter.InsertCommand
|
||||
{
|
||||
get { return m_insertCommand; }
|
||||
set { m_insertCommand = (MySqlCommand)value; }
|
||||
}
|
||||
|
||||
[DataSysDescription("Used during Update for modified rows in Dataset.")]
|
||||
public MySqlCommand UpdateCommand
|
||||
{
|
||||
@@ -147,41 +101,33 @@ namespace ByteFX.Data.MySqlClient
|
||||
set { m_updateCommand = (MySqlCommand)value; }
|
||||
}
|
||||
|
||||
[DataSysDescription("Used during Update for deleted rows in Dataset.")]
|
||||
public MySqlCommand DeleteCommand
|
||||
{
|
||||
get { return m_deleteCommand; }
|
||||
set { m_deleteCommand = value; }
|
||||
}
|
||||
|
||||
IDbCommand IDbDataAdapter.DeleteCommand
|
||||
{
|
||||
get { return m_deleteCommand; }
|
||||
set { m_deleteCommand = (MySqlCommand)value; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
/*
|
||||
* Implement abstract methods inherited from DbDataAdapter.
|
||||
*/
|
||||
/// <summary>
|
||||
/// Overridden. See <see cref="DbDataAdapter.CreateRowUpdatedEvent"/>.
|
||||
/// </summary>
|
||||
/// <param name="dataRow"></param>
|
||||
/// <param name="command"></param>
|
||||
/// <param name="statementType"></param>
|
||||
/// <param name="tableMapping"></param>
|
||||
/// <returns></returns>
|
||||
override protected RowUpdatedEventArgs CreateRowUpdatedEvent(DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping)
|
||||
{
|
||||
return new MySqlRowUpdatedEventArgs(dataRow, command, statementType, tableMapping);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overridden. See <see cref="DbDataAdapter.CreateRowUpdatingEvent"/>.
|
||||
/// </summary>
|
||||
/// <param name="dataRow"></param>
|
||||
/// <param name="command"></param>
|
||||
/// <param name="statementType"></param>
|
||||
/// <param name="tableMapping"></param>
|
||||
/// <returns></returns>
|
||||
override protected RowUpdatingEventArgs CreateRowUpdatingEvent(DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping)
|
||||
{
|
||||
return new MySqlRowUpdatingEventArgs(dataRow, command, statementType, tableMapping);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overridden. Raises the RowUpdating event.
|
||||
/// </summary>
|
||||
/// <param name="value">A MySqlRowUpdatingEventArgs that contains the event data.</param>
|
||||
override protected void OnRowUpdating(RowUpdatingEventArgs value)
|
||||
{
|
||||
MySqlRowUpdatingEventHandler handler = (MySqlRowUpdatingEventHandler) Events[EventRowUpdating];
|
||||
@@ -191,10 +137,6 @@ namespace ByteFX.Data.MySqlClient
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overridden. Raises the RowUpdated event.
|
||||
/// </summary>
|
||||
/// <param name="value">A MySqlRowUpdatedEventArgs that contains the event data. </param>
|
||||
override protected void OnRowUpdated(RowUpdatedEventArgs value)
|
||||
{
|
||||
MySqlRowUpdatedEventHandler handler = (MySqlRowUpdatedEventHandler) Events[EventRowUpdated];
|
||||
@@ -204,18 +146,12 @@ namespace ByteFX.Data.MySqlClient
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Occurs during Update before a command is executed against the data source. The attempt to update is made, so the event fires.
|
||||
/// </summary>
|
||||
public event MySqlRowUpdatingEventHandler RowUpdating
|
||||
{
|
||||
add { Events.AddHandler(EventRowUpdating, value); }
|
||||
remove { Events.RemoveHandler(EventRowUpdating, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Occurs during Update after a command is executed against the data source. The attempt to update is made, so the event fires.
|
||||
/// </summary>
|
||||
public event MySqlRowUpdatedEventHandler RowUpdated
|
||||
{
|
||||
add { Events.AddHandler(EventRowUpdated, value); }
|
||||
@@ -223,36 +159,17 @@ namespace ByteFX.Data.MySqlClient
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents the method that will handle the <see cref="MySqlDataAdapter.RowUpdating"/> event of a <see cref="MySqlDataAdapter"/>.
|
||||
/// </summary>
|
||||
public delegate void MySqlRowUpdatingEventHandler(object sender, MySqlRowUpdatingEventArgs e);
|
||||
|
||||
/// <summary>
|
||||
/// Represents the method that will handle the <see cref="MySqlDataAdapter.RowUpdated"/> event of a <see cref="MySqlDataAdapter"/>.
|
||||
/// </summary>
|
||||
public delegate void MySqlRowUpdatedEventHandler(object sender, MySqlRowUpdatedEventArgs e);
|
||||
|
||||
/// <summary>
|
||||
/// Provides data for the RowUpdating event. This class cannot be inherited.
|
||||
/// </summary>
|
||||
public sealed class MySqlRowUpdatingEventArgs : RowUpdatingEventArgs
|
||||
public class MySqlRowUpdatingEventArgs : RowUpdatingEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the MySqlRowUpdatingEventArgs class.
|
||||
/// </summary>
|
||||
/// <param name="row">The <see cref="DataRow"/> to <see cref="DbDataAdapter.Update"/>.</param>
|
||||
/// <param name="command">The <see cref="IDbCommand"/> to execute during <see cref="DbDataAdapter.Update"/>.</param>
|
||||
/// <param name="statementType">One of the <see cref="StatementType"/> values that specifies the type of query executed.</param>
|
||||
/// <param name="tableMapping">The <see cref="DataTableMapping"/> sent through an <see cref="DbDataAdapter.Update"/>.</param>
|
||||
public MySqlRowUpdatingEventArgs(DataRow row, IDbCommand command, StatementType statementType, DataTableMapping tableMapping)
|
||||
: base(row, command, statementType, tableMapping)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the MySqlCommand to execute when performing the Update.
|
||||
/// </summary>
|
||||
// Hide the inherited implementation of the command property.
|
||||
new public MySqlCommand Command
|
||||
{
|
||||
get { return (MySqlCommand)base.Command; }
|
||||
@@ -260,26 +177,14 @@ namespace ByteFX.Data.MySqlClient
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Provides data for the RowUpdated event. This class cannot be inherited.
|
||||
/// </summary>
|
||||
public sealed class MySqlRowUpdatedEventArgs : RowUpdatedEventArgs
|
||||
public class MySqlRowUpdatedEventArgs : RowUpdatedEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the MySqlRowUpdatedEventArgs class.
|
||||
/// </summary>
|
||||
/// <param name="row">The <see cref="DataRow"/> sent through an <see cref="DbDataAdapter.Update"/>.</param>
|
||||
/// <param name="command">The <see cref="IDbCommand"/> executed when <see cref="DbDataAdapter.Update"/> is called.</param>
|
||||
/// <param name="statementType">One of the <see cref="StatementType"/> values that specifies the type of query executed.</param>
|
||||
/// <param name="tableMapping">The <see cref="DataTableMapping"/> sent through an <see cref="DbDataAdapter.Update"/>.</param>
|
||||
public MySqlRowUpdatedEventArgs(DataRow row, IDbCommand command, StatementType statementType, DataTableMapping tableMapping)
|
||||
: base(row, command, statementType, tableMapping)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the MySqlCommand executed when Update is called.
|
||||
/// </summary>
|
||||
// Hide the inherited implementation of the command property.
|
||||
new public MySqlCommand Command
|
||||
{
|
||||
get { return (MySqlCommand)base.Command; }
|
||||
|
||||
@@ -21,10 +21,6 @@ using System.Collections;
|
||||
|
||||
namespace ByteFX.Data.MySqlClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides a means of reading a forward-only stream of rows from a MySQL database. This class cannot be inherited.
|
||||
/// </summary>
|
||||
/// <include file='docs/MySqlDataReader.xml' path='MyDocs/MyMembers[@name="Class"]/*'/>
|
||||
public sealed class MySqlDataReader : MarshalByRefObject, IEnumerable, IDataReader, IDisposable, IDataRecord
|
||||
{
|
||||
// The DataReader should always be open when returned to the user.
|
||||
@@ -37,6 +33,7 @@ namespace ByteFX.Data.MySqlClient
|
||||
private MySqlCommand command;
|
||||
private bool canRead;
|
||||
private bool hasRows;
|
||||
// private Packet rowPacket = null;
|
||||
|
||||
/*
|
||||
* Keep track of the connection in order to implement the
|
||||
@@ -57,12 +54,14 @@ namespace ByteFX.Data.MySqlClient
|
||||
commandBehavior = behavior;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating the depth of nesting for the current row. This method is not
|
||||
/// supported currently and always returns 0.
|
||||
/// </summary>
|
||||
/****
|
||||
* METHODS / PROPERTIES FROM IDataReader.
|
||||
****/
|
||||
public int Depth
|
||||
{
|
||||
/*
|
||||
* Always return a value of zero if nesting is not supported.
|
||||
*/
|
||||
get { return 0; }
|
||||
}
|
||||
|
||||
@@ -74,7 +73,7 @@ namespace ByteFX.Data.MySqlClient
|
||||
get { return ! isOpen; }
|
||||
}
|
||||
|
||||
void IDisposable.Dispose()
|
||||
public void Dispose()
|
||||
{
|
||||
if (isOpen)
|
||||
Close();
|
||||
@@ -147,10 +146,6 @@ namespace ByteFX.Data.MySqlClient
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the value of a column in its native format.
|
||||
/// [C#] In C#, this property is the indexer for the MySqlDataReader class.
|
||||
/// </summary>
|
||||
public object this [ String name ]
|
||||
{
|
||||
// Look up the ordinal and return
|
||||
@@ -188,13 +183,13 @@ namespace ByteFX.Data.MySqlClient
|
||||
/// <summary>
|
||||
/// Reads a stream of bytes from the specified column offset into the buffer an array starting at the given buffer offset.
|
||||
/// </summary>
|
||||
/// <param name="i">The zero-based column ordinal. </param>
|
||||
/// <param name="dataIndex">The index within the field from which to begin the read operation. </param>
|
||||
/// <param name="buffer">The buffer into which to read the stream of bytes. </param>
|
||||
/// <param name="bufferIndex">The index for buffer to begin the read operation. </param>
|
||||
/// <param name="length">The maximum length to copy into the buffer. </param>
|
||||
/// <returns>The actual number of bytes read.</returns>
|
||||
public long GetBytes(int i, long dataIndex, byte[] buffer, int bufferIndex, int length)
|
||||
/// <param name="i"></param>
|
||||
/// <param name="fieldOffset"></param>
|
||||
/// <param name="buffer"></param>
|
||||
/// <param name="bufferoffset"></param>
|
||||
/// <param name="length"></param>
|
||||
/// <returns></returns>
|
||||
public long GetBytes(int i, long fieldOffset, byte[] buffer, int bufferoffset, int length)
|
||||
{
|
||||
if (i >= _fields.Length)
|
||||
throw new IndexOutOfRangeException();
|
||||
@@ -204,15 +199,15 @@ namespace ByteFX.Data.MySqlClient
|
||||
if (buffer == null)
|
||||
return bytes.Length;
|
||||
|
||||
// adjust the length so we don't run off the end
|
||||
if (bytes.Length < (dataIndex+length))
|
||||
/// adjust the length so we don't run off the end
|
||||
if (bytes.Length < (fieldOffset+length))
|
||||
{
|
||||
length = (int)(bytes.Length - dataIndex);
|
||||
length = (int)(bytes.Length - fieldOffset);
|
||||
}
|
||||
|
||||
for (int x=0; x < length; x++)
|
||||
{
|
||||
buffer[bufferIndex+x] = bytes[dataIndex+x];
|
||||
buffer[bufferoffset+x] = bytes[fieldOffset+x];
|
||||
}
|
||||
|
||||
return length;
|
||||
@@ -252,7 +247,7 @@ namespace ByteFX.Data.MySqlClient
|
||||
if (buffer == null)
|
||||
return chars.Length;
|
||||
|
||||
// adjust the length so we don't run off the end
|
||||
/// adjust the length so we don't run off the end
|
||||
if (chars.Length < (fieldOffset+length))
|
||||
{
|
||||
length = (int)(chars.Length - fieldOffset);
|
||||
@@ -552,8 +547,13 @@ namespace ByteFX.Data.MySqlClient
|
||||
|
||||
#endregion
|
||||
|
||||
IDataReader IDataRecord.GetData(int i)
|
||||
public IDataReader GetData(int i)
|
||||
{
|
||||
/*
|
||||
* The sample code does not support this method. Normally,
|
||||
* this would be used to expose nested tables and
|
||||
* other hierarchical data.
|
||||
*/
|
||||
throw new NotSupportedException("GetData not supported.");
|
||||
}
|
||||
|
||||
@@ -578,19 +578,13 @@ namespace ByteFX.Data.MySqlClient
|
||||
|
||||
Driver driver = connection.InternalConnection.Driver;
|
||||
|
||||
// clear any rows that have not been read from the last rowset
|
||||
ClearCurrentResult();
|
||||
|
||||
// tell our command to continue execution of the SQL batch until it its
|
||||
// another resultset
|
||||
// tell our command to execute the next sql batch
|
||||
Packet packet = command.ExecuteBatch(true);
|
||||
|
||||
// if there was no more resultsets, then signal done
|
||||
if (packet == null)
|
||||
{
|
||||
canRead = false;
|
||||
return false;
|
||||
}
|
||||
// if there was no more batches, then signal done
|
||||
if (packet == null) return false;
|
||||
|
||||
// When executing query statements, the result byte that is returned
|
||||
// from MySql is the column count. That is why we reference the LastResult
|
||||
@@ -600,20 +594,14 @@ namespace ByteFX.Data.MySqlClient
|
||||
_fields = new MySqlField[ packet.ReadLenInteger() ];
|
||||
for (int x=0; x < _fields.Length; x++)
|
||||
{
|
||||
packet = driver.ReadPacket();
|
||||
_fields[x] = new MySqlField();
|
||||
_fields[x].ReadSchemaInfo( packet );
|
||||
}
|
||||
|
||||
// read off the end of schema packet
|
||||
packet = driver.ReadPacket();
|
||||
if ( ! packet.IsLastPacket())
|
||||
throw new MySqlException("Expected end of schema packet");
|
||||
|
||||
// now take a quick peek at the next packet to see if we have rows
|
||||
//
|
||||
packet = driver.PeekPacket();
|
||||
hasRows = ! packet.IsLastPacket();
|
||||
hasRows = packet.Type != PacketType.Last;
|
||||
canRead = hasRows;
|
||||
|
||||
connection.SetState( ConnectionState.Open );
|
||||
@@ -637,7 +625,7 @@ namespace ByteFX.Data.MySqlClient
|
||||
try
|
||||
{
|
||||
Packet rowPacket = driver.ReadPacket();
|
||||
if (rowPacket.IsLastPacket())
|
||||
if (rowPacket.Type == PacketType.Last)
|
||||
{
|
||||
canRead = false;
|
||||
return false;
|
||||
@@ -677,18 +665,16 @@ namespace ByteFX.Data.MySqlClient
|
||||
{
|
||||
if (! canRead) return;
|
||||
|
||||
Driver driver = connection.InternalConnection.Driver;
|
||||
|
||||
Packet packet = driver.ReadPacket();
|
||||
Packet packet = connection.InternalConnection.Driver.ReadPacket();
|
||||
// clean out any current resultset
|
||||
while (! packet.IsLastPacket())
|
||||
packet = driver.ReadPacket();
|
||||
while (packet.Type != PacketType.Last)
|
||||
packet = connection.InternalConnection.Driver.ReadPacket();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IEnumerator
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
public IEnumerator GetEnumerator()
|
||||
{
|
||||
return new System.Data.Common.DbEnumerator(this);
|
||||
}
|
||||
|
||||
@@ -24,37 +24,25 @@ using System.Reflection;
|
||||
|
||||
namespace ByteFX.Data.MySqlClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a parameter to a <see cref="MySqlCommand"/>, and optionally, its mapping to <see cref="DataSet"/> columns. This class cannot be inherited.
|
||||
/// </summary>
|
||||
[TypeConverter(typeof(MySqlParameter.MySqlParameterConverter))]
|
||||
public sealed class MySqlParameter : MarshalByRefObject, IDataParameter, IDbDataParameter, ICloneable
|
||||
{
|
||||
private MySqlDbType dbType = MySqlDbType.Null;
|
||||
private DbType genericType;
|
||||
private ParameterDirection direction = ParameterDirection.Input;
|
||||
private bool isNullable = false;
|
||||
private string paramName;
|
||||
private string sourceColumn;
|
||||
private DataRowVersion sourceVersion = DataRowVersion.Current;
|
||||
private object paramValue = DBNull.Value;
|
||||
private int size;
|
||||
private byte precision=0, scale=0;
|
||||
MySqlDbType dbType = MySqlDbType.Null;
|
||||
DbType genericType;
|
||||
ParameterDirection direction = ParameterDirection.Input;
|
||||
bool isNullable = false;
|
||||
string paramName;
|
||||
string sourceColumn;
|
||||
DataRowVersion sourceVersion = DataRowVersion.Current;
|
||||
object paramValue = DBNull.Value;
|
||||
int size;
|
||||
byte precision=0, scale=0;
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the MySqlParameter class.
|
||||
/// </summary>
|
||||
public MySqlParameter()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MySqlParameter"/> class with the parameter name and a value of the new MySqlParameter.
|
||||
/// </summary>
|
||||
/// <param name="parameterName">The name of the parameter to map. </param>
|
||||
/// <param name="value">An <see cref="Object"/> that is the value of the <see cref="MySqlParameter"/>. </param>
|
||||
public MySqlParameter(string parameterName, object value)
|
||||
{
|
||||
ParameterName = parameterName;
|
||||
@@ -63,54 +51,34 @@ namespace ByteFX.Data.MySqlClient
|
||||
genericType = GetGenericType( paramValue.GetType() );
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MySqlParameter"/> class with the parameter name and the data type.
|
||||
/// </summary>
|
||||
/// <param name="parameterName">The name of the parameter to map. </param>
|
||||
/// <param name="dbType">One of the <see cref="MySqlDbType"/> values. </param>
|
||||
public MySqlParameter( string parameterName, MySqlDbType dbType)
|
||||
public MySqlParameter( string parameterName, MySqlDbType type)
|
||||
{
|
||||
ParameterName = parameterName;
|
||||
this.dbType = dbType;
|
||||
dbType = type;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MySqlParameter"/> class with the parameter name, the <see cref="MySqlDbType"/>, and the size.
|
||||
/// </summary>
|
||||
/// <param name="parameterName">The name of the parameter to map. </param>
|
||||
/// <param name="dbType">One of the <see cref="MySqlDbType"/> values. </param>
|
||||
/// <param name="size">The length of the parameter. </param>
|
||||
public MySqlParameter( string parameterName, MySqlDbType dbType, int size )
|
||||
public MySqlParameter( string parameterName, MySqlDbType type, int size )
|
||||
{
|
||||
ParameterName = parameterName;
|
||||
this.dbType = dbType;
|
||||
dbType = type;
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MySqlParameter"/> class with the parameter name, the <see cref="MySqlDbType"/>, the size, and the source column name.
|
||||
/// </summary>
|
||||
/// <param name="parameterName">The name of the parameter to map. </param>
|
||||
/// <param name="dbType">One of the <see cref="MySqlDbType"/> values. </param>
|
||||
/// <param name="size">The length of the parameter. </param>
|
||||
/// <param name="sourceColumn">The name of the source column. </param>
|
||||
public MySqlParameter( string parameterName, MySqlDbType dbType, int size, string sourceColumn )
|
||||
public MySqlParameter( string name, MySqlDbType dbType, int size, string sourceCol )
|
||||
{
|
||||
ParameterName = parameterName;
|
||||
ParameterName = name;
|
||||
this.dbType = dbType;
|
||||
this.size = size;
|
||||
this.direction = ParameterDirection.Input;
|
||||
this.precision = 0;
|
||||
this.scale = 0;
|
||||
this.sourceColumn = sourceColumn;
|
||||
this.sourceColumn = sourceCol;
|
||||
this.sourceVersion = DataRowVersion.Current;
|
||||
this.paramValue =null;
|
||||
}
|
||||
|
||||
internal MySqlParameter(string name, MySqlDbType type, ParameterDirection dir, string col, DataRowVersion ver, object val)
|
||||
public MySqlParameter(string name, MySqlDbType type, ParameterDirection dir, string col, DataRowVersion ver, object val)
|
||||
{
|
||||
if (direction != ParameterDirection.Input)
|
||||
throw new ArgumentException("Only input parameters are supported by MySql");
|
||||
dbType = type;
|
||||
direction = dir;
|
||||
ParameterName = name;
|
||||
@@ -119,27 +87,10 @@ namespace ByteFX.Data.MySqlClient
|
||||
paramValue = val;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MySqlParameter"/> class with the parameter name, the type of the parameter, the size of the parameter, a <see cref="ParameterDirection"/>, the precision of the parameter, the scale of the parameter, the source column, a <see cref="DataRowVersion"/> to use, and the value of the parameter.
|
||||
/// </summary>
|
||||
/// <param name="parameterName">The name of the parameter to map. </param>
|
||||
/// <param name="dbType">One of the <see cref="MySqlDbType"/> values. </param>
|
||||
/// <param name="size">The length of the parameter. </param>
|
||||
/// <param name="direction">One of the <see cref="ParameterDirection"/> values. </param>
|
||||
/// <param name="isNullable">true if the value of the field can be null, otherwise false. </param>
|
||||
/// <param name="precision">The total number of digits to the left and right of the decimal point to which <see cref="MySqlParameter.Value"/> is resolved.</param>
|
||||
/// <param name="scale">The total number of decimal places to which <see cref="MySqlParameter.Value"/> is resolved. </param>
|
||||
/// <param name="sourceColumn">The name of the source column. </param>
|
||||
/// <param name="sourceVersion">One of the <see cref="DataRowVersion"/> values. </param>
|
||||
/// <param name="value">An <see cref="Object"/> that is the value of the <see cref="MySqlParameter"/>. </param>
|
||||
/// <exception cref="ArgumentException"/>
|
||||
public MySqlParameter( string parameterName, MySqlDbType dbType, int size, ParameterDirection direction,
|
||||
bool isNullable, byte precision, byte scale, string sourceColumn, DataRowVersion sourceVersion,
|
||||
object value)
|
||||
{
|
||||
if (direction != ParameterDirection.Input)
|
||||
throw new ArgumentException("Only input parameters are supported by MySql");
|
||||
|
||||
ParameterName = parameterName;
|
||||
this.dbType = dbType;
|
||||
this.size = size;
|
||||
@@ -153,10 +104,6 @@ namespace ByteFX.Data.MySqlClient
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the <see cref="DbType"/> of the parameter.
|
||||
/// </summary>
|
||||
public DbType DbType
|
||||
{
|
||||
get
|
||||
@@ -186,11 +133,11 @@ namespace ByteFX.Data.MySqlClient
|
||||
|
||||
case DbType.Int32:
|
||||
case DbType.UInt32:
|
||||
MySqlDbType = MySqlDbType.Int; break;
|
||||
MySqlDbType = MySqlDbType.Long; break;
|
||||
|
||||
case DbType.Int64:
|
||||
case DbType.UInt64:
|
||||
MySqlDbType = MySqlDbType.BigInt; break;
|
||||
MySqlDbType = MySqlDbType.LongLong; break;
|
||||
|
||||
case DbType.DateTime:
|
||||
MySqlDbType = MySqlDbType.Datetime; break;
|
||||
@@ -218,29 +165,6 @@ namespace ByteFX.Data.MySqlClient
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether the parameter is input-only, output-only, bidirectional, or a stored procedure return value parameter.
|
||||
/// As of MySql version 4.1 and earlier, input-only is the only valid choice.
|
||||
/// </summary>
|
||||
[Category("Data")]
|
||||
public ParameterDirection Direction
|
||||
{
|
||||
get { return direction; }
|
||||
set { direction = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether the parameter accepts null values.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
public Boolean IsNullable
|
||||
{
|
||||
get { return isNullable; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the MySqlDbType of the parameter.
|
||||
/// </summary>
|
||||
[Category("Data")]
|
||||
public MySqlDbType MySqlDbType
|
||||
{
|
||||
@@ -254,9 +178,19 @@ namespace ByteFX.Data.MySqlClient
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the MySqlParameter.
|
||||
/// </summary>
|
||||
[Category("Data")]
|
||||
public ParameterDirection Direction
|
||||
{
|
||||
get { return direction; }
|
||||
set { direction = value; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public Boolean IsNullable
|
||||
{
|
||||
get { return isNullable; }
|
||||
}
|
||||
|
||||
[Category("Misc")]
|
||||
public String ParameterName
|
||||
{
|
||||
@@ -269,39 +203,6 @@ namespace ByteFX.Data.MySqlClient
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the maximum number of digits used to represent the <see cref="Value"/> property.
|
||||
/// </summary>
|
||||
[Category("Data")]
|
||||
public byte Precision
|
||||
{
|
||||
get { return precision; }
|
||||
set { precision = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the number of decimal places to which <see cref="Value"/> is resolved.
|
||||
/// </summary>
|
||||
[Category("Data")]
|
||||
public byte Scale
|
||||
{
|
||||
get { return scale; }
|
||||
set { scale = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the maximum size, in bytes, of the data within the column.
|
||||
/// </summary>
|
||||
[Category("Data")]
|
||||
public int Size
|
||||
{
|
||||
get { return size; }
|
||||
set { size = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the source column that is mapped to the <see cref="DataSet"/> and used for loading or returning the <see cref="Value"/>.
|
||||
/// </summary>
|
||||
[Category("Data")]
|
||||
public String SourceColumn
|
||||
{
|
||||
@@ -309,9 +210,6 @@ namespace ByteFX.Data.MySqlClient
|
||||
set { sourceColumn = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the <see cref="DataRowVersion"/> to use when loading <see cref="Value"/>.
|
||||
/// </summary>
|
||||
[Category("Data")]
|
||||
public DataRowVersion SourceVersion
|
||||
{
|
||||
@@ -319,9 +217,6 @@ namespace ByteFX.Data.MySqlClient
|
||||
set { sourceVersion = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the parameter.
|
||||
/// </summary>
|
||||
[TypeConverter(typeof(StringConverter))]
|
||||
[Category("Data")]
|
||||
public object Value
|
||||
@@ -338,6 +233,27 @@ namespace ByteFX.Data.MySqlClient
|
||||
}
|
||||
}
|
||||
|
||||
// implement methods of IDbDataParameter
|
||||
[Category("Data")]
|
||||
public byte Precision
|
||||
{
|
||||
get { return precision; }
|
||||
set { precision = value; }
|
||||
}
|
||||
|
||||
[Category("Data")]
|
||||
public byte Scale
|
||||
{
|
||||
get { return scale; }
|
||||
set { scale = value; }
|
||||
}
|
||||
|
||||
[Category("Data")]
|
||||
public int Size
|
||||
{
|
||||
get { return size; }
|
||||
set { size = value; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
private void EscapeByteArray( byte[] bytes, System.IO.MemoryStream s )
|
||||
@@ -363,10 +279,6 @@ namespace ByteFX.Data.MySqlClient
|
||||
s.Write( newbytes, 0, newx );
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overridden. Gets a string containing the <see cref="ParameterName"/>.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return paramName;
|
||||
@@ -385,7 +297,7 @@ namespace ByteFX.Data.MySqlClient
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
internal void SerializeToBytes( System.IO.MemoryStream s, MySqlConnection conn )
|
||||
public void SerializeToBytes( System.IO.MemoryStream s, MySqlConnection conn )
|
||||
{
|
||||
string parm_string = null;
|
||||
byte[] bytes = null;
|
||||
@@ -512,9 +424,9 @@ namespace ByteFX.Data.MySqlClient
|
||||
case TypeCode.Int16:
|
||||
case TypeCode.UInt16: return MySqlDbType.Int24;
|
||||
case TypeCode.Int32:
|
||||
case TypeCode.UInt32: return MySqlDbType.Int;
|
||||
case TypeCode.UInt32: return MySqlDbType.Long;
|
||||
case TypeCode.Int64:
|
||||
case TypeCode.UInt64: return MySqlDbType.BigInt;
|
||||
case TypeCode.UInt64: return MySqlDbType.LongLong;
|
||||
case TypeCode.Single: return MySqlDbType.Float;
|
||||
case TypeCode.Double: return MySqlDbType.Double;
|
||||
case TypeCode.Decimal: return MySqlDbType.Decimal;
|
||||
@@ -528,7 +440,7 @@ namespace ByteFX.Data.MySqlClient
|
||||
|
||||
|
||||
#region ICloneable
|
||||
object System.ICloneable.Clone()
|
||||
public object Clone()
|
||||
{
|
||||
MySqlParameter clone = new MySqlParameter( paramName, dbType, direction,
|
||||
sourceColumn, sourceVersion, paramValue );
|
||||
|
||||
@@ -22,10 +22,6 @@ using System.ComponentModel;
|
||||
|
||||
namespace ByteFX.Data.MySqlClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a collection of parameters relevant to a <see cref="MySqlCommand"/> as well as their respective mappings to columns in a <see cref="DataSet"/>. This class cannot be inherited.
|
||||
/// </summary>
|
||||
/// <include file='docs/MySqlParameterCollection.xml' path='MyDocs/MyMembers[@name="Class"]/*'/>
|
||||
[Editor(typeof(ByteFX.Data.Common.DBParametersEditor), typeof(System.Drawing.Design.UITypeEditor))]
|
||||
[ListBindable(true)]
|
||||
public sealed class MySqlParameterCollection : MarshalByRefObject, IDataParameterCollection,
|
||||
@@ -53,12 +49,12 @@ namespace ByteFX.Data.MySqlClient
|
||||
_parms.CopyTo(array, index);
|
||||
}
|
||||
|
||||
bool ICollection.IsSynchronized
|
||||
public bool IsSynchronized
|
||||
{
|
||||
get { return _parms.IsSynchronized; }
|
||||
}
|
||||
|
||||
object ICollection.SyncRoot
|
||||
public object SyncRoot
|
||||
{
|
||||
get { return _parms.SyncRoot; }
|
||||
}
|
||||
@@ -74,23 +70,11 @@ namespace ByteFX.Data.MySqlClient
|
||||
_parms.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether a MySqlParameter exists in the collection.
|
||||
/// </summary>
|
||||
/// <param name="value">The value of the <see cref="MySqlParameter"/> object to find. </param>
|
||||
/// <returns>true if the collection contains the <see cref="MySqlParameter"/> object; otherwise, false.</returns>
|
||||
/// <overloads>Gets a value indicating whether a <see cref="MySqlParameter"/> exists in the collection.</overloads>
|
||||
public bool Contains(object value)
|
||||
{
|
||||
return _parms.Contains(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the location of a <see cref="MySqlParameter"/> in the collection.
|
||||
/// </summary>
|
||||
/// <param name="value">The <see cref="MySqlParameter"/> object to locate. </param>
|
||||
/// <returns>The zero-based location of the <see cref="MySqlParameter"/> in the collection.</returns>
|
||||
/// <overloads>Gets the location of a <see cref="MySqlParameter"/> in the collection.</overloads>
|
||||
public int IndexOf(object value)
|
||||
{
|
||||
return _parms.IndexOf(value);
|
||||
@@ -106,12 +90,12 @@ namespace ByteFX.Data.MySqlClient
|
||||
_parms.Insert( index, value );
|
||||
}
|
||||
|
||||
bool IList.IsFixedSize
|
||||
public bool IsFixedSize
|
||||
{
|
||||
get { return _parms.IsFixedSize; }
|
||||
}
|
||||
|
||||
bool IList.IsReadOnly
|
||||
public bool IsReadOnly
|
||||
{
|
||||
get { return _parms.IsReadOnly; }
|
||||
}
|
||||
@@ -125,11 +109,6 @@ namespace ByteFX.Data.MySqlClient
|
||||
_parms.Remove( value );
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the specified <see cref="MySqlParameter"/> from the collection using a specific index.
|
||||
/// </summary>
|
||||
/// <param name="index">The zero-based index of the parameter. </param>
|
||||
/// <overloads>Removes the specified <see cref="MySqlParameter"/> from the collection.</overloads>
|
||||
public void RemoveAt( int index )
|
||||
{
|
||||
_parms.RemoveAt( index );
|
||||
@@ -145,11 +124,6 @@ namespace ByteFX.Data.MySqlClient
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the specified <see cref="MySqlParameter"/> object to the <see cref="MySqlParameterCollection"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">The <see cref="MySqlParameter"/> to add to the collection.</param>
|
||||
/// <returns>The index of the new <see cref="MySqlParameter"/> object.</returns>
|
||||
public int Add( object value )
|
||||
{
|
||||
if (! (value is MySqlParameter)) throw new MySqlException("Only MySqlParameter objects may be stored");
|
||||
@@ -165,12 +139,6 @@ namespace ByteFX.Data.MySqlClient
|
||||
#endregion
|
||||
|
||||
#region IDataParameterCollection
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether a <see cref="MySqlParameter"/> with the specified parameter name exists in the collection.
|
||||
/// </summary>
|
||||
/// <param name="name">The name of the <see cref="MySqlParameter"/> object to find.</param>
|
||||
/// <returns>true if the collection contains the parameter; otherwise, false.</returns>
|
||||
public bool Contains(string name)
|
||||
{
|
||||
if (name[0] == '@')
|
||||
@@ -182,27 +150,18 @@ namespace ByteFX.Data.MySqlClient
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the location of the <see cref="MySqlParameter"/> in the collection with a specific parameter name.
|
||||
/// </summary>
|
||||
/// <param name="parameterName">The name of the <see cref="MySqlParameter"/> object to retrieve. </param>
|
||||
/// <returns>The zero-based location of the <see cref="MySqlParameter"/> in the collection.</returns>
|
||||
public int IndexOf( string parameterName )
|
||||
public int IndexOf( string name )
|
||||
{
|
||||
if (parameterName[0] == '@')
|
||||
parameterName = parameterName.Substring(1, parameterName.Length-1);
|
||||
if (name[0] == '@')
|
||||
name = name.Substring(1, name.Length-1);
|
||||
for (int x=0; x < _parms.Count; x++)
|
||||
{
|
||||
MySqlParameter p = (MySqlParameter)_parms[x];
|
||||
if (p.ParameterName.ToLower().Equals( parameterName.ToLower() )) return x;
|
||||
if (p.ParameterName.ToLower().Equals( name.ToLower() )) return x;
|
||||
}
|
||||
throw new MySqlException("Parameter '" + parameterName + "' not found in collection");
|
||||
throw new MySqlException("Parameter '" + name + "' not found in collection");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the specified <see cref="MySqlParameter"/> from the collection using the parameter name.
|
||||
/// </summary>
|
||||
/// <param name="name">The name of the <see cref="MySqlParameter"/> object to retrieve. </param>
|
||||
public void RemoveAt( string name )
|
||||
{
|
||||
int index = IndexOf( name );
|
||||
@@ -221,40 +180,25 @@ namespace ByteFX.Data.MySqlClient
|
||||
#endregion
|
||||
|
||||
#region IEnumerable
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
public IEnumerator GetEnumerator()
|
||||
{
|
||||
return ((IEnumerable)_parms).GetEnumerator();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="MySqlParameter"/> at the specified index.
|
||||
/// </summary>
|
||||
/// <overloads>Gets the <see cref="MySqlParameter"/> with a specified attribute.
|
||||
/// [C#] In C#, this property is the indexer for the <see cref="MySqlParameterCollection"/> class.
|
||||
/// </overloads>
|
||||
public MySqlParameter this[int index]
|
||||
{
|
||||
get { return (MySqlParameter)_parms[index]; }
|
||||
set { _parms[index] = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="MySqlParameter"/> with the specified name.
|
||||
/// </summary>
|
||||
public MySqlParameter this[string name]
|
||||
{
|
||||
get { return (MySqlParameter)_parms[ IndexOf( name ) ]; }
|
||||
set { _parms[ IndexOf( name ) ] = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the specified <see cref="MySqlParameter"/> object to the <see cref="MySqlParameterCollection"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">The <see cref="MySqlParameter"/> to add to the collection.</param>
|
||||
/// <returns>The index of the new <see cref="MySqlParameter"/> object.</returns>
|
||||
public MySqlParameter Add(MySqlParameter value)
|
||||
{
|
||||
if ( value.ParameterName == null ) throw new ArgumentException("parameter must be named");
|
||||
@@ -263,48 +207,21 @@ namespace ByteFX.Data.MySqlClient
|
||||
return value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a <see cref="MySqlParameter"/> to the <see cref="MySqlParameterCollection"/> given the specified parameter name and value.
|
||||
/// </summary>
|
||||
/// <param name="parameterName">The name of the parameter.</param>
|
||||
/// <param name="value">The <see cref="MySqlParameter.Value"/> of the <see cref="MySqlParameter"/> to add to the collection.</param>
|
||||
/// <returns>The index of the new <see cref="MySqlParameter"/> object.</returns>
|
||||
public MySqlParameter Add( string parameterName, object value )
|
||||
{
|
||||
return Add( new MySqlParameter( parameterName, value ) );
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a <see cref="MySqlParameter"/> to the <see cref="MySqlParameterCollection"/> given the parameter name and the data type.
|
||||
/// </summary>
|
||||
/// <param name="parameterName">The name of the parameter.</param>
|
||||
/// <param name="dbType">One of the <see cref="MySqlDbType"/> values. </param>
|
||||
/// <returns>The index of the new <see cref="MySqlParameter"/> object.</returns>
|
||||
public MySqlParameter Add(string parameterName, MySqlDbType dbType)
|
||||
public MySqlParameter Add(string parameterName, MySqlDbType type)
|
||||
{
|
||||
return Add(new MySqlParameter(parameterName, dbType));
|
||||
return Add(new MySqlParameter(parameterName, type));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a <see cref="MySqlParameter"/> to the <see cref="MySqlParameterCollection"/> with the parameter name, the data type, and the column length.
|
||||
/// </summary>
|
||||
/// <param name="parameterName">The name of the parameter.</param>
|
||||
/// <param name="dbType">One of the <see cref="MySqlDbType"/> values. </param>
|
||||
/// <param name="size">The length of the column.</param>
|
||||
/// <returns>The index of the new <see cref="MySqlParameter"/> object.</returns>
|
||||
public MySqlParameter Add(string parameterName, MySqlDbType dbType, int size)
|
||||
{
|
||||
return Add(new MySqlParameter(parameterName, dbType, size ));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a <see cref="MySqlParameter"/> to the <see cref="MySqlParameterCollection"/> with the parameter name, the data type, the column length, and the source column name.
|
||||
/// </summary>
|
||||
/// <param name="parameterName">The name of the parameter.</param>
|
||||
/// <param name="dbType">One of the <see cref="MySqlDbType"/> values. </param>
|
||||
/// <param name="size">The length of the column.</param>
|
||||
/// <param name="sourceColumn">The name of the source column.</param>
|
||||
/// <returns>The index of the new <see cref="MySqlParameter"/> object.</returns>
|
||||
public MySqlParameter Add(string parameterName, MySqlDbType dbType, int size, string sourceColumn)
|
||||
{
|
||||
return Add(new MySqlParameter(parameterName, dbType, size, sourceColumn));
|
||||
|
||||
@@ -20,11 +20,7 @@ using System.Data;
|
||||
|
||||
namespace ByteFX.Data.MySqlClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a SQL transaction to be made in a MySQL database. This class cannot be inherited.
|
||||
/// </summary>
|
||||
/// <include file='docs/MySqlTransaction.xml' path='MyDocs/MyMembers[@name="Class"]/*'/>
|
||||
public sealed class MySqlTransaction : IDbTransaction
|
||||
public class MySqlTransaction : IDbTransaction
|
||||
{
|
||||
private IsolationLevel _level;
|
||||
private MySqlConnection _conn;
|
||||
@@ -35,35 +31,22 @@ namespace ByteFX.Data.MySqlClient
|
||||
_open = true;
|
||||
}
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="MySqlConnection"/> object associated with the transaction, or a null reference (Nothing in Visual Basic) if the transaction is no longer valid.
|
||||
/// </summary>
|
||||
public IDbConnection Connection
|
||||
{
|
||||
get { return _conn; }
|
||||
set { _conn = (MySqlConnection)value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Specifies the <see cref="IsolationLevel"/> for this transaction.
|
||||
/// </summary>
|
||||
public IsolationLevel IsolationLevel
|
||||
{
|
||||
get { return _level; }
|
||||
set { _level = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
public IDbConnection Connection
|
||||
{
|
||||
get { return _conn; }
|
||||
set { _conn = (MySqlConnection)value; }
|
||||
}
|
||||
|
||||
void System.IDisposable.Dispose()
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Commits the database transaction.
|
||||
/// </summary>
|
||||
public void Commit()
|
||||
{
|
||||
if (_conn == null || _conn.State != ConnectionState.Open)
|
||||
@@ -82,9 +65,6 @@ namespace ByteFX.Data.MySqlClient
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overloaded. Rolls back a transaction from a pending state.
|
||||
/// </summary>
|
||||
public void Rollback()
|
||||
{
|
||||
if (_conn == null || _conn.State != ConnectionState.Open)
|
||||
|
||||
@@ -1,127 +0,0 @@
|
||||
/* Transport Security Layer (TLS)
|
||||
* Copyright (c) 2003 Carlos Guzmán Álvarez
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
* obtaining a copy of this software and associated documentation
|
||||
* files (the "Software"), to deal in the Software without restriction,
|
||||
* including without limitation the rights to use, copy, modify, merge,
|
||||
* publish, distribute, sublicense, and/or sell copies of the Software,
|
||||
* and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace Mono.Security.Cryptography
|
||||
{
|
||||
internal class MD5SHA1CryptoServiceProvider : HashAlgorithm
|
||||
{
|
||||
#region FIELDS
|
||||
|
||||
private HashAlgorithm md5;
|
||||
private HashAlgorithm sha;
|
||||
private bool hashing;
|
||||
|
||||
#endregion
|
||||
|
||||
#region CONSTRUCTORS
|
||||
|
||||
public MD5SHA1CryptoServiceProvider()
|
||||
{
|
||||
this.md5 = new MD5CryptoServiceProvider();
|
||||
this.sha = new SHA1CryptoServiceProvider();
|
||||
|
||||
// Set HashSizeValue
|
||||
this.HashSizeValue = this.md5.HashSize + this.sha.HashSize;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region METHODS
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
this.md5.Initialize();
|
||||
this.sha.Initialize();
|
||||
this.hashing = false;
|
||||
}
|
||||
|
||||
protected override byte[] HashFinal()
|
||||
{
|
||||
if (!hashing)
|
||||
{
|
||||
this.hashing = true;
|
||||
}
|
||||
// Finalize the original hash
|
||||
this.md5.TransformFinalBlock(new byte[0], 0, 0);
|
||||
this.sha.TransformFinalBlock(new byte[0], 0, 0);
|
||||
|
||||
byte[] hash = new byte[36];
|
||||
|
||||
System.Array.Copy(this.md5.Hash, 0, hash, 0, 16);
|
||||
System.Array.Copy(this.sha.Hash, 0, hash, 16, 20);
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
protected override void HashCore(
|
||||
byte[] array,
|
||||
int ibStart,
|
||||
int cbSize)
|
||||
{
|
||||
if (!hashing)
|
||||
{
|
||||
hashing = true;
|
||||
}
|
||||
this.md5.TransformBlock(array, ibStart, cbSize, array, ibStart);
|
||||
this.sha.TransformBlock(array, ibStart, cbSize, array, ibStart);
|
||||
}
|
||||
|
||||
public byte[] CreateSignature(RSA rsa)
|
||||
{
|
||||
if (rsa == null)
|
||||
{
|
||||
throw new CryptographicUnexpectedOperationException ("missing key");
|
||||
}
|
||||
|
||||
#warning "MD5SHA1 hash is not supported by .NET"
|
||||
RSAPKCS1SignatureFormatter f = new RSAPKCS1SignatureFormatter(rsa);
|
||||
f.SetHashAlgorithm("MD5SHA1");
|
||||
|
||||
return f.CreateSignature(this.Hash);
|
||||
}
|
||||
|
||||
public bool VerifySignature(RSA rsa, byte[] rgbSignature)
|
||||
{
|
||||
if (rsa == null)
|
||||
{
|
||||
throw new CryptographicUnexpectedOperationException ("missing key");
|
||||
}
|
||||
if (rgbSignature == null)
|
||||
{
|
||||
throw new ArgumentNullException ("rgbSignature");
|
||||
}
|
||||
|
||||
#warning "MD5SHA1 hash is not supported by .NET"
|
||||
RSAPKCS1SignatureDeformatter d = new RSAPKCS1SignatureDeformatter(rsa);
|
||||
d.SetHashAlgorithm("MD5SHA1");
|
||||
|
||||
return d.VerifySignature(this.Hash, rgbSignature);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
/* Transport Security Layer (TLS)
|
||||
* Copyright (c) 2003 Carlos Guzmán Álvarez
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
* obtaining a copy of this software and associated documentation
|
||||
* files (the "Software"), to deal in the Software without restriction,
|
||||
* including without limitation the rights to use, copy, modify, merge,
|
||||
* publish, distribute, sublicense, and/or sell copies of the Software,
|
||||
* and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls
|
||||
{
|
||||
// Information about compression methods allowed by TLS
|
||||
// can be found in:
|
||||
// draft-ietf-tls-compression-05.txt (http://www.ietf.org/internet-drafts/draft-ietf-tls-compression-05.txt)
|
||||
public enum TlsCompressionMethod : byte
|
||||
{
|
||||
None = 0,
|
||||
Zlib = 1
|
||||
}
|
||||
}
|
||||
@@ -1,369 +0,0 @@
|
||||
/* Transport Security Layer (TLS)
|
||||
* Copyright (c) 2003 Carlos Guzmán Álvarez
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
* obtaining a copy of this software and associated documentation
|
||||
* files (the "Software"), to deal in the Software without restriction,
|
||||
* including without limitation the rights to use, copy, modify, merge,
|
||||
* publish, distribute, sublicense, and/or sell copies of the Software,
|
||||
* and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls
|
||||
{
|
||||
public class TlsNetworkStream : Stream, IDisposable
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
private TlsSocket socket;
|
||||
private bool ownsSocket;
|
||||
private bool canRead;
|
||||
private bool canWrite;
|
||||
private bool disposed;
|
||||
|
||||
#endregion
|
||||
|
||||
#region PROPERTIES
|
||||
|
||||
public override bool CanRead
|
||||
{
|
||||
get { return canRead; }
|
||||
}
|
||||
|
||||
public override bool CanSeek
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
public override bool CanWrite
|
||||
{
|
||||
get { return canWrite; }
|
||||
}
|
||||
|
||||
public override long Length
|
||||
{
|
||||
get { throw new NotSupportedException(); }
|
||||
}
|
||||
|
||||
public override long Position
|
||||
{
|
||||
get { throw new NotSupportedException(); }
|
||||
set { throw new NotSupportedException(); }
|
||||
|
||||
}
|
||||
|
||||
public bool DataAvailable
|
||||
{
|
||||
get
|
||||
{
|
||||
if (socket == null)
|
||||
{
|
||||
throw new IOException();
|
||||
}
|
||||
|
||||
if (this.socket.Session.IsSecure)
|
||||
{
|
||||
if ((this.socket.InputBuffer.Length - this.socket.InputBuffer.Position) > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// If there are bytes in the socket buffer return true
|
||||
// otherwise false
|
||||
return this.socket.Available != 0;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region DESTRUCTOR
|
||||
|
||||
~TlsNetworkStream()
|
||||
{
|
||||
this.Dispose(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IDISPOSABLE
|
||||
|
||||
void IDisposable.Dispose()
|
||||
{
|
||||
this.Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (!disposed)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
if (this.socket != null)
|
||||
{
|
||||
if (this.ownsSocket)
|
||||
{
|
||||
try
|
||||
{
|
||||
this.socket.Shutdown(SocketShutdown.Both);
|
||||
}
|
||||
catch{}
|
||||
finally
|
||||
{
|
||||
this.socket.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
this.ownsSocket = false;
|
||||
this.canRead = false;
|
||||
this.canWrite = false;
|
||||
this.socket = null;
|
||||
}
|
||||
|
||||
disposed = true;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region PROTECTED_PROPERTIES
|
||||
|
||||
protected bool Readable
|
||||
{
|
||||
get { return this.canRead; }
|
||||
set { this.canRead = value;}
|
||||
}
|
||||
|
||||
protected TlsSocket Socket
|
||||
{
|
||||
get { return socket; }
|
||||
}
|
||||
|
||||
protected bool Writeable
|
||||
{
|
||||
get { return this.canWrite; }
|
||||
set { this.canWrite = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CONSTRUCTORS
|
||||
|
||||
public TlsNetworkStream(TlsSocket socket)
|
||||
: this(socket, FileAccess.ReadWrite, false)
|
||||
{
|
||||
}
|
||||
|
||||
public TlsNetworkStream(TlsSocket socket, bool ownsSocket)
|
||||
: this(socket, FileAccess.ReadWrite, ownsSocket)
|
||||
{
|
||||
}
|
||||
|
||||
public TlsNetworkStream(TlsSocket socket, FileAccess access)
|
||||
: this(socket, FileAccess.ReadWrite, false)
|
||||
{
|
||||
}
|
||||
|
||||
public TlsNetworkStream(TlsSocket socket, FileAccess access, bool ownsSocket)
|
||||
{
|
||||
if (socket == null)
|
||||
{
|
||||
throw new ArgumentNullException("socket is a null reference.");
|
||||
}
|
||||
if (!socket.Blocking)
|
||||
{
|
||||
throw new IOException("socket is in a nonblocking state.");
|
||||
}
|
||||
if (socket.SocketType != SocketType.Stream)
|
||||
{
|
||||
throw new IOException("The SocketType property of socket is not SocketType.Stream.");
|
||||
}
|
||||
if (!socket.Connected)
|
||||
{
|
||||
throw new IOException("socket is not connected.");
|
||||
}
|
||||
|
||||
this.socket = socket;
|
||||
this.ownsSocket = ownsSocket;
|
||||
switch (access)
|
||||
{
|
||||
case FileAccess.Read:
|
||||
this.canRead = true;
|
||||
break;
|
||||
|
||||
case FileAccess.ReadWrite:
|
||||
this.canRead = true;
|
||||
this.canWrite = true;
|
||||
break;
|
||||
|
||||
case FileAccess.Write:
|
||||
this.canWrite = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region METHODS
|
||||
|
||||
public override IAsyncResult BeginRead(
|
||||
byte[] buffer,
|
||||
int offset,
|
||||
int count,
|
||||
AsyncCallback callback,
|
||||
object state)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public override IAsyncResult BeginWrite(
|
||||
byte[] buffer,
|
||||
int offset,
|
||||
int count,
|
||||
AsyncCallback callback,
|
||||
object state)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public override int EndRead(IAsyncResult asyncResult)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public override void EndWrite(IAsyncResult asyncResult)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public override void Close()
|
||||
{
|
||||
((IDisposable)this).Dispose();
|
||||
}
|
||||
|
||||
public override void Flush()
|
||||
{
|
||||
}
|
||||
|
||||
public override int Read(byte[] buffer, int offset, int size)
|
||||
{
|
||||
if (buffer == null)
|
||||
{
|
||||
throw new ArgumentNullException("buffer is a null reference.");
|
||||
}
|
||||
if (offset < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("offset is less than 0.");
|
||||
}
|
||||
if (offset > buffer.Length)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("offset is greater than the length of buffer.");
|
||||
}
|
||||
if (size < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("size is less than 0.");
|
||||
}
|
||||
if (size > (buffer.Length - offset))
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("size is less than the length of buffer minus the value of the offset parameter.");
|
||||
}
|
||||
if (disposed)
|
||||
{
|
||||
throw new ObjectDisposedException("The NetworkStream is closed.");
|
||||
}
|
||||
if (!socket.Connected)
|
||||
{
|
||||
throw new IOException("The underlying Socket is closed.");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
return socket.Receive(buffer, offset, size, SocketFlags.None);
|
||||
}
|
||||
catch (TlsException ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new IOException("IO exception during read.", ex);
|
||||
}
|
||||
}
|
||||
|
||||
public override long Seek(long offset, SeekOrigin origin)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public override void SetLength(long value)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public override void Write(byte[] buffer, int offset, int size)
|
||||
{
|
||||
if (buffer == null)
|
||||
{
|
||||
throw new ArgumentNullException("buffer is a null reference.");
|
||||
}
|
||||
if (offset < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("offset is less than 0.");
|
||||
}
|
||||
if (offset > buffer.Length)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("offset is greater than the length of buffer.");
|
||||
}
|
||||
if (size < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("size is less than 0.");
|
||||
}
|
||||
if (size > (buffer.Length - offset))
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("size is less than the length of buffer minus the value of the offset parameter.");
|
||||
}
|
||||
if (disposed)
|
||||
{
|
||||
throw new ObjectDisposedException("The NetworkStream is closed.");
|
||||
}
|
||||
if (!socket.Connected)
|
||||
{
|
||||
throw new IOException("The underlying Socket is closed.");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
socket.Send(buffer, offset, size, SocketFlags.None);
|
||||
}
|
||||
catch (TlsException ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new IOException("IO exception during Write.", ex);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
/* Transport Security Layer (TLS)
|
||||
* Copyright (c) 2003 Carlos Guzmán Álvarez
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
* obtaining a copy of this software and associated documentation
|
||||
* files (the "Software"), to deal in the Software without restriction,
|
||||
* including without limitation the rights to use, copy, modify, merge,
|
||||
* publish, distribute, sublicense, and/or sell copies of the Software,
|
||||
* and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls
|
||||
{
|
||||
public enum TlsProtocol : short
|
||||
{
|
||||
Tls1 = (0x03 << 8) | 0x01,
|
||||
Ssl3 = (0x03 << 8) | 0x00
|
||||
}
|
||||
}
|
||||
@@ -1,265 +0,0 @@
|
||||
/* Transport Security Layer (TLS)
|
||||
* Copyright (c) 2003 Carlos Guzmán Álvarez
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
* obtaining a copy of this software and associated documentation
|
||||
* files (the "Software"), to deal in the Software without restriction,
|
||||
* including without limitation the rights to use, copy, modify, merge,
|
||||
* publish, distribute, sublicense, and/or sell copies of the Software,
|
||||
* and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
using System.Text;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
using Mono.Security.Protocol.Tls.Alerts;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls
|
||||
{
|
||||
public sealed class TlsSession
|
||||
{
|
||||
#region EVENTS
|
||||
|
||||
public event TlsWarningAlertEventHandler WarningAlert;
|
||||
|
||||
#endregion
|
||||
|
||||
#region FIELDS
|
||||
|
||||
private byte[] sessionId;
|
||||
private TlsSessionContext context;
|
||||
private TlsSessionSettings settings;
|
||||
private TlsSocket socket;
|
||||
private TlsNetworkStream networkStream;
|
||||
private bool isSecure;
|
||||
private TlsSessionState state;
|
||||
|
||||
#endregion
|
||||
|
||||
#region PROPERTIES
|
||||
|
||||
public byte[] SessionId
|
||||
{
|
||||
get { return sessionId; }
|
||||
}
|
||||
|
||||
public TlsNetworkStream NetworkStream
|
||||
{
|
||||
get { return networkStream; }
|
||||
}
|
||||
|
||||
public TlsSessionState State
|
||||
{
|
||||
get { return state; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region INTERNAL_PROPERTIES
|
||||
|
||||
internal TlsSessionContext Context
|
||||
{
|
||||
get { return context; }
|
||||
}
|
||||
|
||||
internal bool IsSecure
|
||||
{
|
||||
get { return isSecure; }
|
||||
set { isSecure = value; }
|
||||
}
|
||||
|
||||
internal TlsSessionSettings Settings
|
||||
{
|
||||
get { return settings; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CONSTRUCTORS
|
||||
|
||||
public TlsSession(TlsSessionSettings settings)
|
||||
{
|
||||
this.settings = settings;
|
||||
this.context = new TlsSessionContext();
|
||||
this.sessionId = new byte[0];
|
||||
|
||||
// Initialize socket for connection
|
||||
this.initializeSocket();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region EXCEPTION_METHODS
|
||||
|
||||
internal TlsException CreateException(TlsAlertLevel alertLevel, TlsAlertDescription alertDesc)
|
||||
{
|
||||
return CreateException(TlsAlert.GetAlertMessage(alertDesc));
|
||||
}
|
||||
|
||||
internal TlsException CreateException(string format, params object[] args)
|
||||
{
|
||||
StringBuilder message = new StringBuilder();
|
||||
message.AppendFormat(format, args);
|
||||
|
||||
return CreateException(message.ToString());
|
||||
}
|
||||
|
||||
internal TlsException CreateException(string message)
|
||||
{
|
||||
this.state = TlsSessionState.Broken;
|
||||
|
||||
// Throw an exception will made the connection unavailable
|
||||
// for this both streams will be closed
|
||||
closeStreams();
|
||||
|
||||
return new TlsException(message);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region METHODS
|
||||
|
||||
public void Open()
|
||||
{
|
||||
try
|
||||
{
|
||||
this.context.Protocol = settings.Protocol;
|
||||
this.context.CompressionMethod = settings.CompressionMethod;
|
||||
this.context.SupportedCiphers = TlsCipherSuiteFactory.GetSupportedCiphers(context.Protocol);
|
||||
this.state = TlsSessionState.OpeningSecure;
|
||||
this.socket.DoHandshake();
|
||||
this.state = TlsSessionState.OpenSecure;
|
||||
}
|
||||
catch (TlsException ex)
|
||||
{
|
||||
this.state = TlsSessionState.Broken;
|
||||
throw ex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
this.state = TlsSessionState.Broken;
|
||||
this.closeStreams();
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
try
|
||||
{
|
||||
this.state = TlsSessionState.Closing;
|
||||
|
||||
if (isSecure)
|
||||
{
|
||||
TlsCloseNotifyAlert alert = new TlsCloseNotifyAlert(this);
|
||||
|
||||
// Write close notify
|
||||
this.socket.SendAlert(alert);
|
||||
|
||||
// Check that the session is finished by the client and by server
|
||||
if (!this.context.ConnectionEnd)
|
||||
{
|
||||
throw new TlsException("Invalid session termination");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
this.state = TlsSessionState.Broken;
|
||||
throw ex;
|
||||
}
|
||||
finally
|
||||
{
|
||||
// Close streams
|
||||
closeStreams();
|
||||
|
||||
this.state = TlsSessionState.Closed;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region INTERNAL_METHODS
|
||||
|
||||
internal void RaiseWarningAlert(TlsAlertLevel level, TlsAlertDescription description)
|
||||
{
|
||||
if (WarningAlert != null)
|
||||
{
|
||||
WarningAlert(this, new TlsWarningAlertEventArgs(level, description));
|
||||
}
|
||||
}
|
||||
|
||||
internal void SetSessionId(byte[] sessionId)
|
||||
{
|
||||
this.sessionId = sessionId;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region PRIVATE_METHODS
|
||||
|
||||
private void initializeSocket()
|
||||
{
|
||||
try
|
||||
{
|
||||
this.state = TlsSessionState.Opening;
|
||||
|
||||
// Initialize socket
|
||||
IPAddress hostadd = Dns.Resolve(settings.ServerName).AddressList[0];
|
||||
IPEndPoint EPhost = new IPEndPoint(hostadd, settings.ServerPort);
|
||||
|
||||
// Create the socket
|
||||
socket = new TlsSocket(
|
||||
this,
|
||||
AddressFamily.InterNetwork,
|
||||
SocketType.Stream,
|
||||
ProtocolType.IP);
|
||||
|
||||
// Make the socket to connect to the Server
|
||||
socket.Connect(EPhost);
|
||||
networkStream = new TlsNetworkStream(socket, true);
|
||||
|
||||
this.state = TlsSessionState.Open;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
this.state = TlsSessionState.Broken;
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
private void closeStreams()
|
||||
{
|
||||
// Reset session state
|
||||
this.context.IsActual = false;
|
||||
|
||||
// Close the socket and the networkStream
|
||||
this.networkStream.Close();
|
||||
|
||||
// Reset session information
|
||||
this.isSecure = false;
|
||||
this.context = new TlsSessionContext();
|
||||
this.sessionId = new byte[0];
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,289 +0,0 @@
|
||||
/* Transport Security Layer (TLS)
|
||||
* Copyright (c) 2003 Carlos Guzmán Álvarez
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
* obtaining a copy of this software and associated documentation
|
||||
* files (the "Software"), to deal in the Software without restriction,
|
||||
* including without limitation the rights to use, copy, modify, merge,
|
||||
* publish, distribute, sublicense, and/or sell copies of the Software,
|
||||
* and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
using Mono.Security.Cryptography;
|
||||
using Mono.Security.Protocol.Tls.Handshake;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls
|
||||
{
|
||||
internal class TlsSessionContext
|
||||
{
|
||||
#region FIELDS
|
||||
|
||||
// Protocol version
|
||||
private TlsProtocol protocol;
|
||||
|
||||
// Compression method
|
||||
private TlsCompressionMethod compressionMethod;
|
||||
|
||||
// Information sent and request by the server in the Handshake protocol
|
||||
private TlsServerSettings serverSettings;
|
||||
|
||||
// Cipher suite information
|
||||
private CipherSuite cipher;
|
||||
private TlsCipherSuiteCollection supportedCiphers;
|
||||
|
||||
// Misc
|
||||
private bool isActual;
|
||||
private bool helloDone;
|
||||
private bool handshakeFinished;
|
||||
private bool connectionEnd;
|
||||
|
||||
// Sequence numbers
|
||||
private long writeSequenceNumber;
|
||||
private long readSequenceNumber;
|
||||
|
||||
// Random data
|
||||
private byte[] clientRandom;
|
||||
private byte[] serverRandom;
|
||||
private byte[] randomCS;
|
||||
private byte[] randomSC;
|
||||
|
||||
// Key information
|
||||
private byte[] masterSecret;
|
||||
private byte[] clientWriteMAC;
|
||||
private byte[] serverWriteMAC;
|
||||
private byte[] clientWriteKey;
|
||||
private byte[] serverWriteKey;
|
||||
private byte[] clientWriteIV;
|
||||
private byte[] serverWriteIV;
|
||||
|
||||
// Handshake hashes
|
||||
private TlsStream handshakeMessages;
|
||||
|
||||
#endregion
|
||||
|
||||
#region INTERNAL_CONSTANTS
|
||||
|
||||
internal const short MAX_FRAGMENT_SIZE = 16384; // 2^14
|
||||
|
||||
#endregion
|
||||
|
||||
#region PROPERTIES
|
||||
|
||||
public TlsProtocol Protocol
|
||||
{
|
||||
get { return this.protocol; }
|
||||
set { this.protocol = value; }
|
||||
}
|
||||
|
||||
public TlsCompressionMethod CompressionMethod
|
||||
{
|
||||
get { return this.compressionMethod; }
|
||||
set { this.compressionMethod = value; }
|
||||
}
|
||||
|
||||
public TlsServerSettings ServerSettings
|
||||
{
|
||||
get { return this.serverSettings; }
|
||||
set { this.serverSettings = value; }
|
||||
}
|
||||
|
||||
public bool IsActual
|
||||
{
|
||||
get { return this.isActual; }
|
||||
set { this.isActual = value; }
|
||||
}
|
||||
|
||||
public bool HelloDone
|
||||
{
|
||||
get { return helloDone; }
|
||||
set { helloDone = value; }
|
||||
}
|
||||
|
||||
public bool HandshakeFinished
|
||||
{
|
||||
get { return handshakeFinished; }
|
||||
set { handshakeFinished = value; }
|
||||
}
|
||||
|
||||
public bool ConnectionEnd
|
||||
{
|
||||
get { return this.connectionEnd; }
|
||||
set { this.connectionEnd = value; }
|
||||
}
|
||||
|
||||
public CipherSuite Cipher
|
||||
{
|
||||
get { return this.cipher; }
|
||||
set { this.cipher = value; }
|
||||
}
|
||||
|
||||
public TlsCipherSuiteCollection SupportedCiphers
|
||||
{
|
||||
get { return supportedCiphers; }
|
||||
set { supportedCiphers = value; }
|
||||
}
|
||||
|
||||
public TlsStream HandshakeMessages
|
||||
{
|
||||
get { return this.handshakeMessages; }
|
||||
}
|
||||
|
||||
public long WriteSequenceNumber
|
||||
{
|
||||
get { return this.writeSequenceNumber; }
|
||||
set { this.writeSequenceNumber = value; }
|
||||
}
|
||||
|
||||
public long ReadSequenceNumber
|
||||
{
|
||||
get { return this.readSequenceNumber; }
|
||||
set { this.readSequenceNumber = value; }
|
||||
}
|
||||
|
||||
public byte[] ClientRandom
|
||||
{
|
||||
get { return this.clientRandom; }
|
||||
set { this.clientRandom = value; }
|
||||
}
|
||||
|
||||
public byte[] ServerRandom
|
||||
{
|
||||
get { return this.serverRandom; }
|
||||
set { this.serverRandom = value; }
|
||||
}
|
||||
|
||||
public byte[] RandomCS
|
||||
{
|
||||
get { return this.randomCS; }
|
||||
set { this.randomCS = value; }
|
||||
}
|
||||
|
||||
public byte[] RandomSC
|
||||
{
|
||||
get { return this.randomSC; }
|
||||
set { this.randomSC = value; }
|
||||
}
|
||||
|
||||
public byte[] MasterSecret
|
||||
{
|
||||
get { return this.masterSecret; }
|
||||
set { this.masterSecret = value; }
|
||||
}
|
||||
|
||||
public byte[] ClientWriteMAC
|
||||
{
|
||||
get { return this.clientWriteMAC; }
|
||||
set { this.clientWriteMAC = value; }
|
||||
}
|
||||
|
||||
public byte[] ServerWriteMAC
|
||||
{
|
||||
get { return this.serverWriteMAC; }
|
||||
set { this.serverWriteMAC = value; }
|
||||
}
|
||||
|
||||
public byte[] ClientWriteKey
|
||||
{
|
||||
get { return this.clientWriteKey; }
|
||||
set { this.clientWriteKey = value; }
|
||||
}
|
||||
|
||||
public byte[] ServerWriteKey
|
||||
{
|
||||
get { return this.serverWriteKey; }
|
||||
set { this.serverWriteKey = value; }
|
||||
}
|
||||
|
||||
public byte[] ClientWriteIV
|
||||
{
|
||||
get { return this.clientWriteIV; }
|
||||
set { this.clientWriteIV = value; }
|
||||
}
|
||||
|
||||
public byte[] ServerWriteIV
|
||||
{
|
||||
get { return this.serverWriteIV; }
|
||||
set { this.serverWriteIV = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CONSTRUCTORS
|
||||
|
||||
public TlsSessionContext()
|
||||
{
|
||||
this.protocol = TlsProtocol.Tls1;
|
||||
this.compressionMethod = TlsCompressionMethod.None;
|
||||
this.serverSettings = new TlsServerSettings();
|
||||
this.handshakeMessages = new TlsStream();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region METHODS
|
||||
|
||||
public int GetUnixTime()
|
||||
{
|
||||
DateTime now = DateTime.Now.ToUniversalTime();
|
||||
TimeSpan unixTime = now.Subtract(new DateTime(1970, 1, 1));
|
||||
|
||||
return (int)unixTime.TotalSeconds;
|
||||
}
|
||||
|
||||
public byte[] GetSecureRandomBytes(int count)
|
||||
{
|
||||
byte[] secureBytes = new byte[count];
|
||||
|
||||
RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
|
||||
rng.GetNonZeroBytes(secureBytes);
|
||||
|
||||
return secureBytes;
|
||||
}
|
||||
|
||||
public void ClearKeyInfo()
|
||||
{
|
||||
// Clear Master Secret
|
||||
this.masterSecret = null;
|
||||
|
||||
// Clear client and server random
|
||||
this.clientRandom = null;
|
||||
this.serverRandom = null;
|
||||
this.randomCS = null;
|
||||
this.randomSC = null;
|
||||
|
||||
// Clear client keys
|
||||
this.clientWriteKey = null;
|
||||
this.clientWriteIV = null;
|
||||
|
||||
// Clear server keys
|
||||
this.serverWriteKey = null;
|
||||
this.serverWriteIV = null;
|
||||
|
||||
// Clear MAC keys if protocol is different than Ssl3
|
||||
if (this.protocol != TlsProtocol.Ssl3)
|
||||
{
|
||||
this.clientWriteMAC = null;
|
||||
this.serverWriteMAC = null;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,218 +0,0 @@
|
||||
/* Transport Security Layer (TLS)
|
||||
* Copyright (c) 2003 Carlos Guzmán Álvarez
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
* obtaining a copy of this software and associated documentation
|
||||
* files (the "Software"), to deal in the Software without restriction,
|
||||
* including without limitation the rights to use, copy, modify, merge,
|
||||
* publish, distribute, sublicense, and/or sell copies of the Software,
|
||||
* and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls
|
||||
{
|
||||
public sealed class TlsSessionSettings
|
||||
{
|
||||
#region FIELDS
|
||||
|
||||
private string serverName;
|
||||
private int serverPort;
|
||||
private Encoding encoding;
|
||||
private TlsProtocol protocol;
|
||||
private TlsCompressionMethod compressionMethod;
|
||||
private X509CertificateCollection certificates;
|
||||
|
||||
#endregion
|
||||
|
||||
#region PROPERTIES
|
||||
|
||||
public string ServerName
|
||||
{
|
||||
get { return serverName; }
|
||||
set { serverName = value; }
|
||||
}
|
||||
|
||||
public int ServerPort
|
||||
{
|
||||
get { return serverPort; }
|
||||
set { serverPort = value; }
|
||||
}
|
||||
|
||||
public Encoding Encoding
|
||||
{
|
||||
get { return encoding; }
|
||||
set { encoding = value; }
|
||||
}
|
||||
|
||||
public TlsProtocol Protocol
|
||||
{
|
||||
get { return protocol; }
|
||||
set
|
||||
{
|
||||
if (value != TlsProtocol.Tls1 &&
|
||||
value != TlsProtocol.Ssl3)
|
||||
{
|
||||
throw new NotSupportedException("Specified protocol is not supported");
|
||||
}
|
||||
protocol = value;
|
||||
}
|
||||
}
|
||||
|
||||
public TlsCompressionMethod CompressionMethod
|
||||
{
|
||||
get { return compressionMethod; }
|
||||
set
|
||||
{
|
||||
if (value != TlsCompressionMethod.None)
|
||||
{
|
||||
throw new NotSupportedException("Specified compression method is not supported");
|
||||
}
|
||||
compressionMethod = value;
|
||||
}
|
||||
}
|
||||
|
||||
public X509CertificateCollection Certificates
|
||||
{
|
||||
get { return certificates; }
|
||||
set { certificates = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CONSTRUCTORS
|
||||
|
||||
public TlsSessionSettings()
|
||||
{
|
||||
this.protocol = TlsProtocol.Tls1;
|
||||
this.compressionMethod = TlsCompressionMethod.None;
|
||||
this.certificates = new X509CertificateCollection();
|
||||
this.serverName = "localhost";
|
||||
this.serverPort = 443;
|
||||
this.encoding = Encoding.Default;
|
||||
}
|
||||
|
||||
public TlsSessionSettings(TlsProtocol protocol) : this()
|
||||
{
|
||||
this.Protocol = protocol;
|
||||
}
|
||||
|
||||
public TlsSessionSettings(TlsProtocol protocol, Encoding encoding) : this(protocol)
|
||||
{
|
||||
this.encoding = encoding;
|
||||
}
|
||||
|
||||
public TlsSessionSettings(string serverName) : this()
|
||||
{
|
||||
this.serverName = serverName;
|
||||
}
|
||||
|
||||
public TlsSessionSettings(string serverName, Encoding encoding) : this()
|
||||
{
|
||||
this.serverName = serverName;
|
||||
this.encoding = encoding;
|
||||
}
|
||||
|
||||
public TlsSessionSettings(string serverName, int serverPort) : this()
|
||||
{
|
||||
this.serverName = serverName;
|
||||
this.serverPort = serverPort;
|
||||
}
|
||||
|
||||
public TlsSessionSettings(string serverName, int serverPort, Encoding encoding) : this()
|
||||
{
|
||||
this.serverName = serverName;
|
||||
this.serverPort = serverPort;
|
||||
this.encoding = encoding;
|
||||
}
|
||||
|
||||
public TlsSessionSettings(TlsProtocol protocol, string serverName) : this(protocol)
|
||||
{
|
||||
this.serverName = serverName;
|
||||
}
|
||||
|
||||
public TlsSessionSettings(TlsProtocol protocol, string serverName, Encoding encoding) : this(protocol)
|
||||
{
|
||||
this.serverName = serverName;
|
||||
this.encoding = encoding;
|
||||
}
|
||||
|
||||
|
||||
public TlsSessionSettings(TlsProtocol protocol, string serverName, int serverPort) : this(protocol)
|
||||
{
|
||||
this.serverName = serverName;
|
||||
this.serverPort = serverPort;
|
||||
}
|
||||
|
||||
public TlsSessionSettings(TlsProtocol protocol, string serverName, int serverPort, Encoding encoding) : this(protocol)
|
||||
{
|
||||
this.serverName = serverName;
|
||||
this.serverPort = serverPort;
|
||||
this.encoding = encoding;
|
||||
}
|
||||
|
||||
public TlsSessionSettings(TlsProtocol protocol, X509CertificateCollection certificates) : this(protocol)
|
||||
{
|
||||
this.certificates = certificates;
|
||||
}
|
||||
|
||||
public TlsSessionSettings(TlsProtocol protocol, X509CertificateCollection certificates, Encoding encoding) : this(protocol)
|
||||
{
|
||||
this.certificates = certificates;
|
||||
this.encoding = encoding;
|
||||
}
|
||||
|
||||
public TlsSessionSettings(TlsProtocol protocol, X509CertificateCollection certificates, string serverName, int serverPort) : this(protocol)
|
||||
{
|
||||
this.certificates = certificates;
|
||||
this.serverName = serverName;
|
||||
this.serverPort = serverPort;
|
||||
}
|
||||
|
||||
public TlsSessionSettings(TlsProtocol protocol, X509CertificateCollection certificates, string serverName, int serverPort, Encoding encoding) : this(protocol)
|
||||
{
|
||||
this.certificates = certificates;
|
||||
this.serverName = serverName;
|
||||
this.serverPort = serverPort;
|
||||
this.encoding = encoding;
|
||||
}
|
||||
|
||||
public TlsSessionSettings(TlsProtocol protocol, X509Certificate[] certificates)
|
||||
: this(protocol, new X509CertificateCollection(certificates))
|
||||
{
|
||||
}
|
||||
|
||||
public TlsSessionSettings(TlsProtocol protocol, X509Certificate[] certificates, Encoding encoding)
|
||||
: this(protocol, new X509CertificateCollection(certificates), encoding)
|
||||
{
|
||||
}
|
||||
|
||||
public TlsSessionSettings(TlsProtocol protocol, X509Certificate[] certificates, string serverName, int serverPort) :
|
||||
this(protocol, new X509CertificateCollection(certificates), serverName, serverPort)
|
||||
{
|
||||
}
|
||||
|
||||
public TlsSessionSettings(TlsProtocol protocol, X509Certificate[] certificates, string serverName, int serverPort, Encoding encoding) :
|
||||
this(protocol, new X509CertificateCollection(certificates), serverName, serverPort, encoding)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,664 +0,0 @@
|
||||
/* Transport Security Layer (TLS)
|
||||
* Copyright (c) 2003 Carlos Guzmán Álvarez
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
* obtaining a copy of this software and associated documentation
|
||||
* files (the "Software"), to deal in the Software without restriction,
|
||||
* including without limitation the rights to use, copy, modify, merge,
|
||||
* publish, distribute, sublicense, and/or sell copies of the Software,
|
||||
* and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Collections;
|
||||
using System.Net.Sockets;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
using Mono.Security.Protocol.Tls;
|
||||
using Mono.Security.Protocol.Tls.Alerts;
|
||||
using Mono.Security.Protocol.Tls.Handshake;
|
||||
using Mono.Security.Protocol.Tls.Handshake.Client;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls
|
||||
{
|
||||
public sealed class TlsSocket : Socket
|
||||
{
|
||||
#region FIELDS
|
||||
|
||||
private TlsSession session;
|
||||
private BufferedStream inputBuffer;
|
||||
|
||||
#endregion
|
||||
|
||||
#region PROPERTIES
|
||||
|
||||
internal TlsSession Session
|
||||
{
|
||||
get { return this.session; }
|
||||
}
|
||||
|
||||
internal BufferedStream InputBuffer
|
||||
{
|
||||
get { return this.inputBuffer; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CONSTRUCTORS
|
||||
|
||||
private TlsSocket(
|
||||
AddressFamily addressFamily,
|
||||
SocketType socketType,
|
||||
ProtocolType protocolType
|
||||
) : base(addressFamily, socketType, protocolType)
|
||||
{
|
||||
this.inputBuffer = new BufferedStream(new MemoryStream());
|
||||
}
|
||||
|
||||
public TlsSocket(
|
||||
TlsSession session,
|
||||
AddressFamily addressFamily,
|
||||
SocketType socketType,
|
||||
ProtocolType protocolType
|
||||
) : this(addressFamily, socketType, protocolType)
|
||||
{
|
||||
this.session = session;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region REPLACED_METHODS
|
||||
|
||||
public new void Close()
|
||||
{
|
||||
this.resetBuffer();
|
||||
base.Close();
|
||||
if (this.session.State != TlsSessionState.Closing &&
|
||||
this.session.State != TlsSessionState.Closed)
|
||||
{
|
||||
this.session.Close();
|
||||
}
|
||||
}
|
||||
|
||||
public new int Receive(byte[] buffer)
|
||||
{
|
||||
return this.Receive(buffer, 0, buffer != null ? buffer.Length : 0, SocketFlags.None);
|
||||
}
|
||||
|
||||
public new int Receive(byte[] buffer, SocketFlags socketFlags)
|
||||
{
|
||||
return this.Receive(buffer, 0, buffer != null ? buffer.Length : 0, socketFlags);
|
||||
}
|
||||
|
||||
public new int Receive(byte[] buffer, int size, SocketFlags socketFlags)
|
||||
{
|
||||
return this.Receive(buffer, 0, size, socketFlags);
|
||||
}
|
||||
|
||||
public new int Receive(byte[] buffer, int offset, int size, SocketFlags socketFlags)
|
||||
{
|
||||
if (!this.session.IsSecure)
|
||||
{
|
||||
return base.Receive(buffer, offset, size, socketFlags);
|
||||
}
|
||||
|
||||
// If actual buffer is full readed reset it
|
||||
if (this.inputBuffer.Position == this.inputBuffer.Length)
|
||||
{
|
||||
this.resetBuffer();
|
||||
}
|
||||
|
||||
// Check if we have space in the middle buffer
|
||||
// if not Read next TLS record and update the inputBuffer
|
||||
while ((this.inputBuffer.Length - this.inputBuffer.Position) < size)
|
||||
{
|
||||
// Read next record and write it into the inputBuffer
|
||||
long position = this.inputBuffer.Position;
|
||||
byte[] record = this.receiveRecord();
|
||||
|
||||
if (record.Length > 0)
|
||||
{
|
||||
// Write new data to the inputBuffer
|
||||
this.inputBuffer.Seek(0, SeekOrigin.End);
|
||||
this.inputBuffer.Write(record, 0, record.Length);
|
||||
|
||||
// Restore buffer position
|
||||
this.inputBuffer.Seek(position, SeekOrigin.Begin);
|
||||
}
|
||||
|
||||
if (base.Available == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return this.inputBuffer.Read(buffer, offset, size);
|
||||
}
|
||||
|
||||
public new int Send(byte[] buffer)
|
||||
{
|
||||
return this.Send(buffer, 0, buffer != null ? buffer.Length : 0, SocketFlags.None);
|
||||
}
|
||||
|
||||
public new int Send(byte[] buffer, SocketFlags socketFlags)
|
||||
{
|
||||
return this.Send(buffer, 0, buffer != null ? buffer.Length : 0, socketFlags);
|
||||
}
|
||||
|
||||
public new int Send(byte[] buffer, int size, SocketFlags socketFlags)
|
||||
{
|
||||
return this.Send(buffer, 0, size, socketFlags);
|
||||
}
|
||||
|
||||
public new int Send(byte[] buffer, int offset, int size, SocketFlags socketFlags)
|
||||
{
|
||||
if (!this.session.IsSecure)
|
||||
{
|
||||
return base.Send(buffer, offset, size, socketFlags);
|
||||
}
|
||||
|
||||
// Send the buffer as a TLS record
|
||||
byte[] recordData = new byte[size];
|
||||
System.Array.Copy(buffer, offset, recordData, 0, size);
|
||||
|
||||
return this.sendRecord(TlsContentType.ApplicationData, recordData);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region TLS_RECORD_METHODS
|
||||
|
||||
private byte[] receiveRecord()
|
||||
{
|
||||
if (this.session.Context.ConnectionEnd)
|
||||
{
|
||||
throw this.session.CreateException("The session is finished and it's no longer valid.");
|
||||
}
|
||||
|
||||
TlsContentType contentType = (TlsContentType)this.ReadByte();
|
||||
TlsProtocol protocol = (TlsProtocol)this.ReadShort();
|
||||
short length = this.ReadShort();
|
||||
|
||||
// Read Record data
|
||||
int received = 0;
|
||||
byte[] buffer = new byte[length];
|
||||
while (received != length)
|
||||
{
|
||||
received += base.Receive(
|
||||
buffer, received, buffer.Length - received, SocketFlags.None);
|
||||
}
|
||||
|
||||
TlsStream message = new TlsStream(buffer);
|
||||
|
||||
// Check that the message has a valid protocol version
|
||||
if (protocol != this.session.Context.Protocol)
|
||||
{
|
||||
throw session.CreateException("Invalid protocol version on message received from server");
|
||||
}
|
||||
|
||||
// Decrypt message contents if needed
|
||||
if (contentType == TlsContentType.Alert && length == 2)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
if (session.Context.IsActual &&
|
||||
contentType != TlsContentType.ChangeCipherSpec)
|
||||
{
|
||||
message = this.decryptRecordFragment(
|
||||
contentType,
|
||||
protocol,
|
||||
message.ToArray());
|
||||
}
|
||||
}
|
||||
|
||||
byte[] result = message.ToArray();
|
||||
|
||||
// Process record
|
||||
switch (contentType)
|
||||
{
|
||||
case TlsContentType.Alert:
|
||||
this.processAlert((TlsAlertLevel)message.ReadByte(),
|
||||
(TlsAlertDescription)message.ReadByte());
|
||||
break;
|
||||
|
||||
case TlsContentType.ChangeCipherSpec:
|
||||
// Reset sequence numbers
|
||||
this.session.Context.ReadSequenceNumber = 0;
|
||||
break;
|
||||
|
||||
case TlsContentType.ApplicationData:
|
||||
break;
|
||||
|
||||
case TlsContentType.Handshake:
|
||||
while (!message.EOF)
|
||||
{
|
||||
this.processHandshakeMessage(message);
|
||||
}
|
||||
// Update handshakes of current messages
|
||||
this.session.Context.HandshakeMessages.Write(message.ToArray());
|
||||
break;
|
||||
|
||||
default:
|
||||
throw session.CreateException("Unknown record received from server.");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region TLS_CRYPTO_METHODS
|
||||
|
||||
private byte[] encryptRecordFragment(TlsContentType contentType, byte[] fragment)
|
||||
{
|
||||
// Calculate message MAC
|
||||
byte[] mac = this.session.Context.Cipher.ComputeClientRecordMAC(contentType, fragment);
|
||||
|
||||
// Encrypt the message
|
||||
byte[] ecr = this.session.Context.Cipher.EncryptRecord(fragment, mac);
|
||||
|
||||
// Set new IV
|
||||
if (this.session.Context.Cipher.CipherMode == CipherMode.CBC)
|
||||
{
|
||||
byte[] iv = new byte[this.session.Context.Cipher.IvSize];
|
||||
System.Array.Copy(ecr, ecr.Length - iv.Length, iv, 0, iv.Length);
|
||||
this.session.Context.Cipher.UpdateClientCipherIV(iv);
|
||||
}
|
||||
|
||||
// Update sequence number
|
||||
this.session.Context.WriteSequenceNumber++;
|
||||
|
||||
return ecr;
|
||||
}
|
||||
|
||||
private TlsStream decryptRecordFragment(TlsContentType contentType,
|
||||
TlsProtocol protocol,
|
||||
byte[] fragment)
|
||||
{
|
||||
byte[] dcrFragment = null;
|
||||
byte[] dcrMAC = null;
|
||||
|
||||
// Decrypt message
|
||||
this.session.Context.Cipher.DecryptRecord(fragment, ref dcrFragment, ref dcrMAC);
|
||||
|
||||
// Set new IV
|
||||
if (this.session.Context.Cipher.CipherMode == CipherMode.CBC)
|
||||
{
|
||||
byte[] iv = new byte[session.Context.Cipher.IvSize];
|
||||
System.Array.Copy(fragment, fragment.Length - iv.Length, iv, 0, iv.Length);
|
||||
this.session.Context.Cipher.UpdateServerCipherIV(iv);
|
||||
}
|
||||
|
||||
// Check MAC code
|
||||
byte[] mac = this.session.Context.Cipher.ComputeServerRecordMAC(contentType, dcrFragment);
|
||||
|
||||
// Check that the mac is correct
|
||||
if (mac.Length != dcrMAC.Length)
|
||||
{
|
||||
throw new TlsException("Invalid MAC received from server.");
|
||||
}
|
||||
for (int i = 0; i < mac.Length; i++)
|
||||
{
|
||||
if (mac[i] != dcrMAC[i])
|
||||
{
|
||||
throw new TlsException("Invalid MAC received from server.");
|
||||
}
|
||||
}
|
||||
|
||||
// Update sequence number
|
||||
this.session.Context.ReadSequenceNumber++;
|
||||
|
||||
return new TlsStream(dcrFragment);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region TLS_SEND_METHODS
|
||||
|
||||
internal int SendAlert(TlsAlert alert)
|
||||
{
|
||||
// Write record
|
||||
int bytesSent = this.sendRecord(TlsContentType.Alert, alert.ToArray());
|
||||
|
||||
// Update session
|
||||
alert.UpdateSession();
|
||||
|
||||
// Reset message contents
|
||||
alert.Reset();
|
||||
|
||||
return bytesSent;
|
||||
}
|
||||
|
||||
private int sendRecord(TlsHandshakeType type)
|
||||
{
|
||||
TlsHandshakeMessage msg = createClientHandshakeMessage(type);
|
||||
|
||||
// Write record
|
||||
int bytesSent = this.sendRecord(msg.ContentType, msg.EncodeMessage());
|
||||
|
||||
// Update session
|
||||
msg.UpdateSession();
|
||||
|
||||
// Reset message contents
|
||||
msg.Reset();
|
||||
|
||||
return bytesSent;
|
||||
}
|
||||
|
||||
private int sendChangeCipherSpec()
|
||||
{
|
||||
// Send Change Cipher Spec message
|
||||
int bytesSent = this.sendRecord(TlsContentType.ChangeCipherSpec, new byte[] {1});
|
||||
|
||||
// Reset sequence numbers
|
||||
this.session.Context.WriteSequenceNumber = 0;
|
||||
|
||||
// Make the pending state to be the current state
|
||||
this.session.Context.IsActual = true;
|
||||
|
||||
// Send Finished message
|
||||
bytesSent += this.sendRecord(TlsHandshakeType.Finished);
|
||||
|
||||
return bytesSent;
|
||||
}
|
||||
|
||||
private int sendRecord(TlsContentType contentType, byte[] recordData)
|
||||
{
|
||||
if (this.session.Context.ConnectionEnd)
|
||||
{
|
||||
throw this.session.CreateException("The session is finished and it's no longer valid.");
|
||||
}
|
||||
|
||||
int bytesSent = 0;
|
||||
byte[][] fragments = fragmentData(recordData);
|
||||
for (int i = 0; i < fragments.Length; i++)
|
||||
{
|
||||
byte[] fragment = fragments[i];
|
||||
|
||||
if (this.session.Context.IsActual)
|
||||
{
|
||||
// Encrypt fragment
|
||||
fragment = this.encryptRecordFragment(contentType, fragment);
|
||||
}
|
||||
|
||||
// Write tls message
|
||||
TlsStream record = new TlsStream();
|
||||
record.Write((byte)contentType);
|
||||
record.Write((short)this.session.Context.Protocol);
|
||||
record.Write((short)fragment.Length);
|
||||
record.Write(fragment);
|
||||
|
||||
// Write record
|
||||
bytesSent += base.Send(record.ToArray());
|
||||
|
||||
// Reset record data
|
||||
record.Reset();
|
||||
}
|
||||
|
||||
return bytesSent;
|
||||
}
|
||||
|
||||
private byte[][] fragmentData(byte[] messageData)
|
||||
{
|
||||
ArrayList d = new ArrayList();
|
||||
|
||||
int position = 0;
|
||||
|
||||
while (position < messageData.Length)
|
||||
{
|
||||
short fragmentLength = 0;
|
||||
byte[] fragmentData;
|
||||
if ((messageData.Length - position) > TlsSessionContext.MAX_FRAGMENT_SIZE)
|
||||
{
|
||||
fragmentLength = TlsSessionContext.MAX_FRAGMENT_SIZE;
|
||||
}
|
||||
else
|
||||
{
|
||||
fragmentLength = (short)(messageData.Length - position);
|
||||
}
|
||||
fragmentData = new byte[fragmentLength];
|
||||
|
||||
System.Array.Copy(messageData, position, fragmentData, 0, fragmentLength);
|
||||
|
||||
d.Add(fragmentData);
|
||||
|
||||
position += fragmentLength;
|
||||
}
|
||||
|
||||
byte[][] result = new byte[d.Count][];
|
||||
for (int i = 0; i < d.Count; i++)
|
||||
{
|
||||
result[i] = (byte[])d[i];
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region MESSAGE_PROCESSING
|
||||
|
||||
private void processHandshakeMessage(TlsStream handMsg)
|
||||
{
|
||||
TlsHandshakeType handshakeType = (TlsHandshakeType)handMsg.ReadByte();
|
||||
TlsHandshakeMessage message = null;
|
||||
|
||||
// Read message length
|
||||
int length = handMsg.ReadInt24();
|
||||
|
||||
// Read message data
|
||||
byte[] data = new byte[length];
|
||||
handMsg.Read(data, 0, length);
|
||||
|
||||
// Create and process the server message
|
||||
message = this.createServerHandshakeMessage(handshakeType, data);
|
||||
|
||||
// Update session
|
||||
if (message != null)
|
||||
{
|
||||
message.UpdateSession();
|
||||
}
|
||||
}
|
||||
|
||||
private void processAlert(TlsAlertLevel alertLevel, TlsAlertDescription alertDesc)
|
||||
{
|
||||
switch (alertLevel)
|
||||
{
|
||||
case TlsAlertLevel.Fatal:
|
||||
throw this.session.CreateException(alertLevel, alertDesc);
|
||||
|
||||
case TlsAlertLevel.Warning:
|
||||
default:
|
||||
switch (alertDesc)
|
||||
{
|
||||
case TlsAlertDescription.CloseNotify:
|
||||
this.session.Context.ConnectionEnd = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
this.session.RaiseWarningAlert(alertLevel, alertDesc);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region MISC_METHODS
|
||||
|
||||
private void resetBuffer()
|
||||
{
|
||||
this.inputBuffer.SetLength(0);
|
||||
this.inputBuffer.Position = 0;
|
||||
}
|
||||
|
||||
private byte ReadByte()
|
||||
{
|
||||
byte[] b = new byte[1];
|
||||
base.Receive(b);
|
||||
|
||||
return b[0];
|
||||
}
|
||||
|
||||
private short ReadShort()
|
||||
{
|
||||
byte[] b = new byte[2];
|
||||
base.Receive(b);
|
||||
|
||||
short val = BitConverter.ToInt16(b, 0);
|
||||
|
||||
return System.Net.IPAddress.HostToNetworkOrder(val);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region HANDSHAKE_METHODS
|
||||
|
||||
/*
|
||||
Client Server
|
||||
|
||||
ClientHello -------->
|
||||
ServerHello
|
||||
Certificate*
|
||||
ServerKeyExchange*
|
||||
CertificateRequest*
|
||||
<-------- ServerHelloDone
|
||||
Certificate*
|
||||
ClientKeyExchange
|
||||
CertificateVerify*
|
||||
[ChangeCipherSpec]
|
||||
Finished -------->
|
||||
[ChangeCipherSpec]
|
||||
<-------- Finished
|
||||
Application Data <-------> Application Data
|
||||
|
||||
Fig. 1 - Message flow for a full handshake
|
||||
*/
|
||||
|
||||
internal void DoHandshake()
|
||||
{
|
||||
// Reset isSecure field
|
||||
this.session.IsSecure = false;
|
||||
|
||||
// Send client hello
|
||||
this.sendRecord(TlsHandshakeType.ClientHello);
|
||||
|
||||
// Read server response
|
||||
while (!this.session.Context.HelloDone)
|
||||
{
|
||||
// Read next record
|
||||
this.receiveRecord();
|
||||
}
|
||||
|
||||
// Send client certificate if requested
|
||||
if (this.session.Context.ServerSettings.CertificateRequest)
|
||||
{
|
||||
this.sendRecord(TlsHandshakeType.Certificate);
|
||||
}
|
||||
|
||||
// Send Client Key Exchange
|
||||
this.sendRecord(TlsHandshakeType.ClientKeyExchange);
|
||||
|
||||
// Now initialize session cipher with the generated keys
|
||||
this.session.Context.Cipher.InitializeCipher();
|
||||
|
||||
// Send certificate verify if requested
|
||||
if (this.session.Context.ServerSettings.CertificateRequest)
|
||||
{
|
||||
this.sendRecord(TlsHandshakeType.CertificateVerify);
|
||||
}
|
||||
|
||||
// Send Cipher Spec protocol
|
||||
this.sendChangeCipherSpec();
|
||||
|
||||
// Read Cipher Spec protocol
|
||||
this.receiveRecord();
|
||||
|
||||
// Read server finished
|
||||
if (!this.session.Context.HandshakeFinished)
|
||||
{
|
||||
this.receiveRecord();
|
||||
}
|
||||
|
||||
// Clear Key Info
|
||||
this.session.Context.ClearKeyInfo();
|
||||
|
||||
// Set isSecure
|
||||
this.session.IsSecure = true;
|
||||
}
|
||||
|
||||
private TlsHandshakeMessage createClientHandshakeMessage(TlsHandshakeType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case TlsHandshakeType.ClientHello:
|
||||
return new TlsClientHello(session);
|
||||
|
||||
case TlsHandshakeType.Certificate:
|
||||
return new TlsClientCertificate(session);
|
||||
|
||||
case TlsHandshakeType.ClientKeyExchange:
|
||||
return new TlsClientKeyExchange(session);
|
||||
|
||||
case TlsHandshakeType.CertificateVerify:
|
||||
return new TlsClientCertificateVerify(session);
|
||||
|
||||
case TlsHandshakeType.Finished:
|
||||
return new TlsClientFinished(session);
|
||||
|
||||
default:
|
||||
throw new InvalidOperationException("Unknown client handshake message type: " + type.ToString() );
|
||||
}
|
||||
}
|
||||
|
||||
private TlsHandshakeMessage createServerHandshakeMessage(TlsHandshakeType type, byte[] buffer)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case TlsHandshakeType.HelloRequest:
|
||||
this.sendRecord(TlsHandshakeType.ClientHello);
|
||||
return null;
|
||||
|
||||
case TlsHandshakeType.ServerHello:
|
||||
return new TlsServerHello(session, buffer);
|
||||
|
||||
case TlsHandshakeType.Certificate:
|
||||
return new TlsServerCertificate(session, buffer);
|
||||
|
||||
case TlsHandshakeType.ServerKeyExchange:
|
||||
return new TlsServerKeyExchange(session, buffer);
|
||||
|
||||
case TlsHandshakeType.CertificateRequest:
|
||||
return new TlsServerCertificateRequest(session, buffer);
|
||||
|
||||
case TlsHandshakeType.ServerHelloDone:
|
||||
return new TlsServerHelloDone(session, buffer);
|
||||
|
||||
case TlsHandshakeType.Finished:
|
||||
return new TlsServerFinished(session, buffer);
|
||||
|
||||
default:
|
||||
throw this.session.CreateException("Unknown server handshake message received ({0})", type.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
-21
@@ -1,21 +0,0 @@
|
||||
//
|
||||
// System.Data.ObjectSpaces.PersistenceErrorBehaviour.cs - The behaviour to follow when a persistence error occurs
|
||||
//
|
||||
// Author:
|
||||
// Mark Easton ([email protected])
|
||||
//
|
||||
// (C) BLiNK Software Ltd. http://www.blinksoftware.co.uk
|
||||
//
|
||||
|
||||
#if NET_1_2
|
||||
|
||||
namespace System.Data.ObjectSpaces
|
||||
{
|
||||
public enum PersistenceErrorBehaviour
|
||||
{
|
||||
ThrowAtFirstError,
|
||||
ThrowAfterCompletion
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,23 +0,0 @@
|
||||
//
|
||||
// System.Data.ObjectSpaces.PersistenceErrorType.cs - The type of persistence error
|
||||
//
|
||||
// Author:
|
||||
// Mark Easton ([email protected])
|
||||
//
|
||||
// (C) BLiNK Software Ltd. http://www.blinksoftware.co.uk
|
||||
//
|
||||
|
||||
#if NET_1_2
|
||||
|
||||
namespace System.Data.ObjectSpaces
|
||||
{
|
||||
public enum PersistenceErrorType
|
||||
{
|
||||
Inserting,
|
||||
Deleting,
|
||||
Updating,
|
||||
Unknown
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,3 +1,10 @@
|
||||
2003-11-30 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* PageCompiler.cs: assign LCID, Culture and/or UICulture in
|
||||
FrameworInitialize() if provided in @Page.
|
||||
|
||||
Fixes bug #51511.
|
||||
|
||||
2003-11-20 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* TemplateControlCompiler.cs: support for expressions of
|
||||
|
||||
@@ -80,6 +80,18 @@ namespace System.Web.Compilation
|
||||
method.Statements.Add (invoke);
|
||||
}
|
||||
|
||||
int lcid = pageParser.LCID;
|
||||
if (lcid != -1)
|
||||
method.Statements.Add (CreatePropertyAssign ("LCID", lcid));
|
||||
|
||||
string culture = pageParser.Culture;
|
||||
if (culture != null)
|
||||
method.Statements.Add (CreatePropertyAssign ("Culture", culture));
|
||||
|
||||
culture = pageParser.UICulture;
|
||||
if (culture != null)
|
||||
method.Statements.Add (CreatePropertyAssign ("UICulture", culture));
|
||||
|
||||
base.AddStatementsToFrameworkInitialize (method);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
2003-11-30 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* Page.cs: fixed UICulture, LCID and Culture. Set the thread
|
||||
[UI]Culture before processing the request.
|
||||
|
||||
* PageParser.cs: read Culture, UICulture and LCID attributes. Added
|
||||
properties for these. Partially contributed by Mohammad Damt.
|
||||
|
||||
Fixes bug #51511.
|
||||
|
||||
2003-11-27 Jackson Harper <[email protected]>
|
||||
|
||||
* TemplateParser.cs: Ignore aspCompat attribute. This fixes bug
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
// Andreas Nahr ([email protected])
|
||||
//
|
||||
// (C) 2002,2003 Ximian, Inc. (http://www.ximian.com)
|
||||
// (c) 2003 Novell, Inc. (http://www.novell.com)
|
||||
//
|
||||
|
||||
using System;
|
||||
@@ -15,9 +16,11 @@ using System.Collections.Specialized;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.Design;
|
||||
using System.ComponentModel.Design.Serialization;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Security.Principal;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Web;
|
||||
using System.Web.Caching;
|
||||
using System.Web.SessionState;
|
||||
@@ -33,7 +36,6 @@ namespace System.Web.UI
|
||||
[RootDesignerSerializer ("Microsoft.VSDesigner.WebForms.RootCodeDomSerializer, " + Consts.AssemblyMicrosoft_VSDesigner, "System.ComponentModel.Design.Serialization.CodeDomSerializer, " + Consts.AssemblySystem_Design, true)]
|
||||
public class Page : TemplateControl, IHttpHandler
|
||||
{
|
||||
private string _culture;
|
||||
private bool _viewState = true;
|
||||
private bool _viewStateMac = false;
|
||||
private string _errorPage;
|
||||
@@ -44,7 +46,6 @@ public class Page : TemplateControl, IHttpHandler
|
||||
private bool _traceEnabled;
|
||||
private TraceMode _traceModeValue;
|
||||
private int _transactionMode;
|
||||
private string _UICulture;
|
||||
private HttpContext _context;
|
||||
private ValidatorCollection _validators;
|
||||
private bool renderingForm;
|
||||
@@ -133,7 +134,7 @@ public class Page : TemplateControl, IHttpHandler
|
||||
[EditorBrowsable (EditorBrowsableState.Never)]
|
||||
protected string Culture
|
||||
{
|
||||
set { _culture = value; }
|
||||
set { Thread.CurrentThread.CurrentCulture = new CultureInfo (value); }
|
||||
}
|
||||
|
||||
[Browsable (false)]
|
||||
@@ -196,10 +197,9 @@ public class Page : TemplateControl, IHttpHandler
|
||||
get { return _isValid; }
|
||||
}
|
||||
|
||||
[MonoTODO]
|
||||
[EditorBrowsable (EditorBrowsableState.Never)]
|
||||
protected int LCID {
|
||||
set { throw new NotImplementedException (); }
|
||||
set { Thread.CurrentThread.CurrentCulture = new CultureInfo (value); }
|
||||
}
|
||||
|
||||
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
|
||||
@@ -273,7 +273,7 @@ public class Page : TemplateControl, IHttpHandler
|
||||
[EditorBrowsable (EditorBrowsableState.Never)]
|
||||
protected string UICulture
|
||||
{
|
||||
set { _UICulture = value; }
|
||||
set { Thread.CurrentThread.CurrentUICulture = new CultureInfo (value); }
|
||||
}
|
||||
|
||||
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
|
||||
@@ -617,14 +617,24 @@ public class Page : TemplateControl, IHttpHandler
|
||||
public void ProcessRequest (HttpContext context)
|
||||
{
|
||||
_context = context;
|
||||
WebTrace.PushContext ("Page.ProcessRequest ()");
|
||||
WebTrace.WriteLine ("Entering");
|
||||
WireupAutomaticEvents ();
|
||||
WebTrace.WriteLine ("Finished hookup");
|
||||
//-- Control execution lifecycle in the docs
|
||||
WebTrace.WriteLine ("FrameworkInitialize");
|
||||
|
||||
// Save culture information because it can be modified in FrameworkInitialize()
|
||||
CultureInfo culture = Thread.CurrentThread.CurrentCulture;
|
||||
CultureInfo uiculture = Thread.CurrentThread.CurrentUICulture;
|
||||
FrameworkInitialize ();
|
||||
WebTrace.WriteLine ("InitRecursive");
|
||||
|
||||
try {
|
||||
InternalProcessRequest ();
|
||||
} finally {
|
||||
Thread.CurrentThread.CurrentCulture = culture;
|
||||
Thread.CurrentThread.CurrentUICulture = uiculture;
|
||||
}
|
||||
}
|
||||
|
||||
void InternalProcessRequest ()
|
||||
{
|
||||
InitRecursive (null);
|
||||
renderingForm = false;
|
||||
if (IsPostBack) {
|
||||
@@ -632,27 +642,20 @@ public class Page : TemplateControl, IHttpHandler
|
||||
ProcessPostData (DeterminePostBackMode (), false);
|
||||
}
|
||||
|
||||
WebTrace.WriteLine ("LoadRecursive");
|
||||
LoadRecursive ();
|
||||
if (IsPostBack) {
|
||||
ProcessPostData (secondPostData, true);
|
||||
RaiseChangedEvents ();
|
||||
RaisePostBackEvents ();
|
||||
}
|
||||
WebTrace.WriteLine ("PreRenderRecursiveInternal");
|
||||
PreRenderRecursiveInternal ();
|
||||
|
||||
WebTrace.WriteLine ("SavePageViewState");
|
||||
SavePageViewState ();
|
||||
//--
|
||||
HtmlTextWriter output = new HtmlTextWriter (context.Response.Output);
|
||||
WebTrace.WriteLine ("RenderControl");
|
||||
HtmlTextWriter output = new HtmlTextWriter (_context.Response.Output);
|
||||
RenderControl (output);
|
||||
_context = null;
|
||||
WebTrace.WriteLine ("UnloadRecursive");
|
||||
UnloadRecursive (true);
|
||||
WebTrace.WriteLine ("End");
|
||||
WebTrace.PopContext ();
|
||||
}
|
||||
|
||||
internal void RaisePostBackEvents ()
|
||||
@@ -804,15 +807,12 @@ public class Page : TemplateControl, IHttpHandler
|
||||
|
||||
internal void LoadPageViewState()
|
||||
{
|
||||
WebTrace.PushContext ("LoadPageViewState");
|
||||
object sState = LoadPageStateFromPersistenceMedium ();
|
||||
WebTrace.WriteLine ("sState = '{0}'", sState);
|
||||
if (sState != null) {
|
||||
Pair pair = (Pair) sState;
|
||||
LoadViewStateRecursive (pair.First);
|
||||
_requiresPostBack = pair.Second as ArrayList;
|
||||
}
|
||||
WebTrace.PopContext ();
|
||||
}
|
||||
|
||||
internal void SavePageViewState ()
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
//
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using System.Web.Compilation;
|
||||
@@ -22,6 +23,9 @@ namespace System.Web.UI
|
||||
string responseEncoding;
|
||||
string contentType;
|
||||
int codepage = -1;
|
||||
int lcid = -1;
|
||||
string culture;
|
||||
string uiculture;
|
||||
|
||||
// FIXME: this is here just for DesignTimeTemplateParser. Anything to do?
|
||||
internal PageParser ()
|
||||
@@ -94,21 +98,98 @@ namespace System.Web.UI
|
||||
|
||||
contentType = GetString (atts, "ContentType", null);
|
||||
|
||||
string lcidStr = GetString (atts, "LCID", null);
|
||||
if (lcidStr != null) {
|
||||
try {
|
||||
lcid = (int) UInt32.Parse (lcidStr);
|
||||
} catch {
|
||||
ThrowParseException ("Invalid value for LCID: " + lcid);
|
||||
}
|
||||
|
||||
CultureInfo ci = null;
|
||||
try {
|
||||
ci = new CultureInfo (lcid);
|
||||
} catch {
|
||||
ThrowParseException ("Unsupported LCID: " + lcid);
|
||||
}
|
||||
|
||||
if (ci.IsNeutralCulture) {
|
||||
string suggestedCulture = SuggestCulture (ci.Name);
|
||||
string fmt = "LCID attribute must be set to a non-neutral Culture.";
|
||||
if (suggestedCulture != null) {
|
||||
ThrowParseException (fmt + " Please try one of these: " +
|
||||
suggestedCulture);
|
||||
} else {
|
||||
ThrowParseException (fmt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
culture = GetString (atts, "Culture", null);
|
||||
if (culture != null) {
|
||||
if (lcidStr != null)
|
||||
ThrowParseException ("Culture and LCID are mutually exclusive.");
|
||||
|
||||
CultureInfo ci = null;
|
||||
try {
|
||||
ci = new CultureInfo (culture);
|
||||
} catch {
|
||||
ThrowParseException ("Unsupported Culture: " + culture);
|
||||
}
|
||||
|
||||
if (ci.IsNeutralCulture) {
|
||||
string suggestedCulture = SuggestCulture (culture);
|
||||
string fmt = "Culture attribute must be set to a non-neutral Culture.";
|
||||
if (suggestedCulture != null)
|
||||
ThrowParseException (fmt +
|
||||
" Please try one of these: " + suggestedCulture);
|
||||
else
|
||||
ThrowParseException (fmt);
|
||||
}
|
||||
}
|
||||
|
||||
uiculture = GetString (atts, "UICulture", null);
|
||||
if (uiculture != null) {
|
||||
CultureInfo ci = null;
|
||||
try {
|
||||
ci = new CultureInfo (uiculture);
|
||||
} catch {
|
||||
ThrowParseException ("Unsupported Culture: " + uiculture);
|
||||
}
|
||||
|
||||
if (ci.IsNeutralCulture) {
|
||||
string suggestedCulture = SuggestCulture (uiculture);
|
||||
string fmt = "UICulture attribute must be set to a non-neutral Culture.";
|
||||
if (suggestedCulture != null)
|
||||
ThrowParseException (fmt +
|
||||
" Please try one of these: " + suggestedCulture);
|
||||
else
|
||||
ThrowParseException (fmt);
|
||||
}
|
||||
}
|
||||
|
||||
// Ignored by now
|
||||
GetString (atts, "Buffer", null);
|
||||
GetString (atts, "ClientTarget", null);
|
||||
GetString (atts, "Culture", null);
|
||||
GetString (atts, "EnableViewStateMac", null);
|
||||
GetString (atts, "ErrorPage", null);
|
||||
GetString (atts, "LCID", null);
|
||||
GetString (atts, "Trace", null);
|
||||
GetString (atts, "TraceMode", null);
|
||||
GetString (atts, "UICulture", null);
|
||||
GetBool (atts, "ValidateRequest", true);
|
||||
|
||||
base.ProcessMainAttributes (atts);
|
||||
}
|
||||
|
||||
static string SuggestCulture (string culture)
|
||||
{
|
||||
string retval = null;
|
||||
foreach (CultureInfo ci in CultureInfo.GetCultures (CultureTypes.SpecificCultures)) {
|
||||
if (ci.Name.StartsWith (culture))
|
||||
retval += ci.Name + " ";
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
protected override Type CompileIntoType ()
|
||||
{
|
||||
AspGenerator generator = new AspGenerator (this);
|
||||
@@ -123,18 +204,12 @@ namespace System.Web.UI
|
||||
get { return readonlySessionState; }
|
||||
}
|
||||
|
||||
internal override Type DefaultBaseType
|
||||
{
|
||||
get {
|
||||
return typeof (Page);
|
||||
}
|
||||
internal override Type DefaultBaseType {
|
||||
get { return typeof (Page); }
|
||||
}
|
||||
|
||||
internal override string DefaultDirectiveName
|
||||
{
|
||||
get {
|
||||
return "page";
|
||||
}
|
||||
internal override string DefaultDirectiveName {
|
||||
get { return "page"; }
|
||||
}
|
||||
|
||||
internal string ResponseEncoding {
|
||||
@@ -148,6 +223,18 @@ namespace System.Web.UI
|
||||
internal int CodePage {
|
||||
get { return codepage; }
|
||||
}
|
||||
|
||||
internal string Culture {
|
||||
get { return culture; }
|
||||
}
|
||||
|
||||
internal string UICulture {
|
||||
get { return uiculture; }
|
||||
}
|
||||
|
||||
internal int LCID {
|
||||
get { return lcid; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
AttributeCollection
|
||||
BaseParser
|
||||
BasePartialCachingControl
|
||||
CompiledTemplateBuilder
|
||||
ConstructorNeedsTagAttribute
|
||||
ControlBuilder
|
||||
ControlBuilderAttribute
|
||||
ControlCollection
|
||||
CssStyleCollection
|
||||
DataBinder
|
||||
DataBinding
|
||||
DataBindingCollection
|
||||
DataBindingHandlerAttribute
|
||||
DataBoundLiteralControl
|
||||
DesignTimeParseData
|
||||
DesignTimeTemplateParser
|
||||
EmptyControlCollection
|
||||
Html32TextWriter
|
||||
HtmlTextWriter
|
||||
ImageClickEventArgs
|
||||
LosFormatter
|
||||
Page
|
||||
PageParser
|
||||
ParseChildrenAttribute
|
||||
PartialCachingAttribute
|
||||
PartialCachingControl
|
||||
PersistChildrenAttribute
|
||||
PersistanceModeAttribute
|
||||
RootBuilder
|
||||
SimpleWebHandlerParser
|
||||
StateBag
|
||||
StaticPartialCachingControl
|
||||
TagPrefixAttribute
|
||||
TemplateBuilder
|
||||
TemplateContainerAttribute
|
||||
TemplateControl
|
||||
TemplateControlParser
|
||||
ToolboxDataAttribute
|
||||
UserControl
|
||||
ValidationPropertyAttribute
|
||||
ValidatorCollection
|
||||
WebServiceProvider
|
||||
@@ -1,37 +0,0 @@
|
||||
Microsoft.CSharp/CodeGeneratorFromCompileUnitTest.cs
|
||||
Microsoft.CSharp/CodeGeneratorFromExpressionTest.cs
|
||||
Microsoft.CSharp/CodeGeneratorFromNamespaceTest.cs
|
||||
Microsoft.CSharp/CodeGeneratorFromStatementTest.cs
|
||||
Microsoft.CSharp/CodeGeneratorFromTypeTest.cs
|
||||
Microsoft.CSharp/CodeGeneratorTestBase.cs
|
||||
System/UriBuilderTest.cs
|
||||
System/UriTest.cs
|
||||
System.Collections.Specialized/BasicOperationsTest.cs
|
||||
System.Collections.Specialized/BitVector32Test.cs
|
||||
System.Collections.Specialized/HybridDictionaryTest.cs
|
||||
System.Collections.Specialized/ListDictionaryTest.cs
|
||||
System.Collections.Specialized/NameValueCollectionTest.cs
|
||||
System.Collections.Specialized/StringCollectionTest.cs
|
||||
System.ComponentModel/EventHandlerListTests.cs
|
||||
System.Diagnostics/TraceTest.cs
|
||||
System.Diagnostics/SwitchesTest.cs
|
||||
System.Diagnostics/DiagnosticsConfigurationHandlerTest.cs
|
||||
System.Net/CookieCollectionTest.cs
|
||||
System.Net/CookieTest.cs
|
||||
System.Net/CredentialCacheTest.cs
|
||||
System.Net/DnsTest.cs
|
||||
System.Net/FileWebRequestTest.cs
|
||||
System.Net/HttpWebRequestTest.cs
|
||||
System.Net/IPAddressTest.cs
|
||||
System.Net/IPEndPointTest.cs
|
||||
System.Net/ServicePointManagerTest.cs
|
||||
System.Net/ServicePointTest.cs
|
||||
System.Net/SocketPermissionTest.cs
|
||||
System.Net/WebHeaderCollectionTest.cs
|
||||
System.Net/WebProxyTest.cs
|
||||
System.Net/WebRequestTest.cs
|
||||
System.Net.Sockets/TcpClientTest.cs
|
||||
System.Net.Sockets/TcpListenerTest.cs
|
||||
System.Text.RegularExpressions/PerlTest.cs
|
||||
System.Text.RegularExpressions/PerlTrials.cs
|
||||
System.Text.RegularExpressions/RegexTrial.cs
|
||||
@@ -0,0 +1,25 @@
|
||||
Assembly.cs
|
||||
AssemblyNameFlags.cs
|
||||
BindingFlags.cs
|
||||
CallingConventions.cs
|
||||
ConstructorInfo.cs
|
||||
DefaultMemberAttribute.cs
|
||||
EventAttributes.cs
|
||||
EventInfo.cs
|
||||
FieldAttributes.cs
|
||||
FieldInfo.cs
|
||||
ICustomAttributeProvider.cs
|
||||
MemberFilter.cs
|
||||
MemberInfo.cs
|
||||
MemberTypes.cs
|
||||
MethodAttributes.cs
|
||||
MethodBase.cs
|
||||
MethodImplAttributes.cs
|
||||
MethodInfo.cs
|
||||
Module.cs
|
||||
ParameterAttributes.cs
|
||||
PropertyAttributes.cs
|
||||
PropertyInfo.cs
|
||||
ResourceAttributes.cs
|
||||
ResourceLocation.cs
|
||||
TypeAttributes.cs
|
||||
@@ -1,246 +0,0 @@
|
||||
System.Object
|
||||
System.Exception
|
||||
System.ValueType
|
||||
System.Delegate
|
||||
System.MulticastDelegate
|
||||
System.Enum
|
||||
System.Activator
|
||||
System.ArgIterator
|
||||
System.__ComObject
|
||||
System.TypedReference
|
||||
System.Security.AllowPartiallyTrustedCallersAttribute
|
||||
System.Runtime.Serialization.Formatter
|
||||
System.Runtime.Serialization.FormatterConverter
|
||||
System.Runtime.Serialization.FormatterServices
|
||||
System.Runtime.Serialization.ObjectIDGenerator
|
||||
System.Runtime.Serialization.ObjectManager
|
||||
System.Reflection.ModuleResolveEventHandler
|
||||
System.Reflection.Pointer
|
||||
System.Globalization.CompareInfo
|
||||
System.Globalization.HebrewCalendar
|
||||
System.Globalization.HijriCalendar
|
||||
System.Globalization.JapaneseCalendar
|
||||
System.Globalization.KoreanCalendar
|
||||
System.Globalization.SortKey
|
||||
System.Globalization.StringInfo
|
||||
System.Globalization.TaiwanCalendar
|
||||
System.Globalization.TextElementEnumerator
|
||||
System.Globalization.TextInfo
|
||||
System.Globalization.ThaiBuddhistCalendar
|
||||
System.IO.IsolatedStorage.IsolatedStorageFile
|
||||
System.Reflection.Emit.MethodRental
|
||||
System.Runtime.CompilerServices.AccessedThroughPropertyAttribute
|
||||
System.Runtime.CompilerServices.CallConvCdecl
|
||||
System.Runtime.CompilerServices.CallConvStdcall
|
||||
System.Runtime.CompilerServices.CallConvThiscall
|
||||
System.Runtime.CompilerServices.CallConvFastcall
|
||||
System.Runtime.CompilerServices.CustomConstantAttribute
|
||||
System.Runtime.CompilerServices.DateTimeConstantAttribute
|
||||
System.Runtime.CompilerServices.DiscardableAttribute
|
||||
System.Runtime.CompilerServices.DecimalConstantAttribute
|
||||
System.Runtime.CompilerServices.CompilationRelaxationsAttribute
|
||||
System.Runtime.CompilerServices.CompilerGlobalScopeAttribute
|
||||
System.Runtime.CompilerServices.IDispatchConstantAttribute
|
||||
System.Runtime.CompilerServices.IsVolatile
|
||||
System.Runtime.CompilerServices.IUnknownConstantAttribute
|
||||
System.Runtime.CompilerServices.RequiredAttributeAttribute
|
||||
System.Runtime.InteropServices.ArrayWithOffset
|
||||
System.Runtime.InteropServices.DispIdAttribute
|
||||
System.Runtime.InteropServices.ClassInterfaceType
|
||||
System.Runtime.InteropServices.ClassInterfaceAttribute
|
||||
System.Runtime.InteropServices.ComVisibleAttribute
|
||||
System.Runtime.InteropServices.LCIDConversionAttribute
|
||||
System.Runtime.InteropServices.ComRegisterFunctionAttribute
|
||||
System.Runtime.InteropServices.ComUnregisterFunctionAttribute
|
||||
System.Runtime.InteropServices.ProgIdAttribute
|
||||
System.Runtime.InteropServices.ImportedFromTypeLibAttribute
|
||||
System.Runtime.InteropServices.IDispatchImplType
|
||||
System.Runtime.InteropServices.IDispatchImplAttribute
|
||||
System.Runtime.InteropServices.ComSourceInterfacesAttribute
|
||||
System.Runtime.InteropServices.ComConversionLossAttribute
|
||||
System.Runtime.InteropServices.TypeLibTypeFlags
|
||||
System.Runtime.InteropServices.TypeLibFuncFlags
|
||||
System.Runtime.InteropServices.TypeLibVarFlags
|
||||
System.Runtime.InteropServices.TypeLibTypeAttribute
|
||||
System.Runtime.InteropServices.TypeLibFuncAttribute
|
||||
System.Runtime.InteropServices.TypeLibVarAttribute
|
||||
System.Runtime.InteropServices.ComImportAttribute
|
||||
System.Runtime.InteropServices.PreserveSigAttribute
|
||||
System.Runtime.InteropServices.ComAliasNameAttribute
|
||||
System.Runtime.InteropServices.AutomationProxyAttribute
|
||||
System.Runtime.InteropServices.PrimaryInteropAssemblyAttribute
|
||||
System.Runtime.InteropServices.CoClassAttribute
|
||||
System.Runtime.InteropServices.ComEventInterfaceAttribute
|
||||
System.Runtime.InteropServices.COMException
|
||||
System.Runtime.InteropServices.ComMemberType
|
||||
System.Runtime.InteropServices.CurrencyWrapper
|
||||
System.Runtime.InteropServices.DispatchWrapper
|
||||
System.Runtime.InteropServices.ErrorWrapper
|
||||
System.Runtime.InteropServices.ExtensibleClassFactory
|
||||
System.Runtime.InteropServices.HandleRef
|
||||
System.Runtime.InteropServices.InvalidComObjectException
|
||||
System.Runtime.InteropServices.InvalidOleVariantTypeException
|
||||
System.Runtime.InteropServices.TypeLibImporterFlags
|
||||
System.Runtime.InteropServices.ExporterEventKind
|
||||
System.Runtime.InteropServices.ITypeLibExporterNotifySink
|
||||
System.Runtime.InteropServices.ITypeLibConverter
|
||||
System.Runtime.InteropServices.MarshalDirectiveException
|
||||
System.Runtime.InteropServices.ObjectCreationDelegate
|
||||
System.Runtime.InteropServices.RuntimeEnvironment
|
||||
System.Runtime.InteropServices.RegistrationServices
|
||||
System.Runtime.InteropServices.SafeArrayRankMismatchException
|
||||
System.Runtime.InteropServices.SafeArrayTypeMismatchException
|
||||
System.Runtime.InteropServices.SEHException
|
||||
System.Runtime.InteropServices.TypeLibConverter
|
||||
System.Runtime.InteropServices.BIND_OPTS
|
||||
System.Runtime.InteropServices.UCOMIBindCtx
|
||||
System.Runtime.InteropServices.UCOMIConnectionPointContainer
|
||||
System.Runtime.InteropServices.UCOMIConnectionPoint
|
||||
System.Runtime.InteropServices.UCOMIEnumMoniker
|
||||
System.Runtime.InteropServices.CONNECTDATA
|
||||
System.Runtime.InteropServices.UCOMIEnumConnections
|
||||
System.Runtime.InteropServices.UCOMIEnumConnectionPoints
|
||||
System.Runtime.InteropServices.UCOMIEnumString
|
||||
System.Runtime.InteropServices.UCOMIEnumVARIANT
|
||||
System.Runtime.InteropServices.FILETIME
|
||||
System.Runtime.InteropServices.UCOMIMoniker
|
||||
System.Runtime.InteropServices.UCOMIPersistFile
|
||||
System.Runtime.InteropServices.UCOMIRunningObjectTable
|
||||
System.Runtime.InteropServices.STATSTG
|
||||
System.Runtime.InteropServices.UCOMIStream
|
||||
System.Runtime.InteropServices.DESCKIND
|
||||
System.Runtime.InteropServices.BINDPTR
|
||||
System.Runtime.InteropServices.UCOMITypeComp
|
||||
System.Runtime.InteropServices.TYPEKIND
|
||||
System.Runtime.InteropServices.TYPEFLAGS
|
||||
System.Runtime.InteropServices.IMPLTYPEFLAGS
|
||||
System.Runtime.InteropServices.TYPEATTR
|
||||
System.Runtime.InteropServices.FUNCDESC
|
||||
System.Runtime.InteropServices.IDLFLAG
|
||||
System.Runtime.InteropServices.IDLDESC
|
||||
System.Runtime.InteropServices.PARAMFLAG
|
||||
System.Runtime.InteropServices.PARAMDESC
|
||||
System.Runtime.InteropServices.TYPEDESC
|
||||
System.Runtime.InteropServices.ELEMDESC
|
||||
System.Runtime.InteropServices.VARDESC
|
||||
System.Runtime.InteropServices.DISPPARAMS
|
||||
System.Runtime.InteropServices.EXCEPINFO
|
||||
System.Runtime.InteropServices.FUNCKIND
|
||||
System.Runtime.InteropServices.INVOKEKIND
|
||||
System.Runtime.InteropServices.CALLCONV
|
||||
System.Runtime.InteropServices.FUNCFLAGS
|
||||
System.Runtime.InteropServices.VARFLAGS
|
||||
System.Runtime.InteropServices.UCOMITypeInfo
|
||||
System.Runtime.InteropServices.SYSKIND
|
||||
System.Runtime.InteropServices.LIBFLAGS
|
||||
System.Runtime.InteropServices.TYPELIBATTR
|
||||
System.Runtime.InteropServices.UCOMITypeLib
|
||||
System.Runtime.InteropServices.UnknownWrapper
|
||||
System.Runtime.Remoting.IObjectHandle
|
||||
System.Runtime.Remoting.IRemotingTypeInfo
|
||||
System.Runtime.Remoting.IChannelInfo
|
||||
System.Runtime.Remoting.IEnvoyInfo
|
||||
System.Runtime.Remoting.RemotingConfiguration
|
||||
System.Runtime.Remoting.TypeEntry
|
||||
System.Runtime.Remoting.ActivatedClientTypeEntry
|
||||
System.Runtime.Remoting.ActivatedServiceTypeEntry
|
||||
System.Runtime.Remoting.WellKnownClientTypeEntry
|
||||
System.Runtime.Remoting.WellKnownServiceTypeEntry
|
||||
System.Runtime.Remoting.RemotingException
|
||||
System.Runtime.Remoting.ServerException
|
||||
System.Runtime.Remoting.RemotingTimeoutException
|
||||
System.Runtime.Remoting.RemotingServices
|
||||
System.Runtime.Remoting.InternalRemotingServices
|
||||
System.Runtime.Remoting.SoapServices
|
||||
System.Runtime.Remoting.Activation.UrlAttribute
|
||||
System.Runtime.Remoting.Messaging.IMessageSink
|
||||
System.Runtime.Remoting.Messaging.AsyncResult
|
||||
System.Runtime.Remoting.Messaging.CallContext
|
||||
System.Runtime.Remoting.Messaging.ILogicalThreadAffinative
|
||||
System.Runtime.Remoting.Messaging.InternalMessageWrapper
|
||||
System.Runtime.Remoting.Messaging.IMethodCallMessage
|
||||
System.Runtime.Remoting.Messaging.MethodCallMessageWrapper
|
||||
System.Runtime.Remoting.Messaging.HeaderHandler
|
||||
System.Runtime.Remoting.Messaging.IMessageCtrl
|
||||
System.Runtime.Remoting.Messaging.IRemotingFormatter
|
||||
System.Runtime.Remoting.Messaging.ReturnMessage
|
||||
System.Runtime.Remoting.Messaging.MethodCall
|
||||
System.Runtime.Remoting.Messaging.ConstructionCall
|
||||
System.Runtime.Remoting.Messaging.MethodResponse
|
||||
System.Runtime.Remoting.Messaging.ConstructionResponse
|
||||
System.Runtime.Remoting.Messaging.MethodReturnMessageWrapper
|
||||
System.Runtime.Remoting.Messaging.OneWayAttribute
|
||||
System.Runtime.Remoting.Messaging.MessageSurrogateFilter
|
||||
System.Runtime.Remoting.Messaging.RemotingSurrogateSelector
|
||||
System.Runtime.Remoting.Contexts.CrossContextDelegate
|
||||
System.Runtime.Remoting.Contexts.ContextProperty
|
||||
System.Runtime.Remoting.Contexts.IContextPropertyActivator
|
||||
System.Runtime.Remoting.Contexts.IContributeClientContextSink
|
||||
System.Runtime.Remoting.Contexts.IContributeDynamicSink
|
||||
System.Runtime.Remoting.Contexts.IContributeEnvoySink
|
||||
System.Runtime.Remoting.Contexts.IContributeObjectSink
|
||||
System.Runtime.Remoting.Contexts.IContributeServerContextSink
|
||||
System.Runtime.Serialization.Formatters.InternalRM
|
||||
System.Runtime.Serialization.Formatters.InternalST
|
||||
System.Runtime.Serialization.Formatters.SoapMessage
|
||||
System.Runtime.Serialization.Formatters.SoapFault
|
||||
System.Runtime.Serialization.Formatters.ServerFault
|
||||
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
System.Security.Cryptography.CryptoConfig
|
||||
System.Security.Cryptography.KeyedHashAlgorithm
|
||||
System.Security.Cryptography.HMACSHA1
|
||||
System.Security.Cryptography.MACTripleDES
|
||||
System.Security.Cryptography.MaskGenerationMethod
|
||||
System.Security.Cryptography.PasswordDeriveBytes
|
||||
System.Security.Cryptography.PKCS1MaskGenerationMethod
|
||||
System.Security.Cryptography.RC2
|
||||
System.Security.Cryptography.RC2CryptoServiceProvider
|
||||
System.Security.Cryptography.RSACryptoServiceProvider
|
||||
System.Security.Cryptography.RSAOAEPKeyExchangeDeformatter
|
||||
System.Security.Cryptography.RSAOAEPKeyExchangeFormatter
|
||||
System.Security.Cryptography.RSAPKCS1KeyExchangeDeformatter
|
||||
System.Security.Cryptography.RSAPKCS1KeyExchangeFormatter
|
||||
System.Security.Cryptography.RSAPKCS1SignatureDeformatter
|
||||
System.Security.Cryptography.RSAPKCS1SignatureFormatter
|
||||
System.Security.Cryptography.SHA1Managed
|
||||
System.Security.Cryptography.TripleDES
|
||||
System.Security.Cryptography.TripleDESCryptoServiceProvider
|
||||
System.Security.Permissions.EnvironmentPermission
|
||||
System.Security.Permissions.FileDialogPermission
|
||||
System.Security.Permissions.IsolatedStorageFilePermission
|
||||
System.Security.Permissions.PrincipalPermissionAttribute
|
||||
System.Security.Permissions.SecurityPermissionAttribute
|
||||
System.Security.Permissions.PublisherIdentityPermissionAttribute
|
||||
System.Security.Permissions.PublisherIdentityPermission
|
||||
System.Security.Permissions.ReflectionPermission
|
||||
System.Security.Permissions.RegistryPermission
|
||||
System.Security.Permissions.PrincipalPermission
|
||||
System.Security.Permissions.SiteIdentityPermission
|
||||
System.Security.Permissions.StrongNameIdentityPermission
|
||||
System.Security.Permissions.StrongNamePublicKeyBlob
|
||||
System.Security.Permissions.UIPermission
|
||||
System.Security.Permissions.UrlIdentityPermission
|
||||
System.Security.Permissions.ZoneIdentityPermission
|
||||
System.Security.Policy.ApplicationDirectory
|
||||
System.Security.Policy.ApplicationDirectoryMembershipCondition
|
||||
System.Security.Policy.FirstMatchCodeGroup
|
||||
System.Security.Policy.Hash
|
||||
System.Security.Policy.HashMembershipCondition
|
||||
System.Security.Policy.NetCodeGroup
|
||||
System.Security.Policy.PermissionRequestEvidence
|
||||
System.Security.Policy.Publisher
|
||||
System.Security.Policy.PublisherMembershipCondition
|
||||
System.Security.Policy.Site
|
||||
System.Security.Policy.SiteMembershipCondition
|
||||
System.Security.Policy.StrongName
|
||||
System.Security.Policy.StrongNameMembershipCondition
|
||||
System.Security.Policy.UnionCodeGroup
|
||||
System.Security.Policy.Url
|
||||
System.Security.Policy.UrlMembershipCondition
|
||||
System.Security.Policy.Zone
|
||||
System.Security.Policy.ZoneMembershipCondition
|
||||
System.Security.Principal.WindowsIdentity
|
||||
System.Security.Principal.WindowsImpersonationContext
|
||||
System.Security.Principal.WindowsPrincipal
|
||||
System.Threading.CompressedStack
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
Currently you can read our plans for <a
|
||||
href="ado-net.html">ADO.NET</a>, <a
|
||||
href="asp-net.html">ASP.NET</a>, <a href="java.html">Java</a> and
|
||||
href="asp-net">ASP.NET</a>, <a href="java.html">Java</a> and
|
||||
<a href="winforms.html">WinForms</a>.
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -82,7 +82,7 @@
|
||||
{
|
||||
string connectionString = "URI=file:SqliteTest.db";
|
||||
IDbConnection dbcon;
|
||||
dbcon = new SqliteConnection(connectionString);
|
||||
dbcon = new MySQLConnection(connectionString);
|
||||
dbcon.Open();
|
||||
IDbCommand dbcmd = dbcon.CreateCommand();
|
||||
// requires a table to be created named employee
|
||||
|
||||
Reference in new issue
Block a user