Skip to content

Commit 0d18cd7

Browse files
committed
Driver code formatting tweaks.
Spaces to tabs. Use static private methods where possible.
1 parent 877136c commit 0d18cd7

6 files changed

+51
-123
lines changed

src/NHibernate/Driver/FirebirdClientDriver.cs

+6-16
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

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

4542
/// <summary></summary>
46-
public override bool UseNamedPrefixInParameter
47-
{
48-
get { return true; }
49-
}
43+
public override bool UseNamedPrefixInParameter => true;
5044

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

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

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

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

88-
public override bool SupportsMultipleQueries
89-
{
90-
get { return true; }
91-
}
73+
public override bool SupportsMultipleQueries => true;
9274

9375
public override bool RequiresTimeSpanForTime => true;
9476

src/NHibernate/Driver/NpgsqlDriver.cs

+9-25
Original file line numberDiff line numberDiff line change
@@ -41,31 +41,18 @@ public NpgsqlDriver() : base(
4141
{
4242
}
4343

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

49-
public override bool UseNamedPrefixInParameter
50-
{
51-
get { return true; }
52-
}
46+
public override bool UseNamedPrefixInParameter => true;
5347

54-
public override string NamedPrefix
55-
{
56-
get { return ":"; }
57-
}
48+
public override string NamedPrefix => ":";
5849

59-
public override bool SupportsMultipleOpenReaders
60-
{
61-
get { return false; }
62-
}
50+
public override bool SupportsMultipleOpenReaders => false;
6351

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

7057
public override bool SupportsNullEnlistment => false;
7158

@@ -74,10 +61,7 @@ public override IResultSetsCommand GetResultSetsCommand(Engine.ISessionImplement
7461
return new BasicResultSetsCommand(session);
7562
}
7663

77-
public override bool SupportsMultipleQueries
78-
{
79-
get { return true; }
80-
}
64+
public override bool SupportsMultipleQueries => true;
8165

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

src/NHibernate/Driver/OracleDataClientDriverBase.cs

-1
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

+26-41
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

+4-16
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)