Skip to content

Commit 8e92af3

Browse files
committed
Refactoring NET2.0 (generics collections)
SVN: trunk@3223
1 parent 10414a4 commit 8e92af3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+160
-128
lines changed

src/NHibernate.DomainModel/CustomPersister.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ public Cascades.CascadeStyle[] PropertyCascadeStyles
155155
get { return null; }
156156
}
157157

158-
public object[] PropertySpaces
158+
public string[] PropertySpaces
159159
{
160160
get { return new string[] {"CUSTOMS"}; }
161161
}
@@ -418,7 +418,7 @@ public object CreateProxy(object id, ISessionImplementor session)
418418
throw new NotSupportedException("CustomPersister.CreateProxy is not implemented");
419419
}
420420

421-
public object[] QuerySpaces
421+
public string[] QuerySpaces
422422
{
423423
get { return null; }
424424
}

src/NHibernate.Test/NHSpecificTest/EntityKeyFixture.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ public Cascades.CascadeStyle[] PropertyCascadeStyles
184184
}
185185
}
186186

187-
public object[] PropertySpaces
187+
public string[] PropertySpaces
188188
{
189189
get
190190
{
@@ -479,7 +479,7 @@ public object CreateProxy(object id, ISessionImplementor session)
479479
return null;
480480
}
481481

482-
public object[] QuerySpaces
482+
public string[] QuerySpaces
483483
{
484484
get { return null; }
485485
}

src/NHibernate.Test/NHSpecificTest/SetFixture.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ public object ReadIdentifier(IDataReader rs, string alias, ISessionImplementor s
318318
return null;
319319
}
320320

321-
public object CollectionSpace
321+
public string CollectionSpace
322322
{
323323
get
324324
{

src/NHibernate/Action/BulkOperationCleanupAction.cs

+9-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections;
3+
using System.Collections.Generic;
34
using Iesi.Collections;
45
using Iesi.Collections.Generic;
56
using NHibernate.Engine;
@@ -16,12 +17,12 @@ public class BulkOperationCleanupAction: IExecutable
1617
private readonly ISessionImplementor session;
1718
private readonly HashedSet<string> affectedEntityNames= new HashedSet<string>();
1819
private readonly HashedSet affectedCollectionRoles= new HashedSet();
19-
private readonly ArrayList spaces;
20+
private readonly List<string> spaces;
2021

2122
public BulkOperationCleanupAction(ISessionImplementor session, IQueryable[] affectedQueryables)
2223
{
2324
this.session = session;
24-
ArrayList tmpSpaces = new ArrayList();
25+
List<string> tmpSpaces = new List<string>();
2526
for (int i = 0; i < affectedQueryables.Length; i++)
2627
{
2728
if (affectedQueryables[i].HasCache)
@@ -38,25 +39,25 @@ public BulkOperationCleanupAction(ISessionImplementor session, IQueryable[] affe
3839
tmpSpaces.Add(affectedQueryables[i].QuerySpaces[y]);
3940
}
4041
}
41-
spaces = new ArrayList(tmpSpaces);
42+
spaces = new List<string>(tmpSpaces);
4243
}
4344

4445
/// <summary>
4546
/// Create an action that will evict collection and entity regions based on queryspaces (table names).
4647
/// </summary>
47-
public BulkOperationCleanupAction(ISessionImplementor session, ISet querySpaces)
48+
public BulkOperationCleanupAction(ISessionImplementor session, ISet<string> querySpaces)
4849
{
4950
//from H3.2 TODO: cache the autodetected information and pass it in instead.
5051
this.session = session;
5152

52-
ISet tmpSpaces = new HashedSet(querySpaces);
53+
ISet<string> tmpSpaces = new HashedSet<string>(querySpaces);
5354
ISessionFactoryImplementor factory = session.Factory;
5455
IDictionary acmd = factory.GetAllClassMetadata();
5556
foreach (DictionaryEntry entry in acmd)
5657
{
5758
string entityName = ((System.Type) entry.Key).FullName;
5859
IEntityPersister persister = factory.GetEntityPersister(entityName);
59-
object[] entitySpaces = persister.QuerySpaces;
60+
string[] entitySpaces = persister.QuerySpaces;
6061

6162
if (AffectedEntity(querySpaces, entitySpaces))
6263
{
@@ -75,10 +76,10 @@ public BulkOperationCleanupAction(ISessionImplementor session, ISet querySpaces)
7576
}
7677
}
7778
}
78-
spaces = new ArrayList(tmpSpaces);
79+
spaces = new List<string>(tmpSpaces);
7980
}
8081

81-
private bool AffectedEntity(ISet querySpaces, object[] entitySpaces)
82+
private bool AffectedEntity(ISet<string> querySpaces, string[] entitySpaces)
8283
{
8384
if (querySpaces == null || (querySpaces.Count == 0))
8485
{

src/NHibernate/Cache/IQueryCache.cs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
using System;
21
using System.Collections;
3-
using Iesi.Collections;
2+
using Iesi.Collections.Generic;
43
using NHibernate.Engine;
54
using NHibernate.Type;
65

@@ -18,7 +17,7 @@ public interface IQueryCache
1817

1918
void Clear();
2019
bool Put(QueryKey key, ICacheAssembler[] returnTypes, IList result, ISessionImplementor session);
21-
IList Get(QueryKey key, ICacheAssembler[] returnTypes, ISet spaces, ISessionImplementor session);
20+
IList Get(QueryKey key, ICacheAssembler[] returnTypes, ISet<string> spaces, ISessionImplementor session);
2221
void Destroy();
2322
}
2423
}

src/NHibernate/Cache/QueryKey.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,11 @@ public override bool Equals(object other)
132132
return false;
133133
}
134134

135-
if(!CollectionHelper.CollectionEquals(this.multiQueriesFirstRows, that.multiQueriesFirstRows))
135+
if(!CollectionHelper.CollectionEquals<int>(multiQueriesFirstRows, that.multiQueriesFirstRows))
136136
{
137137
return false;
138138
}
139-
if(!CollectionHelper.CollectionEquals(this.multiQueriesMaxRows, that.multiQueriesMaxRows))
139+
if(!CollectionHelper.CollectionEquals<int>(multiQueriesMaxRows, that.multiQueriesMaxRows))
140140
{
141141
return false;
142142
}

src/NHibernate/Cache/StandardQueryCache.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using NHibernate.Cfg;
66
using NHibernate.Engine;
77
using NHibernate.Type;
8+
using Iesi.Collections.Generic;
89

910
namespace NHibernate.Cache
1011
{
@@ -71,7 +72,7 @@ public bool Put(QueryKey key, ICacheAssembler[] returnTypes, IList result, ISess
7172
return true;
7273
}
7374

74-
public IList Get(QueryKey key, ICacheAssembler[] returnTypes, ISet spaces, ISessionImplementor session)
75+
public IList Get(QueryKey key, ICacheAssembler[] returnTypes, ISet<string> spaces, ISessionImplementor session)
7576
{
7677
if (log.IsDebugEnabled)
7778
{
@@ -106,7 +107,7 @@ public IList Get(QueryKey key, ICacheAssembler[] returnTypes, ISet spaces, ISess
106107
return result;
107108
}
108109

109-
protected bool IsUpToDate(ISet spaces, long timestamp)
110+
protected bool IsUpToDate(ISet<string> spaces, long timestamp)
110111
{
111112
return updateTimestampsCache.IsUpToDate(spaces, timestamp);
112113
}

src/NHibernate/Cache/UpdateTimestampsCache.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System;
22
using System.Collections;
33
using System.Runtime.CompilerServices;
4-
using Iesi.Collections;
4+
using Iesi.Collections.Generic;
55
using log4net;
66
using NHibernate.Cfg;
77

@@ -61,9 +61,9 @@ public void Invalidate(object[] spaces)
6161
}
6262

6363
[MethodImpl(MethodImplOptions.Synchronized)]
64-
public bool IsUpToDate(ISet spaces, long timestamp /* H2.1 has Long here */)
64+
public bool IsUpToDate(ISet<string> spaces, long timestamp /* H2.1 has Long here */)
6565
{
66-
foreach (object space in spaces)
66+
foreach (string space in spaces)
6767
{
6868
object lastUpdate = updateTimestamps.Get(space);
6969
if (lastUpdate == null)

src/NHibernate/Cfg/XmlHbmBinding/NamedQueryBinder.cs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System.Collections;
2-
1+
using System.Collections.Generic;
32
using NHibernate.Cfg.MappingSchema;
43
using NHibernate.Engine;
54
using NHibernate.Util;
@@ -39,7 +38,7 @@ public void AddQuery(HbmQuery querySchema)
3938

4039

4140

42-
IDictionary parameterTypes = new SequencedHashMap();
41+
IDictionary<string,string> parameterTypes = new LinkedHashMap<string,string>();
4342

4443
NamedQueryDefinition namedQuery = new NamedQueryDefinition(queryText, cacheable, region, timeout,
4544
fetchSize, flushMode, cacheMode, readOnly, comment, parameterTypes);

src/NHibernate/Cfg/XmlHbmBinding/NamedSQLQueryBinder.cs

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System.Collections;
2-
1+
using System.Collections.Generic;
32
using NHibernate.Cfg.MappingSchema;
43
using NHibernate.Engine;
54
using NHibernate.Util;
@@ -38,8 +37,8 @@ public void AddSqlQuery(HbmSqlQuery querySchema)
3837
? CacheModeConverter.GetCacheMode(querySchema.cachemode)
3938
: null;
4039

41-
IDictionary parameterTypes = new SequencedHashMap();
42-
IList synchronizedTables = GetSynchronizedTables(querySchema);
40+
IDictionary<string,string> parameterTypes = new LinkedHashMap<string,string>();
41+
IList<string> synchronizedTables = GetSynchronizedTables(querySchema);
4342

4443
NamedSQLQueryDefinition namedQuery;
4544

@@ -63,9 +62,9 @@ public void AddSqlQuery(HbmSqlQuery querySchema)
6362
});
6463
}
6564

66-
private static IList GetSynchronizedTables(HbmSqlQuery querySchema)
65+
private static IList<string> GetSynchronizedTables(HbmSqlQuery querySchema)
6766
{
68-
IList synchronizedTables = new ArrayList();
67+
IList<string> synchronizedTables = new List<string>();
6968

7069
foreach (object item in querySchema.Items ?? new object[0])
7170
{

src/NHibernate/Engine/ActionQueue.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using System.Collections;
33
using System.Collections.Generic;
44
using System.Text;
5-
using Iesi.Collections;
5+
using Iesi.Collections.Generic;
66
using log4net;
77
using NHibernate.Action;
88
using NHibernate.Cache;
@@ -209,7 +209,7 @@ public void AfterTransactionCompletion(bool success)
209209
/// </summary>
210210
/// <param name="tables">The table/query-spaces to check. </param>
211211
/// <returns> True if we contain pending actions against any of the given tables; false otherwise.</returns>
212-
public virtual bool AreTablesToBeUpdated(ISet tables)
212+
public virtual bool AreTablesToBeUpdated(ISet<string> tables)
213213
{
214214
return AreTablesToUpdated(updates, tables) ||
215215
AreTablesToUpdated(insertions, tables) ||
@@ -228,12 +228,12 @@ public bool AreInsertionsOrDeletionsQueued
228228
get { return (insertions.Count > 0 || deletions.Count > 0); }
229229
}
230230

231-
private static bool AreTablesToUpdated(IList executables, ISet tablespaces)
231+
private static bool AreTablesToUpdated(IList executables, ISet<string> tablespaces)
232232
{
233233
foreach (IExecutable exec in executables)
234234
{
235235
object[] spaces = exec.PropertySpaces;
236-
foreach (object o in spaces)
236+
foreach (string o in spaces)
237237
{
238238
if(tablespaces.Contains(o))
239239
{

src/NHibernate/Engine/NamedQueryDefinition.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using System;
2-
using System.Collections;
2+
using System.Collections.Generic;
33

44
namespace NHibernate.Engine
55
{
@@ -12,14 +12,14 @@ public class NamedQueryDefinition
1212
private readonly int timeout = -1;
1313
private readonly int fetchSize = -1;
1414
private readonly FlushMode flushMode = FlushMode.Unspecified;
15-
private readonly IDictionary parameterTypes;
15+
private readonly IDictionary<string, string> parameterTypes;
1616

1717
private readonly CacheMode? cacheMode;
1818
private readonly bool readOnly;
1919
private readonly string comment;
2020

2121
public NamedQueryDefinition(string query, bool cacheable, string cacheRegion, int timeout,
22-
int fetchSize, FlushMode flushMode, bool readOnly, string comment, IDictionary parameterTypes)
22+
int fetchSize, FlushMode flushMode, bool readOnly, string comment, IDictionary<string, string> parameterTypes)
2323
: this(query,cacheable,cacheRegion,timeout,fetchSize,flushMode,null,readOnly,comment,parameterTypes)
2424
{}
2525

@@ -33,7 +33,7 @@ public NamedQueryDefinition(
3333
CacheMode? cacheMode,
3434
bool readOnly,
3535
string comment,
36-
IDictionary parameterTypes
36+
IDictionary<string,string> parameterTypes
3737
)
3838
{
3939
this.query = query;
@@ -83,7 +83,7 @@ public override string ToString()
8383
return GetType().FullName + '(' + query + ')';
8484
}
8585

86-
public IDictionary ParameterTypes
86+
public IDictionary<string, string> ParameterTypes
8787
{
8888
get { return parameterTypes; }
8989
}

src/NHibernate/Engine/NamedSQLQueryDefinition.cs

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
using System;
22
using System.Collections;
33
using NHibernate.Engine.Query.Sql;
4+
using System.Collections.Generic;
45

56
namespace NHibernate.Engine
67
{
78
[Serializable]
89
public class NamedSQLQueryDefinition : NamedQueryDefinition
910
{
1011
private readonly INativeSQLQueryReturn[] queryReturns;
11-
private readonly IList querySpaces;
12+
private readonly IList<string> querySpaces;
1213
private readonly bool callable;
1314
private readonly string resultSetRef;
1415

1516
public NamedSQLQueryDefinition(
1617
string query,
1718
INativeSQLQueryReturn[] queryReturns,
18-
IList querySpaces,
19+
IList<string> querySpaces,
1920
bool cacheable,
2021
string cacheRegion,
2122
int timeout,
@@ -24,7 +25,7 @@ public NamedSQLQueryDefinition(
2425
CacheMode? cacheMode,
2526
bool readOnly,
2627
string comment,
27-
IDictionary parameterTypes,
28+
IDictionary<string, string> parameterTypes,
2829
bool callable)
2930
: base(
3031
query.Trim(), /* trim done to workaround stupid oracle bug that cant handle whitespaces before a { in a sp */
@@ -47,7 +48,7 @@ public NamedSQLQueryDefinition(
4748
public NamedSQLQueryDefinition(
4849
string query,
4950
string resultSetRef,
50-
IList querySpaces,
51+
IList<string> querySpaces,
5152
bool cacheable,
5253
string cacheRegion,
5354
int timeout,
@@ -56,7 +57,7 @@ public NamedSQLQueryDefinition(
5657
CacheMode? cacheMode,
5758
bool readOnly,
5859
string comment,
59-
IDictionary parameterTypes,
60+
IDictionary<string, string> parameterTypes,
6061
bool callable)
6162
: base(
6263
query.Trim(), /* trim done to workaround stupid oracle bug that cant handle whitespaces before a { in a sp */
@@ -81,7 +82,7 @@ public INativeSQLQueryReturn[] QueryReturns
8182
get { return queryReturns; }
8283
}
8384

84-
public IList QuerySpaces
85+
public IList<string> QuerySpaces
8586
{
8687
get { return querySpaces; }
8788
}

src/NHibernate/Engine/Query/HQLQueryPlan.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public string SourceQuery
106106
get { return sourceQuery; }
107107
}
108108

109-
public ISet QuerySpaces
109+
public ISet<string> QuerySpaces
110110
{
111111
get { return querySpaces; }
112112
}

0 commit comments

Comments
 (0)