Skip to content

Commit ea2c6d4

Browse files
committed
NH-4008 - Driver code formatting tweaks.
Spaces to tabs. Use static private methods where possible.
1 parent 6619d67 commit ea2c6d4

File tree

6 files changed

+51
-123
lines changed

6 files changed

+51
-123
lines changed

src/NHibernate/Driver/FirebirdClientDriver.cs

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ public class FirebirdClientDriver : ReflectionBasedDriver
2020
{
2121
private const string SELECT_CLAUSE_EXP = @"(?<=\bselect|\bwhere).*";
2222
private const string CAST_PARAMS_EXP = @"(?<![=<>]\s?|first\s?|skip\s?|between\s|between\s@\bp\w+\b\sand\s)@\bp\w+\b(?!\s?[=<>])";
23-
private readonly Regex _statementRegEx = new Regex(SELECT_CLAUSE_EXP, RegexOptions.IgnoreCase);
24-
private readonly Regex _castCandidateRegEx = new Regex(CAST_PARAMS_EXP, RegexOptions.IgnoreCase);
23+
private static readonly Regex _statementRegEx = new Regex(SELECT_CLAUSE_EXP, RegexOptions.IgnoreCase);
24+
private static readonly Regex _castCandidateRegEx = new Regex(CAST_PARAMS_EXP, RegexOptions.IgnoreCase);
2525
private readonly FirebirdDialect _fbDialect = new FirebirdDialect();
2626

2727
/// <summary>
@@ -37,7 +37,6 @@ public FirebirdClientDriver()
3737
"FirebirdSql.Data.FirebirdClient.FbConnection",
3838
"FirebirdSql.Data.FirebirdClient.FbCommand")
3939
{
40-
4140
}
4241

4342
public override void Configure(IDictionary<string, string> settings)
@@ -46,20 +45,11 @@ public override void Configure(IDictionary<string, string> settings)
4645
_fbDialect.Configure(settings);
4746
}
4847

49-
public override bool UseNamedPrefixInSql
50-
{
51-
get { return true; }
52-
}
48+
public override bool UseNamedPrefixInSql => true;
5349

54-
public override bool UseNamedPrefixInParameter
55-
{
56-
get { return true; }
57-
}
50+
public override bool UseNamedPrefixInParameter => true;
5851

59-
public override string NamedPrefix
60-
{
61-
get { return "@"; }
62-
}
52+
public override string NamedPrefix => "@";
6353

6454
protected override void InitializeParameter(DbParameter dbParam, string name, SqlType sqlType)
6555
{
@@ -96,7 +86,7 @@ private string GetStatementsWithCastCandidates(string commandText)
9686
return _statementRegEx.Match(commandText).Value;
9787
}
9888

99-
private HashSet<string> GetCastCandidates(string statement)
89+
private static HashSet<string> GetCastCandidates(string statement)
10090
{
10191
var candidates =
10292
_castCandidateRegEx

src/NHibernate/Driver/MySqlDataDriver.cs

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -36,35 +36,23 @@ public MySqlDataDriver() : base(
3636
/// MySql.Data uses named parameters in the sql.
3737
/// </summary>
3838
/// <value><see langword="true" /> - MySql uses <c>?</c> in the sql.</value>
39-
public override bool UseNamedPrefixInSql
40-
{
41-
get { return true; }
42-
}
39+
public override bool UseNamedPrefixInSql => true;
4340

4441
/// <summary></summary>
45-
public override bool UseNamedPrefixInParameter
46-
{
47-
get { return true; }
48-
}
42+
public override bool UseNamedPrefixInParameter => true;
4943

5044
/// <summary>
5145
/// MySql.Data use the <c>?</c> to locate parameters in sql.
5246
/// </summary>
5347
/// <value><c>?</c> is used to locate parameters in sql.</value>
54-
public override string NamedPrefix
55-
{
56-
get { return "?"; }
57-
}
48+
public override string NamedPrefix => "?";
5849

5950
/// <summary>
6051
/// The MySql.Data driver does NOT support more than 1 open DbDataReader
6152
/// with only 1 DbConnection.
6253
/// </summary>
6354
/// <value><see langword="false" /> - it is not supported.</value>
64-
public override bool SupportsMultipleOpenReaders
65-
{
66-
get { return false; }
67-
}
55+
public override bool SupportsMultipleOpenReaders => false;
6856

6957
/// <summary>
7058
/// MySql.Data does not support preparing of commands.
@@ -74,20 +62,14 @@ public override bool SupportsMultipleOpenReaders
7462
/// With the Gamma MySql.Data provider it is throwing an exception with the
7563
/// message "Expected End of data packet" when a select command is prepared.
7664
/// </remarks>
77-
protected override bool SupportsPreparingCommands
78-
{
79-
get { return false; }
80-
}
65+
protected override bool SupportsPreparingCommands => false;
8166

8267
public override IResultSetsCommand GetResultSetsCommand(Engine.ISessionImplementor session)
8368
{
8469
return new BasicResultSetsCommand(session);
8570
}
8671

87-
public override bool SupportsMultipleQueries
88-
{
89-
get { return true; }
90-
}
72+
public override bool SupportsMultipleQueries => true;
9173

9274
public override bool RequiresTimeSpanForTime => true;
9375

src/NHibernate/Driver/NpgsqlDriver.cs

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -40,31 +40,18 @@ public NpgsqlDriver() : base(
4040
{
4141
}
4242

43-
public override bool UseNamedPrefixInSql
44-
{
45-
get { return true; }
46-
}
43+
public override bool UseNamedPrefixInSql => true;
4744

48-
public override bool UseNamedPrefixInParameter
49-
{
50-
get { return true; }
51-
}
45+
public override bool UseNamedPrefixInParameter => true;
5246

53-
public override string NamedPrefix
54-
{
55-
get { return ":"; }
56-
}
47+
public override string NamedPrefix => ":";
5748

58-
public override bool SupportsMultipleOpenReaders
59-
{
60-
get { return false; }
61-
}
49+
public override bool SupportsMultipleOpenReaders => false;
6250

63-
protected override bool SupportsPreparingCommands
64-
{
65-
// NH-2267 Patrick Earl
66-
get { return true; }
67-
}
51+
/// <remarks>
52+
/// NH-2267 Patrick Earl
53+
/// </remarks>
54+
protected override bool SupportsPreparingCommands => true;
6855

6956
public override bool SupportsNullEnlistment => false;
7057

@@ -73,10 +60,7 @@ public override IResultSetsCommand GetResultSetsCommand(Engine.ISessionImplement
7360
return new BasicResultSetsCommand(session);
7461
}
7562

76-
public override bool SupportsMultipleQueries
77-
{
78-
get { return true; }
79-
}
63+
public override bool SupportsMultipleQueries => true;
8064

8165
protected override void InitializeParameter(DbParameter dbParam, string name, SqlTypes.SqlType sqlType)
8266
{

src/NHibernate/Driver/OracleDataClientDriverBase.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using System.Collections.Generic;
33
using System.Data;
44
using System.Data.Common;
5-
using System.Reflection;
65
using NHibernate.AdoNet;
76
using NHibernate.Engine.Query;
87
using NHibernate.SqlTypes;

src/NHibernate/Driver/SQLite20Driver.cs

Lines changed: 26 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -35,58 +35,43 @@ public SQLite20Driver() : base(
3535
{
3636
}
3737

38-
public override DbConnection CreateConnection()
39-
{
40-
var connection = base.CreateConnection();
41-
connection.StateChange += Connection_StateChange;
42-
return connection;
43-
}
44-
45-
private static void Connection_StateChange(object sender, StateChangeEventArgs e)
46-
{
47-
if ((e.OriginalState == ConnectionState.Broken || e.OriginalState == ConnectionState.Closed || e.OriginalState == ConnectionState.Connecting) &&
48-
e.CurrentState == ConnectionState.Open)
49-
{
50-
var connection = (DbConnection)sender;
51-
using (var command = connection.CreateCommand())
52-
{
53-
// Activated foreign keys if supported by SQLite. Unknown pragmas are ignored.
54-
command.CommandText = "PRAGMA foreign_keys = ON";
55-
command.ExecuteNonQuery();
56-
}
57-
}
58-
}
59-
60-
public override bool UseNamedPrefixInSql
61-
{
62-
get { return true; }
63-
}
64-
65-
public override bool UseNamedPrefixInParameter
66-
{
67-
get { return true; }
68-
}
69-
70-
public override string NamedPrefix
38+
public override DbConnection CreateConnection()
7139
{
72-
get { return "@"; }
40+
var connection = base.CreateConnection();
41+
connection.StateChange += Connection_StateChange;
42+
return connection;
7343
}
7444

75-
public override bool SupportsMultipleOpenReaders
45+
private static void Connection_StateChange(object sender, StateChangeEventArgs e)
7646
{
77-
get { return false; }
47+
if ((e.OriginalState == ConnectionState.Broken || e.OriginalState == ConnectionState.Closed || e.OriginalState == ConnectionState.Connecting) &&
48+
e.CurrentState == ConnectionState.Open)
49+
{
50+
var connection = (DbConnection)sender;
51+
using (var command = connection.CreateCommand())
52+
{
53+
// Activated foreign keys if supported by SQLite. Unknown pragmas are ignored.
54+
command.CommandText = "PRAGMA foreign_keys = ON";
55+
command.ExecuteNonQuery();
56+
}
57+
}
7858
}
7959

8060
public override IResultSetsCommand GetResultSetsCommand(Engine.ISessionImplementor session)
8161
{
8262
return new BasicResultSetsCommand(session);
8363
}
8464

85-
public override bool SupportsMultipleQueries
86-
{
87-
get { return true; }
88-
}
89-
65+
public override bool UseNamedPrefixInSql => true;
66+
67+
public override bool UseNamedPrefixInParameter => true;
68+
69+
public override string NamedPrefix => "@";
70+
71+
public override bool SupportsMultipleOpenReaders => false;
72+
73+
public override bool SupportsMultipleQueries => true;
74+
9075
public override bool SupportsNullEnlistment => false;
9176

9277
public override bool HasDelayedDistributedTransactionCompletion => true;

src/NHibernate/Driver/SqlServerCeDriver.cs

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,32 +42,23 @@ public override void Configure(IDictionary<string, string> settings)
4242
/// <remarks>
4343
/// <see langword="true" /> because MsSql uses "<c>@</c>".
4444
/// </remarks>
45-
public override bool UseNamedPrefixInSql
46-
{
47-
get { return true; }
48-
}
45+
public override bool UseNamedPrefixInSql => true;
4946

5047
/// <summary>
5148
/// MsSql requires the use of a Named Prefix in the Parameter.
5249
/// </summary>
5350
/// <remarks>
5451
/// <see langword="true" /> because MsSql uses "<c>@</c>".
5552
/// </remarks>
56-
public override bool UseNamedPrefixInParameter
57-
{
58-
get { return true; }
59-
}
53+
public override bool UseNamedPrefixInParameter => true;
6054

6155
/// <summary>
6256
/// The Named Prefix for parameters.
6357
/// </summary>
6458
/// <value>
6559
/// Sql Server uses <c>"@"</c>.
6660
/// </value>
67-
public override string NamedPrefix
68-
{
69-
get { return "@"; }
70-
}
61+
public override string NamedPrefix => "@";
7162

7263
/// <summary>
7364
/// The SqlClient driver does NOT support more than 1 open DbDataReader
@@ -79,10 +70,7 @@ public override string NamedPrefix
7970
/// attempted to be Opened. When Yukon comes out a new Driver will be
8071
/// created for Yukon because it is supposed to support it.
8172
/// </remarks>
82-
public override bool SupportsMultipleOpenReaders
83-
{
84-
get { return false; }
85-
}
73+
public override bool SupportsMultipleOpenReaders => false;
8674

8775
protected override void SetCommandTimeout(DbCommand cmd)
8876
{

0 commit comments

Comments
 (0)