Skip to content

Commit 8d2b123

Browse files
authored
Obsolete UnmodifiableDictionary
1 parent 1919480 commit 8d2b123

File tree

5 files changed

+12
-6
lines changed

5 files changed

+12
-6
lines changed

src/NHibernate/Event/EventListeners.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Collections.ObjectModel;
34
using NHibernate.Cfg;
45
using NHibernate.Event.Default;
56
using NHibernate.Util;
@@ -53,7 +54,7 @@ static EventListeners()
5354
eventInterfaceFromType[ListenerType.PostCollectionRecreate] = typeof (IPostCollectionRecreateEventListener);
5455
eventInterfaceFromType[ListenerType.PostCollectionRemove] = typeof (IPostCollectionRemoveEventListener);
5556
eventInterfaceFromType[ListenerType.PostCollectionUpdate] = typeof (IPostCollectionUpdateEventListener);
56-
eventInterfaceFromType = new UnmodifiableDictionary<ListenerType, System.Type>(eventInterfaceFromType);
57+
eventInterfaceFromType = new ReadOnlyDictionary<ListenerType, System.Type>(eventInterfaceFromType);
5758
}
5859

5960
private ILoadEventListener[] loadEventListeners = new ILoadEventListener[] {new DefaultLoadEventListener()};

src/NHibernate/Impl/SessionFactoryImpl.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Concurrent;
33
using System.Collections.Generic;
4+
using System.Collections.ObjectModel;
45
using System.Data.Common;
56
using System.Linq;
67
using System.Runtime.Serialization;
@@ -263,7 +264,7 @@ public SessionFactoryImpl(Configuration cfg, IMapping mapping, Settings settings
263264
implementorToEntityName[model.MappedClass] = model.EntityName;
264265
}
265266
}
266-
classMetadata = new UnmodifiableDictionary<string, IClassMetadata>(classMeta);
267+
classMetadata = new ReadOnlyDictionary<string, IClassMetadata>(classMeta);
267268

268269
Dictionary<string, ISet<string>> tmpEntityToCollectionRoleMap = new Dictionary<string, ISet<string>>();
269270
collectionPersisters = new Dictionary<string, ICollectionPersister>();
@@ -308,8 +309,8 @@ public SessionFactoryImpl(Configuration cfg, IMapping mapping, Settings settings
308309
{
309310
tmpcollectionMetadata.Add(collectionPersister.Key, collectionPersister.Value.CollectionMetadata);
310311
}
311-
collectionMetadata = new UnmodifiableDictionary<string, ICollectionMetadata>(tmpcollectionMetadata);
312-
collectionRolesByEntityParticipant = new UnmodifiableDictionary<string, ISet<string>>(tmpEntityToCollectionRoleMap);
312+
collectionMetadata = new ReadOnlyDictionary<string, ICollectionMetadata>(tmpcollectionMetadata);
313+
collectionRolesByEntityParticipant = new ReadOnlyDictionary<string, ISet<string>>(tmpEntityToCollectionRoleMap);
313314
#endregion
314315

315316
#region Named Queries

src/NHibernate/Mapping/PersistentClass.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using NHibernate.SqlCommand;
55
using NHibernate.Util;
66
using System.Collections.Generic;
7+
using System.Collections.ObjectModel;
78
using System.Linq;
89

910
namespace NHibernate.Mapping
@@ -560,7 +561,7 @@ public virtual IDictionary<EntityMode, string> TuplizerMap
560561
{
561562
get
562563
{
563-
return tuplizerImpls == null ? null : new UnmodifiableDictionary<EntityMode, string>(tuplizerImpls);
564+
return tuplizerImpls == null ? null : new ReadOnlyDictionary<EntityMode, string>(tuplizerImpls);
564565
}
565566
}
566567

src/NHibernate/Mapping/Subclass.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections;
33
using System.Collections.Generic;
4+
using System.Collections.ObjectModel;
45
using System.Linq;
56
using NHibernate.Engine;
67
using NHibernate.Util;
@@ -189,7 +190,7 @@ public override IDictionary<EntityMode, string> TuplizerMap
189190
{
190191
ArrayHelper.AddAll(combined, specificTuplizerDefs);
191192
}
192-
return new UnmodifiableDictionary<EntityMode, string>(combined);
193+
return new ReadOnlyDictionary<EntityMode, string>(combined);
193194
}
194195
}
195196
}

src/NHibernate/Util/UnmodifiableDictionary.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ namespace NHibernate.Util
1313
/// </summary>
1414
/// <typeparam name="TKey">The type of keys in the dictionary.</typeparam>
1515
/// <typeparam name="TValue">The type of values in the dictionary.</typeparam>
16+
//Since v5.1
17+
[Obsolete("Please use System.Collections.ObjectModel.ReadOnlyDictionary<K,V> instead.")]
1618
[Serializable]
1719
public class UnmodifiableDictionary<TKey, TValue> : IDictionary<TKey, TValue>
1820
{

0 commit comments

Comments
 (0)