/********************************************************
* ADO.NET 2.0 Data Provider for SQLite Version 3.X
* Written by Robert Simpson (robert@blackcastlesoft.com)
*
* Released to the public domain, use at your own risk!
********************************************************/
namespace System.Data.SQLite
{
using System;
using System.Data.Common;
#if !PLATFORM_COMPACTFRAMEWORK
///
/// SQLite implementation of .
///
public sealed partial class SQLiteFactory : DbProviderFactory, IDisposable
{
///
/// Constructs a new instance.
///
public SQLiteFactory()
{
//
// NOTE: Do nothing here now. All the logging setup related code has
// been moved to the new SQLiteLog static class.
//
}
///////////////////////////////////////////////////////////////////////////////////////////////
#region IDisposable Members
///
/// Cleans up resources (native and managed) associated with the current instance.
///
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
#endregion
///////////////////////////////////////////////////////////////////////////////////////////////
#region IDisposable "Pattern" Members
private bool disposed;
private void CheckDisposed() /* throw */
{
#if THROW_ON_DISPOSED
if (disposed)
throw new ObjectDisposedException(typeof(SQLiteFactory).Name);
#endif
}
///////////////////////////////////////////////////////////////////////////////////////////////
private void Dispose(bool disposing)
{
if (!disposed)
{
//if (disposing)
//{
// ////////////////////////////////////
// // dispose managed resources here...
// ////////////////////////////////////
//}
//////////////////////////////////////
// release unmanaged resources here...
//////////////////////////////////////
disposed = true;
}
}
#endregion
///////////////////////////////////////////////////////////////////////////////////////////////
#region Destructor
///
/// Cleans up resources associated with the current instance.
///
~SQLiteFactory()
{
Dispose(false);
}
#endregion
///////////////////////////////////////////////////////////////////////////////////////////////
///
/// This event is raised whenever SQLite raises a logging event.
/// Note that this should be set as one of the first things in the
/// application. This event is provided for backward compatibility only.
/// New code should use the class instead.
///
public event SQLiteLogEventHandler Log
{
add { CheckDisposed(); SQLiteLog.Log += value; }
remove { CheckDisposed(); SQLiteLog.Log -= value; }
}
///
/// Static instance member which returns an instanced class.
///
public static readonly SQLiteFactory Instance = new SQLiteFactory();
///
/// Creates and returns a new object.
///
/// The new object.
public override DbCommand CreateCommand()
{
CheckDisposed();
return new SQLiteCommand();
}
///
/// Creates and returns a new object.
///
/// The new object.
public override DbCommandBuilder CreateCommandBuilder()
{
CheckDisposed();
return new SQLiteCommandBuilder();
}
///
/// Creates and returns a new object.
///
/// The new object.
public override DbConnection CreateConnection()
{
CheckDisposed();
return new SQLiteConnection();
}
///
/// Creates and returns a new object.
///
/// The new object.
public override DbConnectionStringBuilder CreateConnectionStringBuilder()
{
CheckDisposed();
return new SQLiteConnectionStringBuilder();
}
///
/// Creates and returns a new object.
///
/// The new object.
public override DbDataAdapter CreateDataAdapter()
{
CheckDisposed();
return new SQLiteDataAdapter();
}
///
/// Creates and returns a new object.
///
/// The new object.
public override DbParameter CreateParameter()
{
CheckDisposed();
return new SQLiteParameter();
}
}
#endif
}