Added:
trunk/Driver/Source/base/DbConnectionStringBuilder.cs
trunk/Driver/Source/base/DbException.cs
trunk/Driver/Source/common/BufferedStream.cs
Log:
New files needed for compilation on .NET CF
Added: trunk/Driver/Source/base/DbConnectionStringBuilder.cs
===================================================================
--- trunk/Driver/Source/base/DbConnectionStringBuilder.cs 2007-02-20 22:20:04 UTC (rev 599)
+++ trunk/Driver/Source/base/DbConnectionStringBuilder.cs 2007-02-20 22:21:33 UTC (rev 600)
@@ -0,0 +1,222 @@
+// Copyright (C) 2004-2006 MySQL AB
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License version 2 as published by
+// the Free Software Foundation
+//
+// There are special exceptions to the terms and conditions of the GPL
+// as it is applied to this software. View the full text of the
+// exception in file EXCEPTIONS in the directory of this software
+// distribution.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+using System;
+using System.Collections;
+using System.ComponentModel;
+
+namespace MySql.Data.MySqlClient
+{
+ public class DbConnectionStringBuilder : IDictionary, ICollection, IEnumerable, ICustomTypeDescriptor
+ {
+ private string connectionString;
+ private Hashtable hash;
+ private bool browsable;
+
+ public DbConnectionStringBuilder()
+ {
+ hash = new Hashtable();
+ browsable = false;
+ }
+
+ #region Properties
+
+ public bool BrowsableConnectionString
+ {
+ get { return browsable; }
+ set { browsable = value; }
+ }
+
+ public string ConnectionString
+ {
+ get { return connectionString; }
+ set { connectionString = value; }
+ }
+
+ public virtual object this[string key]
+ {
+ get { return hash[key]; }
+ set { Add(key, value); }
+ }
+
+ #endregion
+
+ #region IDictionary Members
+
+ public void Add(object key, object value)
+ {
+ hash.Add(key, value);
+ //TODO: update connection string
+ }
+
+ public virtual void Clear()
+ {
+ connectionString = null;
+ hash.Clear();
+ }
+
+ public bool Contains(object key)
+ {
+ return hash.ContainsKey(key);
+ }
+
+ public IDictionaryEnumerator GetEnumerator()
+ {
+ return hash.GetEnumerator();
+ }
+
+ public bool IsFixedSize
+ {
+ get { return false; }
+ }
+
+ public bool IsReadOnly
+ {
+ get { return false; }
+ }
+
+ public ICollection Keys
+ {
+ get { return hash.Keys; }
+ }
+
+ public void Remove(object key)
+ {
+ hash.Remove(key);
+ //TODO: update connection string
+ }
+
+ public ICollection Values
+ {
+ get { return hash.Values; }
+ }
+
+ public object this[object key]
+ {
+ get
+ {
+ return this[(string)key];
+ }
+ set
+ {
+ this[(string)key] = value;
+ }
+ }
+
+ #endregion
+
+ #region ICollection Members
+
+ public void CopyTo(Array array, int index)
+ {
+ hash.CopyTo(array, index);
+ }
+
+ public int Count
+ {
+ get { return hash.Count; }
+ }
+
+ public bool IsSynchronized
+ {
+ get { return hash.IsSynchronized; }
+ }
+
+ public object SyncRoot
+ {
+ get { return hash.SyncRoot; }
+ }
+
+ #endregion
+
+ #region IEnumerable Members
+
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ return hash.GetEnumerator();
+ }
+
+ #endregion
+
+ #region ICustomTypeDescriptor Members
+
+ public AttributeCollection GetAttributes()
+ {
+ throw new Exception("The method or operation is not implemented.");
+ }
+
+ public string GetClassName()
+ {
+ throw new Exception("The method or operation is not implemented.");
+ }
+
+ public string GetComponentName()
+ {
+ throw new Exception("The method or operation is not implemented.");
+ }
+
+ public TypeConverter GetConverter()
+ {
+ throw new Exception("The method or operation is not implemented.");
+ }
+
+ public EventDescriptor GetDefaultEvent()
+ {
+ throw new Exception("The method or operation is not implemented.");
+ }
+
+ public PropertyDescriptor GetDefaultProperty()
+ {
+ throw new Exception("The method or operation is not implemented.");
+ }
+
+ public object GetEditor(Type editorBaseType)
+ {
+ throw new Exception("The method or operation is not implemented.");
+ }
+
+ public EventDescriptorCollection GetEvents(Attribute[] attributes)
+ {
+ throw new Exception("The method or operation is not implemented.");
+ }
+
+ public EventDescriptorCollection GetEvents()
+ {
+ throw new Exception("The method or operation is not implemented.");
+ }
+
+ public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
+ {
+ throw new Exception("The method or operation is not implemented.");
+ }
+
+ public PropertyDescriptorCollection GetProperties()
+ {
+ throw new Exception("The method or operation is not implemented.");
+ }
+
+ public object GetPropertyOwner(PropertyDescriptor pd)
+ {
+ throw new Exception("The method or operation is not implemented.");
+ }
+
+ #endregion
+ }
+}
Added: trunk/Driver/Source/base/DbException.cs
===================================================================
--- trunk/Driver/Source/base/DbException.cs 2007-02-20 22:20:04 UTC (rev 599)
+++ trunk/Driver/Source/base/DbException.cs 2007-02-20 22:21:33 UTC (rev 600)
@@ -0,0 +1,60 @@
+// Copyright (C) 2004-2006 MySQL AB
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License version 2 as published by
+// the Free Software Foundation
+//
+// There are special exceptions to the terms and conditions of the GPL
+// as it is applied to this software. View the full text of the
+// exception in file EXCEPTIONS in the directory of this software
+// distribution.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+using System;
+using System.Runtime.InteropServices;
+
+namespace MySql.Data.MySqlClient
+{
+ public abstract class DbException : ExternalException
+ {
+ private int errorCode;
+
+ public DbException()
+ : base()
+ {
+ }
+
+ public DbException(string message) : base(message)
+ {
+ }
+
+ public DbException(string message, Exception innerException)
+ : base(message, innerException)
+ {
+ }
+
+ public DbException(string message, int errorCode)
+ : base(message)
+ {
+ this.errorCode = errorCode;
+ }
+
+ #region Properties
+
+ public int ErrorCode
+ {
+ get { return errorCode; }
+ }
+
+ #endregion
+
+ }
+}
Added: trunk/Driver/Source/common/BufferedStream.cs
===================================================================
--- trunk/Driver/Source/common/BufferedStream.cs 2007-02-20 22:20:04 UTC (rev 599)
+++ trunk/Driver/Source/common/BufferedStream.cs 2007-02-20 22:21:33 UTC (rev 600)
@@ -0,0 +1,196 @@
+// Copyright (C) 2004-2006 MySQL AB
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License version 2 as published by
+// the Free Software Foundation
+//
+// There are special exceptions to the terms and conditions of the GPL
+// as it is applied to this software. View the full text of the
+// exception in file EXCEPTIONS in the directory of this software
+// distribution.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+using System;
+using System.IO;
+using MySql.Data.MySqlClient;
+
+namespace MySql.Data.Common
+{
+ internal class BufferedStream : Stream
+ {
+ private byte[] writeBuffer;
+ private byte[] readBuffer;
+ private int writePos;
+ private int readLength;
+ private int readPos;
+ private int bufferSize;
+ private Stream baseStream;
+
+ public BufferedStream(Stream stream)
+ {
+ baseStream = stream;
+ bufferSize = 4096;
+ }
+
+ #region Stream Implementation
+
+ public override bool CanRead
+ {
+ get
+ {
+ if (baseStream != null) return baseStream.CanRead;
+ return false;
+ }
+ }
+
+ public override bool CanSeek
+ {
+ get
+ {
+ if (baseStream != null) return baseStream.CanSeek;
+ return false;
+ }
+ }
+
+ public override bool CanWrite
+ {
+ get
+ {
+ if (baseStream != null) return baseStream.CanWrite;
+ return false;
+ }
+ }
+
+ public override void Flush()
+ {
+ if (baseStream == null)
+ throw new InvalidOperationException(Resources.ObjectDisposed);
+ if (writePos == 0) return;
+
+ baseStream.Write(writeBuffer, 0, writePos);
+ baseStream.Flush();
+ writePos = 0;
+ }
+
+ public override long Length
+ {
+ get
+ {
+ if (baseStream == null)
+ throw new InvalidOperationException(Resources.ObjectDisposed);
+ Flush();
+ return baseStream.Length;
+ }
+
+ }
+
+ public override long Position
+ {
+ get
+ {
+ throw new Exception("The method or operation is not implemented.");
+ }
+ set
+ {
+ throw new Exception("The method or operation is not implemented.");
+ }
+ }
+
+ public override int Read(byte[] buffer, int offset, int count)
+ {
+ if (buffer == null)
+ throw new ArgumentNullException("buffer", Resources.ParameterCannotBeNull);
+ if (offset < 0)
+ throw new ArgumentOutOfRangeException("offset", Resources.OffsetCannotBeNegative);
+ if (count < 0)
+ throw new ArgumentOutOfRangeException("count", Resources.CountCannotBeNegative);
+ if ((buffer.Length - offset) < count)
+ throw new ArgumentException(Resources.OffsetMustBeValid);
+ if (baseStream == null)
+ throw new InvalidOperationException(Resources.ObjectDisposed);
+
+ if ((readLength - readPos) == 0)
+ {
+ TryToFillReadBuffer();
+ if (readLength == 0) return 0;
+ }
+
+ int inBuffer = readLength - readPos;
+ int toRead = count;
+ if (toRead > inBuffer)
+ toRead = inBuffer;
+ Buffer.BlockCopy(readBuffer, readPos, buffer, offset, toRead);
+ readPos += toRead;
+ count -= toRead;
+ if (count > 0)
+ {
+ int read = baseStream.Read(buffer, offset + toRead, count);
+ toRead += read;
+ readPos = readLength = 0;
+ }
+ return toRead;
+ }
+
+ private void TryToFillReadBuffer()
+ {
+ int read = baseStream.Read(readBuffer, 0, bufferSize);
+ readPos = 0;
+ readLength = read;
+ }
+
+ public override long Seek(long offset, SeekOrigin origin)
+ {
+ throw new Exception("The method or operation is not implemented.");
+ }
+
+ public override void SetLength(long value)
+ {
+ throw new Exception("The method or operation is not implemented.");
+ }
+
+ public override void Write(byte[] buffer, int offset, int count)
+ {
+ if (buffer == null)
+ throw new ArgumentNullException("buffer", Resources.ParameterCannotBeNull);
+ if (offset < 0)
+ throw new ArgumentOutOfRangeException("offset", Resources.OffsetCannotBeNegative);
+ if (count < 0)
+ throw new ArgumentOutOfRangeException("count", Resources.CountCannotBeNegative);
+ if ((buffer.Length - offset) < count)
+ throw new ArgumentException(Resources.OffsetMustBeValid);
+ if (baseStream == null)
+ throw new InvalidOperationException(Resources.ObjectDisposed);
+
+ // if we have not created our write buffer yet, then do so now
+ if (writeBuffer == null)
+ writeBuffer = new byte[bufferSize];
+
+ // if we don't have enough room in our current write buffer for the data
+ // then flush the data
+ int roomLeft = bufferSize - writePos;
+ if (count > roomLeft)
+ Flush();
+
+ // if the data will not fit into a entire buffer, then there is no need to buffer it.
+ // We just send it down
+ if (count > bufferSize)
+ baseStream.Write(buffer, offset, count);
+
+ // if we get here then there is room in our buffer for the data. We store it and
+ // adjust our internal lengths.
+ Buffer.BlockCopy (buffer, offset, writeBuffer, writePos, count);
+ writePos += count;
+ }
+
+ #endregion
+
+ }
+}
| Thread |
|---|
| • Connector/NET commit: r600 - in trunk/Driver/Source: base common | rburnett | 20 Feb |