| Previous CloneSet | Next CloneSet | Back to Main Report |
| Clone Mass | Clones in CloneSet | Parameter Count | Clone Similarity | Syntax Category [Sequence Length] |
|---|---|---|---|---|
| 72 | 3 | 1 | 0.998 | compilation_unit |
| Clone Abstraction | Parameter Bindings |
| Clone Instance (Click to see clone) | Line Count | Source Line | Source File |
|---|---|---|---|
| 1 | 72 | 1 | src/NHibernate.ByteCode.Castle.Tests/DebugConnectionProvider.cs |
| 2 | 68 | 1 | src/NHibernate.ByteCode.LinFu.Tests/DebugConnectionProvider.cs |
| 3 | 68 | 1 | src/NHibernate.ByteCode.Spring.Tests/DebugConnectionProvider.cs |
| ||||
using System.Collections;
using System.Data;
using Iesi.Collections;
using NHibernate.Connection;
namespace NHibernate.ByteCode.Castle.Tests
{
/// <summary>
/// This connection provider keeps a list of all open connections,
/// it is used when testing to check that tests clean up after themselves.
/// </summary>
public class DebugConnectionProvider : DriverConnectionProvider
{
private readonly ISet connections = new ListSet();
public override IDbConnection GetConnection()
{
IDbConnection connection = base.GetConnection();
connections.Add(connection);
return connection;
}
public override void CloseConnection(IDbConnection conn)
{
base.CloseConnection(conn);
connections.Remove(conn);
}
public bool HasOpenConnections
{
get
{
// check to see if all connections that were at one point opened
// have been closed through the CloseConnection
// method
if (connections.IsEmpty)
{
// there are no connections, either none were opened or
// all of the closings went through CloseConnection.
return false;
}
else
{
// Disposing of an ISession does not call CloseConnection (should it???)
// so a Diposed of ISession will leave an IDbConnection in the list but
// the IDbConnection will be closed (atleast with MsSql it works this way).
foreach (IDbConnection conn in connections)
{
if (conn.State != ConnectionState.Closed)
{
return true;
}
}
// all of the connections have been Disposed and were closed that way
// or they were Closed through the CloseConnection method.
return false;
}
}
}
public void CloseAllConnections()
{
while ( !connections.IsEmpty)
{
IEnumerator en = connections.GetEnumerator();
en.MoveNext();
CloseConnection(en.Current as IDbConnection);
}
}
}
}
|
| ||||
using System.Collections;
using System.Data;
using Iesi.Collections;
using NHibernate.Connection;
namespace NHibernate.ByteCode.LinFu.Tests
{
public class DebugConnectionProvider : DriverConnectionProvider
{
private readonly ISet connections = new ListSet();
public override IDbConnection GetConnection()
{
IDbConnection connection = base.GetConnection();
connections.Add(connection);
return connection;
}
public override void CloseConnection(IDbConnection conn)
{
base.CloseConnection(conn);
connections.Remove(conn);
}
public bool HasOpenConnections
{
get
{
// check to see if all connections that were at one point opened
// have been closed through the CloseConnection
// method
if (connections.IsEmpty)
{
// there are no connections, either none were opened or
// all of the closings went through CloseConnection.
return false;
}
else
{
// Disposing of an ISession does not call CloseConnection (should it???)
// so a Diposed of ISession will leave an IDbConnection in the list but
// the IDbConnection will be closed (atleast with MsSql it works this way).
foreach (IDbConnection conn in connections)
{
if (conn.State != ConnectionState.Closed)
{
return true;
}
}
// all of the connections have been Disposed and were closed that way
// or they were Closed through the CloseConnection method.
return false;
}
}
}
public void CloseAllConnections()
{
while ( !connections.IsEmpty)
{
IEnumerator en = connections.GetEnumerator();
en.MoveNext();
CloseConnection(en.Current as IDbConnection);
}
}
}
}
|
| ||||
using System.Collections;
using System.Data;
using Iesi.Collections;
using NHibernate.Connection;
namespace NHibernate.ByteCode.Spring.Tests
{
public class DebugConnectionProvider : DriverConnectionProvider
{
private readonly ISet connections = new ListSet();
public override IDbConnection GetConnection()
{
IDbConnection connection = base.GetConnection();
connections.Add(connection);
return connection;
}
public override void CloseConnection(IDbConnection conn)
{
base.CloseConnection(conn);
connections.Remove(conn);
}
public bool HasOpenConnections
{
get
{
// check to see if all connections that were at one point opened
// have been closed through the CloseConnection
// method
if (connections.IsEmpty)
{
// there are no connections, either none were opened or
// all of the closings went through CloseConnection.
return false;
}
else
{
// Disposing of an ISession does not call CloseConnection (should it???)
// so a Diposed of ISession will leave an IDbConnection in the list but
// the IDbConnection will be closed (atleast with MsSql it works this way).
foreach (IDbConnection conn in connections)
{
if (conn.State != ConnectionState.Closed)
{
return true;
}
}
// all of the connections have been Disposed and were closed that way
// or they were Closed through the CloseConnection method.
return false;
}
}
}
public void CloseAllConnections()
{
while ( !connections.IsEmpty)
{
IEnumerator en = connections.GetEnumerator();
en.MoveNext();
CloseConnection(en.Current as IDbConnection);
}
}
}
}
|
| |||
using System.Collections;
using System.Data;
using Iesi.Collections;
using NHibernate.Connection;
namespace NHibernate.ByteCode. [[#variable68761b20]].Tests
{
/// <summary>
/// This connection provider keeps a list of all open connections,
/// it is used when testing to check that tests clean up after themselves.
/// </summary>
public class DebugConnectionProvider: DriverConnectionProvider
{
private readonly ISet connections = new ListSet();
public override IDbConnection GetConnection()
{
IDbConnection connection = base.GetConnection();
connections.Add(connection);
return connection;
}
public override void CloseConnection(IDbConnection conn)
{
base.CloseConnection(conn);
connections.Remove(conn);
}
public bool HasOpenConnections
{
get
{
// check to see if all connections that were at one point opened
// have been closed through the CloseConnection
// method
if (connections.IsEmpty)
{
// there are no connections, either none were opened or
// all of the closings went through CloseConnection.
return false;
}
else
{
// Disposing of an ISession does not call CloseConnection (should it???)
// so a Diposed of ISession will leave an IDbConnection in the list but
// the IDbConnection will be closed (atleast with MsSql it works this way).
foreach (IDbConnection conn in connections)
{
if (conn.State != ConnectionState.Closed)
{
return true;
}
}
// all of the connections have been Disposed and were closed that way
// or they were Closed through the CloseConnection method.
return false;
}
}
}
public void CloseAllConnections()
{
while ( !connections.IsEmpty)
{
IEnumerator en = connections.GetEnumerator();
en.MoveNext();
CloseConnection(en.Current as IDbConnection);
}
}
}
}
|
| CloneAbstraction |
| Parameter Index | Clone Instance | Parameter Name | Value |
|---|---|---|---|
| 1 | 1 | [[#68761b20]] | Castle |
| 1 | 2 | [[#68761b20]] | LinFu |
| 1 | 3 | [[#68761b20]] | Spring |