Skip to content

Commit 1160ede

Browse files
committed
Refactoring:
- use of strongly typed collections - use of JoinedEnumerable instead create new collections - changed methods/properties names like H3.2 - insured properties changing its type from ICollection to IEnumerable SVN: trunk@3086
1 parent 6b7ae63 commit 1160ede

21 files changed

+322
-203
lines changed

src/NHibernate.Test/TestCase.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ protected void ApplyCacheSettings(Configuration configuration)
296296
foreach (PersistentClass clazz in configuration.ClassMappings)
297297
{
298298
bool hasLob = false;
299-
foreach (Mapping.Property prop in clazz.PropertyClosureCollection)
299+
foreach (Mapping.Property prop in clazz.PropertyClosureIterator)
300300
{
301301
if (prop.Value.IsSimpleValue)
302302
{

src/NHibernate/Cfg/XmlHbmBinding/ResultSetMappingBinder.cs

+2-1
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 NHibernate.Cfg.MappingSchema;
56
using NHibernate.Engine;
@@ -179,7 +180,7 @@ private IDictionary BindPropertyResults(string alias, HbmReturnDiscriminator dis
179180
int dotIndex = name.LastIndexOf('.');
180181
string reducedName = name.Substring(0, dotIndex);
181182
IValue value = pc.GetRecursiveProperty(reducedName).Value;
182-
ICollection parentPropIter;
183+
IEnumerable<Mapping.Property> parentPropIter;
183184
if (value is Component)
184185
{
185186
Component comp = (Component) value;

src/NHibernate/Engine/Query/HQLQueryPlan.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -282,11 +282,11 @@ public IEnumerable<T> PerformIterate<T>(QueryParameters queryParameters, IEventS
282282

283283
// NH Different behavior (we need to implement the translators.GetEnumerable<T>)
284284
if (many.HasValue && many.Value)
285-
return new GenericJoinedEnumerable<T>(results);
285+
return new JoinedEnumerable<T>(results);
286286
else
287287
{
288-
results = new IEnumerable[] {result};
289-
return new GenericJoinedEnumerable<T>(results);
288+
results = new IEnumerable[] { result };
289+
return new JoinedEnumerable<T>(results);
290290
}
291291
}
292292

src/NHibernate/Mapping/Collection.cs

+5-4
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 NHibernate.Engine;
45
using NHibernate.SqlCommand;
56
using NHibernate.Type;
@@ -63,8 +64,8 @@ public abstract class Collection : IFetchable, IValue, IFilterable
6364

6465
private bool isGeneric;
6566
private System.Type[] genericArguments;
66-
private IDictionary filters = new Hashtable();
67-
private IDictionary manyToManyFilters = new Hashtable();
67+
private readonly Dictionary<string, string> filters = new Dictionary<string, string>();
68+
private readonly Dictionary<string, string> manyToManyFilters = new Dictionary<string, string>();
6869
private bool subselectLoadable;
6970
private string manyToManyWhere;
7071
private string manyToManyOrderBy;
@@ -480,7 +481,7 @@ public void AddFilter(string name, string condition)
480481
filters.Add(name, condition);
481482
}
482483

483-
public IDictionary FilterMap
484+
public IDictionary<string,string> FilterMap
484485
{
485486
get { return filters; }
486487
}
@@ -490,7 +491,7 @@ public void AddManyToManyFilter(string name, string condition)
490491
manyToManyFilters.Add(name, condition);
491492
}
492493

493-
public IDictionary ManyToManyFilterMap
494+
public IDictionary<string, string> ManyToManyFilterMap
494495
{
495496
get { return manyToManyFilters; }
496497
}

src/NHibernate/Mapping/Component.cs

+4-9
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

45
namespace NHibernate.Mapping
56
{
@@ -9,7 +10,7 @@ namespace NHibernate.Mapping
910
/// </summary>
1011
public class Component : SimpleValue
1112
{
12-
private ArrayList properties = new ArrayList();
13+
private readonly List<Property> properties = new List<Property>();
1314
private System.Type componentClass;
1415
private bool embedded;
1516
private string parentProperty;
@@ -23,7 +24,7 @@ public int PropertySpan
2324
}
2425

2526
/// <summary></summary>
26-
public ICollection PropertyCollection
27+
public IEnumerable<Property> PropertyCollection
2728
{
2829
get { return properties; }
2930
}
@@ -145,12 +146,6 @@ public string ParentProperty
145146
set { parentProperty = value; }
146147
}
147148

148-
/// <summary></summary>
149-
public ArrayList Properties
150-
{
151-
get { return properties; }
152-
}
153-
154149
public override bool[] ColumnInsertability
155150
{
156151
get
@@ -191,7 +186,7 @@ public override bool[] ColumnUpdateability
191186

192187
public Property GetProperty(string propertyName)
193188
{
194-
ICollection iter = PropertyCollection;
189+
IEnumerable<Property> iter = PropertyCollection;
195190
foreach (Property prop in iter)
196191
{
197192
if (prop.Name.Equals(propertyName))

src/NHibernate/Mapping/IFilterable.cs

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System;
2-
using System.Collections;
1+
using System.Collections.Generic;
32

43
namespace NHibernate.Mapping
54
{
@@ -8,8 +7,8 @@ namespace NHibernate.Mapping
87
/// </summary>
98
public interface IFilterable
109
{
11-
void AddFilter(String name, String condition);
10+
void AddFilter(string name, string condition);
1211

13-
IDictionary FilterMap { get; }
12+
IDictionary<string, string> FilterMap { get; }
1413
}
1514
}

src/NHibernate/Mapping/Join.cs

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

@@ -11,7 +10,7 @@ public class Join
1110
{
1211
private static readonly Alias PK_ALIAS = new Alias(15, "PK");
1312

14-
private ArrayList properties = new ArrayList();
13+
private readonly List<Property> properties = new List<Property>();
1514
private Table table;
1615
private IKeyValue key;
1716
private PersistentClass persistentClass;
@@ -33,15 +32,15 @@ public class Join
3332
public void AddProperty(Property prop)
3433
{
3534
properties.Add(prop);
36-
prop.PersistentClass = this.PersistentClass;
35+
prop.PersistentClass = PersistentClass;
3736
}
3837

3938
public bool ContainsProperty(Property prop)
4039
{
4140
return properties.Contains(prop);
4241
}
4342

44-
public ICollection PropertyCollection
43+
public IEnumerable<Property> PropertyIterator
4544
{
4645
get { return properties; }
4746
}

src/NHibernate/Mapping/JoinedSubclass.cs

+6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Collections.Generic;
23
using System.Text;
34

45
using NHibernate.Engine;
@@ -45,5 +46,10 @@ public override void Validate(IMapping mapping)
4546
throw new MappingException(string.Format("subclass key has wrong number of columns: {0} type: {1}", MappedClass.Name, Key.Type.Name));
4647
}
4748
}
49+
50+
public override IEnumerable<Property> ReferenceablePropertyIterator
51+
{
52+
get { return PropertyIterator; }
53+
}
4854
}
4955
}

0 commit comments

Comments
 (0)