|
From: <fab...@us...> - 2010-08-14 16:00:05
|
Revision: 5141
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5141&view=rev
Author: fabiomaulo
Date: 2010-08-14 15:59:58 +0000 (Sat, 14 Aug 2010)
Log Message:
-----------
Refactoring
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Driver/ReflectionBasedDriver.cs
trunk/nhibernate/src/NHibernate/NHibernate.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate/Driver/IDriveConnectionCommandProvider.cs
trunk/nhibernate/src/NHibernate/Driver/ReflectionDriveConnectionCommandProvider.cs
Added: trunk/nhibernate/src/NHibernate/Driver/IDriveConnectionCommandProvider.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Driver/IDriveConnectionCommandProvider.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Driver/IDriveConnectionCommandProvider.cs 2010-08-14 15:59:58 UTC (rev 5141)
@@ -0,0 +1,10 @@
+using System.Data;
+
+namespace NHibernate.Driver
+{
+ public interface IDriveConnectionCommandProvider
+ {
+ IDbConnection CreateConnection();
+ IDbCommand CreateCommand();
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Driver/ReflectionBasedDriver.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Driver/ReflectionBasedDriver.cs 2010-08-11 16:08:53 UTC (rev 5140)
+++ trunk/nhibernate/src/NHibernate/Driver/ReflectionBasedDriver.cs 2010-08-14 15:59:58 UTC (rev 5141)
@@ -5,8 +5,7 @@
{
public abstract class ReflectionBasedDriver : DriverBase
{
- private readonly System.Type connectionType;
- private readonly System.Type commandType;
+ private readonly IDriveConnectionCommandProvider connectionCommandProvider;
/// <summary>
/// Initializes a new instance of <see cref="ReflectionBasedDriver" /> with
@@ -18,8 +17,8 @@
protected ReflectionBasedDriver(string driverAssemblyName, string connectionTypeName, string commandTypeName)
{
// Try to get the types from an already loaded assembly
- connectionType = ReflectHelper.TypeFromAssembly(connectionTypeName, driverAssemblyName, false);
- commandType = ReflectHelper.TypeFromAssembly(commandTypeName, driverAssemblyName, false);
+ var connectionType = ReflectHelper.TypeFromAssembly(connectionTypeName, driverAssemblyName, false);
+ var commandType = ReflectHelper.TypeFromAssembly(commandTypeName, driverAssemblyName, false);
if (connectionType == null || commandType == null)
{
@@ -31,16 +30,17 @@
+ "application configuration file to specify the full name of the assembly.",
driverAssemblyName));
}
+ connectionCommandProvider = new ReflectionDriveConnectionCommandProvider(connectionType, commandType);
}
public override IDbConnection CreateConnection()
{
- return (IDbConnection) Cfg.Environment.BytecodeProvider.ObjectsFactory.CreateInstance(connectionType);
+ return connectionCommandProvider.CreateConnection();
}
public override IDbCommand CreateCommand()
{
- return (IDbCommand) Cfg.Environment.BytecodeProvider.ObjectsFactory.CreateInstance(commandType);
+ return connectionCommandProvider.CreateCommand();
}
}
}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate/Driver/ReflectionDriveConnectionCommandProvider.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Driver/ReflectionDriveConnectionCommandProvider.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Driver/ReflectionDriveConnectionCommandProvider.cs 2010-08-14 15:59:58 UTC (rev 5141)
@@ -0,0 +1,40 @@
+using System;
+using System.Data;
+using Environment = NHibernate.Cfg.Environment;
+
+namespace NHibernate.Driver
+{
+ public class ReflectionDriveConnectionCommandProvider : IDriveConnectionCommandProvider
+ {
+ private readonly System.Type commandType;
+ private readonly System.Type connectionType;
+
+ public ReflectionDriveConnectionCommandProvider(System.Type connectionType, System.Type commandType)
+ {
+ if (connectionType == null)
+ {
+ throw new ArgumentNullException("connectionType");
+ }
+ if (commandType == null)
+ {
+ throw new ArgumentNullException("commandType");
+ }
+ this.connectionType = connectionType;
+ this.commandType = commandType;
+ }
+
+ #region IDriveConnectionCommandProvider Members
+
+ public IDbConnection CreateConnection()
+ {
+ return (IDbConnection) Environment.BytecodeProvider.ObjectsFactory.CreateInstance(connectionType);
+ }
+
+ public IDbCommand CreateCommand()
+ {
+ return (IDbCommand) Environment.BytecodeProvider.ObjectsFactory.CreateInstance(commandType);
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2010-08-11 16:08:53 UTC (rev 5140)
+++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2010-08-14 15:59:58 UTC (rev 5141)
@@ -593,8 +593,10 @@
<Compile Include="Dialect\SybaseASA10Dialect.cs" />
<Compile Include="Dialect\SybaseASA9Dialect.cs" />
<Compile Include="Driver\CsharpSqliteDriver.cs" />
+ <Compile Include="Driver\IDriveConnectionCommandProvider.cs" />
<Compile Include="Driver\IfxDriver.cs" />
<Compile Include="Driver\OracleLiteDataClientDriver.cs" />
+ <Compile Include="Driver\ReflectionDriveConnectionCommandProvider.cs" />
<Compile Include="Engine\Query\CallableParser.cs" />
<Compile Include="Engine\Query\HQLExpressionQueryPlan.cs" />
<Compile Include="Engine\Query\HQLStringQueryPlan.cs" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|