@@ -24,7 +24,7 @@ public class PersistentGenericSet<T> : AbstractPersistentCollection, ISet<T>
24
24
/// <summary>
25
25
/// The <see cref="ISet{T}"/> that NHibernate is wrapping.
26
26
/// </summary>
27
- protected ISet < T > set ;
27
+ protected ISet < T > WrappedSet ;
28
28
29
29
/// <summary>
30
30
/// A temporary list that holds the objects while the PersistentSet is being
@@ -67,7 +67,7 @@ public PersistentGenericSet(ISessionImplementor session, ISet<T> original)
67
67
// do we need to copy it to be sure it won't be changing
68
68
// underneath us?
69
69
// ie. this.set.addAll(set);
70
- set = original ;
70
+ WrappedSet = original ;
71
71
SetInitialized ( ) ;
72
72
IsDirectlyAccessible = true ;
73
73
}
@@ -80,8 +80,8 @@ public override bool RowUpdatePossible
80
80
public override object GetSnapshot ( ICollectionPersister persister )
81
81
{
82
82
var entityMode = Session . EntityMode ;
83
- var clonedSet = new SetSnapShot < T > ( set . Count ) ;
84
- var enumerable = from object current in set
83
+ var clonedSet = new SetSnapShot < T > ( WrappedSet . Count ) ;
84
+ var enumerable = from object current in WrappedSet
85
85
select persister . ElementType . DeepCopy ( current , entityMode , persister . Factory ) ;
86
86
foreach ( var copied in enumerable )
87
87
{
@@ -95,21 +95,21 @@ public override ICollection GetOrphans(object snapshot, string entityName)
95
95
var sn = new SetSnapShot < T > ( ( IEnumerable < T > ) snapshot ) ;
96
96
97
97
// TODO: Avoid duplicating shortcuts and array copy, by making base class GetOrphans() more flexible
98
- if ( set . Count == 0 ) return sn ;
98
+ if ( WrappedSet . Count == 0 ) return sn ;
99
99
if ( ( ( ICollection ) sn ) . Count == 0 ) return sn ;
100
- return GetOrphans ( sn , set . ToArray ( ) , entityName , Session ) ;
100
+ return GetOrphans ( sn , WrappedSet . ToArray ( ) , entityName , Session ) ;
101
101
}
102
102
103
103
public override bool EqualsSnapshot ( ICollectionPersister persister )
104
104
{
105
105
var elementType = persister . ElementType ;
106
106
var snapshot = ( ISetSnapshot < T > ) GetSnapshot ( ) ;
107
- if ( ( ( ICollection ) snapshot ) . Count != set . Count )
107
+ if ( ( ( ICollection ) snapshot ) . Count != WrappedSet . Count )
108
108
{
109
109
return false ;
110
110
}
111
111
112
- return ! ( from object obj in set
112
+ return ! ( from object obj in WrappedSet
113
113
let oldValue = snapshot [ ( T ) obj ]
114
114
where oldValue == null || elementType . IsDirty ( oldValue , obj , Session )
115
115
select obj ) . Any ( ) ;
@@ -122,7 +122,7 @@ public override bool IsSnapshotEmpty(object snapshot)
122
122
123
123
public override void BeforeInitialize ( ICollectionPersister persister , int anticipatedSize )
124
124
{
125
- set = ( ISet < T > ) persister . CollectionType . Instantiate ( anticipatedSize ) ;
125
+ WrappedSet = ( ISet < T > ) persister . CollectionType . Instantiate ( anticipatedSize ) ;
126
126
}
127
127
128
128
/// <summary>
@@ -141,21 +141,21 @@ public override void InitializeFromCache(ICollectionPersister persister, object
141
141
var element = ( T ) persister . ElementType . Assemble ( array [ i ] , Session , owner ) ;
142
142
if ( element != null )
143
143
{
144
- set . Add ( element ) ;
144
+ WrappedSet . Add ( element ) ;
145
145
}
146
146
}
147
147
SetInitialized ( ) ;
148
148
}
149
149
150
150
public override bool Empty
151
151
{
152
- get { return set . Count == 0 ; }
152
+ get { return WrappedSet . Count == 0 ; }
153
153
}
154
154
155
155
public override string ToString ( )
156
156
{
157
157
Read ( ) ;
158
- return StringHelper . CollectionToString ( set ) ;
158
+ return StringHelper . CollectionToString ( WrappedSet ) ;
159
159
}
160
160
161
161
public override object ReadFrom ( IDataReader rs , ICollectionPersister role , ICollectionAliases descriptor , object owner )
@@ -187,7 +187,7 @@ public override bool EndRead(ICollectionPersister persister)
187
187
{
188
188
foreach ( T item in _tempList )
189
189
{
190
- set . Add ( item ) ;
190
+ WrappedSet . Add ( item ) ;
191
191
}
192
192
_tempList = null ;
193
193
SetInitialized ( ) ;
@@ -196,15 +196,15 @@ public override bool EndRead(ICollectionPersister persister)
196
196
197
197
public override IEnumerable Entries ( ICollectionPersister persister )
198
198
{
199
- return set ;
199
+ return WrappedSet ;
200
200
}
201
201
202
202
public override object Disassemble ( ICollectionPersister persister )
203
203
{
204
- var result = new object [ set . Count ] ;
204
+ var result = new object [ WrappedSet . Count ] ;
205
205
int i = 0 ;
206
206
207
- foreach ( object obj in set )
207
+ foreach ( object obj in WrappedSet )
208
208
{
209
209
result [ i ++ ] = persister . ElementType . Disassemble ( obj , Session , null ) ;
210
210
}
@@ -217,9 +217,9 @@ public override IEnumerable GetDeletes(ICollectionPersister persister, bool inde
217
217
var sn = ( ISetSnapshot < T > ) GetSnapshot ( ) ;
218
218
var deletes = new List < T > ( ( ( ICollection < T > ) sn ) . Count ) ;
219
219
220
- deletes . AddRange ( sn . Where ( obj => ! set . Contains ( obj ) ) ) ;
220
+ deletes . AddRange ( sn . Where ( obj => ! WrappedSet . Contains ( obj ) ) ) ;
221
221
222
- deletes . AddRange ( from obj in set
222
+ deletes . AddRange ( from obj in WrappedSet
223
223
let oldValue = sn [ obj ]
224
224
where oldValue != null && elementType . IsDirty ( obj , oldValue , Session )
225
225
select oldValue ) ;
@@ -265,13 +265,13 @@ public override bool Equals(object other)
265
265
return false ;
266
266
}
267
267
Read ( ) ;
268
- return set . SequenceEqual ( that ) ;
268
+ return WrappedSet . SequenceEqual ( that ) ;
269
269
}
270
270
271
271
public override int GetHashCode ( )
272
272
{
273
273
Read ( ) ;
274
- return set . GetHashCode ( ) ;
274
+ return WrappedSet . GetHashCode ( ) ;
275
275
}
276
276
277
277
public override bool EntryExists ( object entry , int i )
@@ -281,7 +281,7 @@ public override bool EntryExists(object entry, int i)
281
281
282
282
public override bool IsWrapper ( object collection )
283
283
{
284
- return set == collection ;
284
+ return WrappedSet == collection ;
285
285
}
286
286
287
287
#region ISet<T> Members
@@ -290,7 +290,7 @@ public override bool IsWrapper(object collection)
290
290
public bool Contains ( T item )
291
291
{
292
292
bool ? exists = ReadElementExistence ( item ) ;
293
- return exists == null ? set . Contains ( item ) : exists . Value ;
293
+ return exists == null ? WrappedSet . Contains ( item ) : exists . Value ;
294
294
}
295
295
296
296
@@ -300,7 +300,7 @@ public bool Add(T o)
300
300
if ( ! exists . HasValue )
301
301
{
302
302
Initialize ( true ) ;
303
- if ( set . Add ( o ) )
303
+ if ( WrappedSet . Add ( o ) )
304
304
{
305
305
Dirty ( ) ;
306
306
return true ;
@@ -324,9 +324,9 @@ public void UnionWith(IEnumerable<T> other)
324
324
325
325
Initialize ( true ) ;
326
326
327
- var oldCount = set . Count ;
328
- set . UnionWith ( collection ) ;
329
- var newCount = set . Count ;
327
+ var oldCount = WrappedSet . Count ;
328
+ WrappedSet . UnionWith ( collection ) ;
329
+ var newCount = WrappedSet . Count ;
330
330
331
331
// Union can only add, so if the set was modified the count must increase.
332
332
if ( oldCount != newCount )
@@ -337,9 +337,9 @@ public void IntersectWith(IEnumerable<T> other)
337
337
{
338
338
Initialize ( true ) ;
339
339
340
- var oldCount = set . Count ;
341
- set . IntersectWith ( other ) ;
342
- var newCount = set . Count ;
340
+ var oldCount = WrappedSet . Count ;
341
+ WrappedSet . IntersectWith ( other ) ;
342
+ var newCount = WrappedSet . Count ;
343
343
344
344
// Intersect can only remove, so if the set was modified the count must decrease.
345
345
if ( oldCount != newCount )
@@ -354,9 +354,9 @@ public void ExceptWith(IEnumerable<T> other)
354
354
355
355
Initialize ( true ) ;
356
356
357
- var oldCount = set . Count ;
358
- set . ExceptWith ( collection ) ;
359
- var newCount = set . Count ;
357
+ var oldCount = WrappedSet . Count ;
358
+ WrappedSet . ExceptWith ( collection ) ;
359
+ var newCount = WrappedSet . Count ;
360
360
361
361
// Except can only remove, so if the set was modified the count must decrease.
362
362
if ( oldCount != newCount )
@@ -371,7 +371,7 @@ public void SymmetricExceptWith(IEnumerable<T> other)
371
371
372
372
Initialize ( true ) ;
373
373
374
- set . SymmetricExceptWith ( collection ) ;
374
+ WrappedSet . SymmetricExceptWith ( collection ) ;
375
375
376
376
// If the other collection is non-empty, we are guaranteed to
377
377
// remove or add at least one element.
@@ -381,37 +381,37 @@ public void SymmetricExceptWith(IEnumerable<T> other)
381
381
public bool IsSubsetOf ( IEnumerable < T > other )
382
382
{
383
383
Read ( ) ;
384
- return set . IsProperSupersetOf ( other ) ;
384
+ return WrappedSet . IsProperSupersetOf ( other ) ;
385
385
}
386
386
387
387
public bool IsSupersetOf ( IEnumerable < T > other )
388
388
{
389
389
Read ( ) ;
390
- return set . IsSupersetOf ( other ) ;
390
+ return WrappedSet . IsSupersetOf ( other ) ;
391
391
}
392
392
393
393
public bool IsProperSupersetOf ( IEnumerable < T > other )
394
394
{
395
395
Read ( ) ;
396
- return set . IsProperSupersetOf ( other ) ;
396
+ return WrappedSet . IsProperSupersetOf ( other ) ;
397
397
}
398
398
399
399
public bool IsProperSubsetOf ( IEnumerable < T > other )
400
400
{
401
401
Read ( ) ;
402
- return set . IsProperSubsetOf ( other ) ;
402
+ return WrappedSet . IsProperSubsetOf ( other ) ;
403
403
}
404
404
405
405
public bool Overlaps ( IEnumerable < T > other )
406
406
{
407
407
Read ( ) ;
408
- return set . Overlaps ( other ) ;
408
+ return WrappedSet . Overlaps ( other ) ;
409
409
}
410
410
411
411
public bool SetEquals ( IEnumerable < T > other )
412
412
{
413
413
Read ( ) ;
414
- return set . SetEquals ( other ) ;
414
+ return WrappedSet . SetEquals ( other ) ;
415
415
}
416
416
417
417
public bool Remove ( T o )
@@ -420,7 +420,7 @@ public bool Remove(T o)
420
420
if ( ! exists . HasValue )
421
421
{
422
422
Initialize ( true ) ;
423
- if ( set . Remove ( o ) )
423
+ if ( WrappedSet . Remove ( o ) )
424
424
{
425
425
Dirty ( ) ;
426
426
return true ;
@@ -445,9 +445,9 @@ public void Clear()
445
445
else
446
446
{
447
447
Initialize ( true ) ;
448
- if ( set . Count != 0 )
448
+ if ( WrappedSet . Count != 0 )
449
449
{
450
- set . Clear ( ) ;
450
+ WrappedSet . Clear ( ) ;
451
451
Dirty ( ) ;
452
452
}
453
453
}
@@ -461,12 +461,12 @@ public void CopyTo(T[] array, int arrayIndex)
461
461
{
462
462
// NH : we really need to initialize the set ?
463
463
Read ( ) ;
464
- set . CopyTo ( array , arrayIndex ) ;
464
+ WrappedSet . CopyTo ( array , arrayIndex ) ;
465
465
}
466
466
467
467
public int Count
468
468
{
469
- get { return ReadSize ( ) ? CachedSize : set . Count ; }
469
+ get { return ReadSize ( ) ? CachedSize : WrappedSet . Count ; }
470
470
}
471
471
472
472
public bool IsReadOnly
@@ -497,7 +497,7 @@ void ICollection<T>.Add(T item)
497
497
IEnumerator IEnumerable . GetEnumerator ( )
498
498
{
499
499
Read ( ) ;
500
- return set . GetEnumerator ( ) ;
500
+ return WrappedSet . GetEnumerator ( ) ;
501
501
}
502
502
503
503
#endregion
@@ -507,7 +507,7 @@ IEnumerator IEnumerable.GetEnumerator()
507
507
public IEnumerator < T > GetEnumerator ( )
508
508
{
509
509
Read ( ) ;
510
- return set . GetEnumerator ( ) ;
510
+ return WrappedSet . GetEnumerator ( ) ;
511
511
}
512
512
513
513
#endregion
@@ -536,7 +536,7 @@ public object Orphan
536
536
537
537
public void Operate ( )
538
538
{
539
- enclosingInstance . set . Clear ( ) ;
539
+ enclosingInstance . WrappedSet . Clear ( ) ;
540
540
}
541
541
}
542
542
@@ -563,7 +563,7 @@ public object Orphan
563
563
564
564
public void Operate ( )
565
565
{
566
- enclosingInstance . set . Add ( value ) ;
566
+ enclosingInstance . WrappedSet . Add ( value ) ;
567
567
}
568
568
}
569
569
@@ -590,7 +590,7 @@ public object Orphan
590
590
591
591
public void Operate ( )
592
592
{
593
- enclosingInstance . set . Remove ( value ) ;
593
+ enclosingInstance . WrappedSet . Remove ( value ) ;
594
594
}
595
595
}
596
596
0 commit comments