-
Notifications
You must be signed in to change notification settings - Fork 934
/
Copy pathIConnectionProvider.cs
61 lines (55 loc) · 2.09 KB
/
IConnectionProvider.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
using System;
using System.Collections.Generic;
using System.Data.Common;
using NHibernate.Driver;
using NHibernate.Util;
namespace NHibernate.Connection
{
//6.0 TODO: Merge into IConnectionProvider
public static partial class ConnectionProviderExtensions
{
internal static DbConnection GetConnection(this IConnectionProvider connectionProvider, string connectionString)
{
return ReflectHelper.CastOrThrow<ConnectionProvider>(connectionProvider, "open connection by connectionString").GetConnection(connectionString);
}
//6.0 TODO: Expose as ConnectionString property
public static string GetConnectionString(this IConnectionProvider connectionProvider)
{
return ReflectHelper.CastOrThrow<ConnectionProvider>(connectionProvider, "retrieve connectionString").ConnectionString;
}
}
/// <summary>
/// A strategy for obtaining ADO.NET <see cref="DbConnection"/>.
/// </summary>
/// <remarks>
/// The <c>IConnectionProvider</c> interface is not intended to be exposed to the application.
/// Instead it is used internally by NHibernate to obtain <see cref="DbConnection"/>.
/// Implementors should provide a public default constructor.
/// </remarks>
public partial interface IConnectionProvider : IDisposable
{
/// <summary>
/// Initialize the connection provider from the given properties.
/// </summary>
/// <param name="settings">The connection provider settings</param>
void Configure(IDictionary<string, string> settings);
/// <summary>
/// Dispose of a used <see cref="DbConnection"/>
/// </summary>
/// <param name="conn">The <see cref="DbConnection"/> to clean up.</param>
void CloseConnection(DbConnection conn);
/// <summary>
/// Gets the <see cref="IDriver"/> this ConnectionProvider should use to
/// communicate with the .NET Data Provider
/// </summary>
/// <value>
/// The <see cref="IDriver"/> to communicate with the .NET Data Provider.
/// </value>
IDriver Driver { get; }
/// <summary>
/// Get an open <see cref="DbConnection"/>.
/// </summary>
/// <returns>An open <see cref="DbConnection"/>.</returns>
DbConnection GetConnection();
}
}