@@ -25,7 +25,7 @@ namespace NHibernate.Collection.Generic
25
25
[ DebuggerTypeProxy ( typeof ( DictionaryProxy < , > ) ) ]
26
26
public partial class PersistentGenericMap < TKey , TValue > : AbstractPersistentCollection , IDictionary < TKey , TValue > , ICollection
27
27
{
28
- private IDictionary < TKey , TValue > _wrappedMap ;
28
+ protected IDictionary < TKey , TValue > WrappedMap ;
29
29
private readonly ICollection < TValue > _wrappedValues ;
30
30
31
31
public PersistentGenericMap ( )
@@ -50,16 +50,16 @@ public PersistentGenericMap(ISessionImplementor session) : base(session)
50
50
public PersistentGenericMap ( ISessionImplementor session , IDictionary < TKey , TValue > map )
51
51
: base ( session )
52
52
{
53
- _wrappedMap = map ;
53
+ WrappedMap = map ;
54
54
_wrappedValues = new ValuesWrapper ( this ) ;
55
55
SetInitialized ( ) ;
56
56
IsDirectlyAccessible = true ;
57
57
}
58
58
59
59
public override object GetSnapshot ( ICollectionPersister persister )
60
60
{
61
- Dictionary < TKey , TValue > clonedMap = new Dictionary < TKey , TValue > ( _wrappedMap . Count ) ;
62
- foreach ( KeyValuePair < TKey , TValue > e in _wrappedMap )
61
+ Dictionary < TKey , TValue > clonedMap = new Dictionary < TKey , TValue > ( WrappedMap . Count ) ;
62
+ foreach ( KeyValuePair < TKey , TValue > e in WrappedMap )
63
63
{
64
64
object copy = persister . ElementType . DeepCopy ( e . Value , persister . Factory ) ;
65
65
clonedMap [ e . Key ] = ( TValue ) copy ;
@@ -70,18 +70,18 @@ public override object GetSnapshot(ICollectionPersister persister)
70
70
public override ICollection GetOrphans ( object snapshot , string entityName )
71
71
{
72
72
var sn = ( IDictionary < TKey , TValue > ) snapshot ;
73
- return GetOrphans ( ( ICollection ) sn . Values , ( ICollection ) _wrappedMap . Values , entityName , Session ) ;
73
+ return GetOrphans ( ( ICollection ) sn . Values , ( ICollection ) WrappedMap . Values , entityName , Session ) ;
74
74
}
75
75
76
76
public override bool EqualsSnapshot ( ICollectionPersister persister )
77
77
{
78
78
IType elementType = persister . ElementType ;
79
79
var xmap = ( IDictionary < TKey , TValue > ) GetSnapshot ( ) ;
80
- if ( xmap . Count != _wrappedMap . Count )
80
+ if ( xmap . Count != WrappedMap . Count )
81
81
{
82
82
return false ;
83
83
}
84
- foreach ( KeyValuePair < TKey , TValue > entry in _wrappedMap )
84
+ foreach ( KeyValuePair < TKey , TValue > entry in WrappedMap )
85
85
{
86
86
// This method is not currently called if a key has been removed/added, but better be on the safe side.
87
87
if ( ! xmap . TryGetValue ( entry . Key , out var value ) ||
@@ -100,23 +100,23 @@ public override bool IsSnapshotEmpty(object snapshot)
100
100
101
101
public override bool IsWrapper ( object collection )
102
102
{
103
- return _wrappedMap == collection ;
103
+ return WrappedMap == collection ;
104
104
}
105
105
106
106
public override void BeforeInitialize ( ICollectionPersister persister , int anticipatedSize )
107
107
{
108
- _wrappedMap = ( IDictionary < TKey , TValue > ) persister . CollectionType . Instantiate ( anticipatedSize ) ;
108
+ WrappedMap = ( IDictionary < TKey , TValue > ) persister . CollectionType . Instantiate ( anticipatedSize ) ;
109
109
}
110
110
111
111
public override bool Empty
112
112
{
113
- get { return ( _wrappedMap . Count == 0 ) ; }
113
+ get { return ( WrappedMap . Count == 0 ) ; }
114
114
}
115
115
116
116
public override string ToString ( )
117
117
{
118
118
Read ( ) ;
119
- return StringHelper . CollectionToString ( _wrappedMap ) ;
119
+ return StringHelper . CollectionToString ( WrappedMap ) ;
120
120
}
121
121
122
122
public override object ReadFrom ( DbDataReader rs , ICollectionPersister role , ICollectionAliases descriptor , object owner )
@@ -130,12 +130,12 @@ public override object ReadFrom(DbDataReader rs, ICollectionPersister role, ICol
130
130
131
131
protected virtual void AddDuringInitialize ( object index , object element )
132
132
{
133
- _wrappedMap [ ( TKey ) index ] = ( TValue ) element ;
133
+ WrappedMap [ ( TKey ) index ] = ( TValue ) element ;
134
134
}
135
135
136
136
public override IEnumerable Entries ( ICollectionPersister persister )
137
137
{
138
- return _wrappedMap ;
138
+ return WrappedMap ;
139
139
}
140
140
141
141
/// <summary>
@@ -151,16 +151,16 @@ public override void InitializeFromCache(ICollectionPersister persister, object
151
151
BeforeInitialize ( persister , size ) ;
152
152
for ( int i = 0 ; i < size ; i += 2 )
153
153
{
154
- _wrappedMap [ ( TKey ) persister . IndexType . Assemble ( array [ i ] , Session , owner ) ] =
154
+ WrappedMap [ ( TKey ) persister . IndexType . Assemble ( array [ i ] , Session , owner ) ] =
155
155
( TValue ) persister . ElementType . Assemble ( array [ i + 1 ] , Session , owner ) ;
156
156
}
157
157
}
158
158
159
159
public override object Disassemble ( ICollectionPersister persister )
160
160
{
161
- object [ ] result = new object [ _wrappedMap . Count * 2 ] ;
161
+ object [ ] result = new object [ WrappedMap . Count * 2 ] ;
162
162
int i = 0 ;
163
- foreach ( KeyValuePair < TKey , TValue > e in _wrappedMap )
163
+ foreach ( KeyValuePair < TKey , TValue > e in WrappedMap )
164
164
{
165
165
result [ i ++ ] = persister . IndexType . Disassemble ( e . Key , Session , null ) ;
166
166
result [ i ++ ] = persister . ElementType . Disassemble ( e . Value , Session , null ) ;
@@ -174,7 +174,7 @@ public override IEnumerable GetDeletes(ICollectionPersister persister, bool inde
174
174
var sn = ( IDictionary < TKey , TValue > ) GetSnapshot ( ) ;
175
175
foreach ( var e in sn )
176
176
{
177
- if ( ! _wrappedMap . ContainsKey ( e . Key ) )
177
+ if ( ! WrappedMap . ContainsKey ( e . Key ) )
178
178
{
179
179
object key = e . Key ;
180
180
deletes . Add ( indexIsFormula ? e . Value : key ) ;
@@ -224,18 +224,18 @@ public override bool Equals(object other)
224
224
return false ;
225
225
}
226
226
Read ( ) ;
227
- return CollectionHelper . DictionaryEquals ( _wrappedMap , that ) ;
227
+ return CollectionHelper . DictionaryEquals ( WrappedMap , that ) ;
228
228
}
229
229
230
230
public override int GetHashCode ( )
231
231
{
232
232
Read ( ) ;
233
- return _wrappedMap . GetHashCode ( ) ;
233
+ return WrappedMap . GetHashCode ( ) ;
234
234
}
235
235
236
236
public override bool EntryExists ( object entry , int i )
237
237
{
238
- return _wrappedMap . ContainsKey ( ( ( KeyValuePair < TKey , TValue > ) entry ) . Key ) ;
238
+ return WrappedMap . ContainsKey ( ( ( KeyValuePair < TKey , TValue > ) entry ) . Key ) ;
239
239
}
240
240
241
241
@@ -244,7 +244,7 @@ public override bool EntryExists(object entry, int i)
244
244
public bool ContainsKey ( TKey key )
245
245
{
246
246
bool ? exists = ReadIndexExistence ( key ) ;
247
- return ! exists . HasValue ? _wrappedMap . ContainsKey ( key ) : exists . Value ;
247
+ return ! exists . HasValue ? WrappedMap . ContainsKey ( key ) : exists . Value ;
248
248
}
249
249
250
250
public void Add ( TKey key , TValue value )
@@ -263,7 +263,7 @@ public void Add(TKey key, TValue value)
263
263
}
264
264
}
265
265
Initialize ( true ) ;
266
- _wrappedMap . Add ( key , value ) ;
266
+ WrappedMap . Add ( key , value ) ;
267
267
Dirty ( ) ;
268
268
}
269
269
@@ -273,7 +273,7 @@ public bool Remove(TKey key)
273
273
if ( old == Unknown ) // queue is not enabled for 'puts', or element not found
274
274
{
275
275
Initialize ( true ) ;
276
- bool contained = _wrappedMap . Remove ( key ) ;
276
+ bool contained = WrappedMap . Remove ( key ) ;
277
277
if ( contained )
278
278
{
279
279
Dirty ( ) ;
@@ -291,7 +291,7 @@ public bool TryGetValue(TKey key, out TValue value)
291
291
object result = ReadElementByIndex ( key ) ;
292
292
if ( result == Unknown )
293
293
{
294
- return _wrappedMap . TryGetValue ( key , out value ) ;
294
+ return WrappedMap . TryGetValue ( key , out value ) ;
295
295
}
296
296
if ( result == NotFound )
297
297
{
@@ -309,7 +309,7 @@ public TValue this[TKey key]
309
309
object result = ReadElementByIndex ( key ) ;
310
310
if ( result == Unknown )
311
311
{
312
- return _wrappedMap [ key ] ;
312
+ return WrappedMap [ key ] ;
313
313
}
314
314
if ( result == NotFound )
315
315
{
@@ -331,8 +331,8 @@ public TValue this[TKey key]
331
331
}
332
332
Initialize ( true ) ;
333
333
TValue tempObject ;
334
- _wrappedMap . TryGetValue ( key , out tempObject ) ;
335
- _wrappedMap [ key ] = value ;
334
+ WrappedMap . TryGetValue ( key , out tempObject ) ;
335
+ WrappedMap [ key ] = value ;
336
336
TValue old2 = tempObject ;
337
337
// would be better to use the element-type to determine
338
338
// whether the old and the new are equal here; the problem being
@@ -350,7 +350,7 @@ public ICollection<TKey> Keys
350
350
get
351
351
{
352
352
Read ( ) ;
353
- return _wrappedMap . Keys ;
353
+ return WrappedMap . Keys ;
354
354
}
355
355
}
356
356
@@ -380,10 +380,10 @@ public void Clear()
380
380
else
381
381
{
382
382
Initialize ( true ) ;
383
- if ( _wrappedMap . Count != 0 )
383
+ if ( WrappedMap . Count != 0 )
384
384
{
385
385
Dirty ( ) ;
386
- _wrappedMap . Clear ( ) ;
386
+ WrappedMap . Clear ( ) ;
387
387
}
388
388
}
389
389
}
@@ -393,7 +393,7 @@ public bool Contains(KeyValuePair<TKey, TValue> item)
393
393
bool ? exists = ReadIndexExistence ( item . Key ) ;
394
394
if ( ! exists . HasValue )
395
395
{
396
- return _wrappedMap . Contains ( item ) ;
396
+ return WrappedMap . Contains ( item ) ;
397
397
}
398
398
399
399
if ( exists . Value )
@@ -441,7 +441,7 @@ public bool Remove(KeyValuePair<TKey, TValue> item)
441
441
442
442
public int Count
443
443
{
444
- get { return ReadSize ( ) ? CachedSize : _wrappedMap . Count ; }
444
+ get { return ReadSize ( ) ? CachedSize : WrappedMap . Count ; }
445
445
}
446
446
447
447
public bool IsReadOnly
@@ -475,7 +475,7 @@ public bool IsSynchronized
475
475
IEnumerator < KeyValuePair < TKey , TValue > > IEnumerable < KeyValuePair < TKey , TValue > > . GetEnumerator ( )
476
476
{
477
477
Read ( ) ;
478
- return _wrappedMap . GetEnumerator ( ) ;
478
+ return WrappedMap . GetEnumerator ( ) ;
479
479
}
480
480
481
481
#endregion
@@ -485,7 +485,7 @@ IEnumerator<KeyValuePair<TKey, TValue>> IEnumerable<KeyValuePair<TKey, TValue>>.
485
485
IEnumerator IEnumerable . GetEnumerator ( )
486
486
{
487
487
Read ( ) ;
488
- return _wrappedMap . GetEnumerator ( ) ;
488
+ return WrappedMap . GetEnumerator ( ) ;
489
489
}
490
490
491
491
#endregion
@@ -513,7 +513,7 @@ public object Orphan
513
513
514
514
public void Operate ( )
515
515
{
516
- _enclosingInstance . _wrappedMap . Clear ( ) ;
516
+ _enclosingInstance . WrappedMap . Clear ( ) ;
517
517
}
518
518
}
519
519
@@ -544,7 +544,7 @@ public object Orphan
544
544
545
545
public void Operate ( )
546
546
{
547
- _enclosingInstance . _wrappedMap [ _index ] = _value ;
547
+ _enclosingInstance . WrappedMap [ _index ] = _value ;
548
548
}
549
549
}
550
550
@@ -573,7 +573,7 @@ public object Orphan
573
573
574
574
public void Operate ( )
575
575
{
576
- _enclosingInstance . _wrappedMap . Remove ( _index ) ;
576
+ _enclosingInstance . WrappedMap . Remove ( _index ) ;
577
577
}
578
578
}
579
579
@@ -609,7 +609,7 @@ public ValuesWrapper(PersistentGenericMap<TKey, TValue> map)
609
609
public IEnumerator < TValue > GetEnumerator ( )
610
610
{
611
611
_map . Read ( ) ;
612
- return _map . _wrappedMap . Values . GetEnumerator ( ) ;
612
+ return _map . WrappedMap . Values . GetEnumerator ( ) ;
613
613
}
614
614
615
615
IEnumerator IEnumerable . GetEnumerator ( )
@@ -631,13 +631,13 @@ public void Clear()
631
631
public bool Contains ( TValue item )
632
632
{
633
633
_map . Read ( ) ;
634
- return _map . _wrappedMap . Values . Contains ( item ) ;
634
+ return _map . WrappedMap . Values . Contains ( item ) ;
635
635
}
636
636
637
637
public void CopyTo ( TValue [ ] array , int arrayIndex )
638
638
{
639
639
_map . Read ( ) ;
640
- _map . _wrappedMap . Values . CopyTo ( array , arrayIndex ) ;
640
+ _map . WrappedMap . Values . CopyTo ( array , arrayIndex ) ;
641
641
}
642
642
643
643
public bool Remove ( TValue item )
@@ -650,7 +650,7 @@ public int Count
650
650
get
651
651
{
652
652
_map . Read ( ) ;
653
- return _map . _wrappedMap . Values . Count ;
653
+ return _map . WrappedMap . Values . Count ;
654
654
}
655
655
}
656
656
0 commit comments