Permalink
Browse files

Make IPersistentCollection.GetSnapshot() return object instead of ICo…

…llection. Some of the implementations return sets, and when those are BCL sets they don't implement non-generic ICollection. Since the contents of the snapshots are never accessed outside each type of persistent collection (and probably never should be), we might as well make it a completely opaque object.
  • Loading branch information...
1 parent 2d324e0 commit f4c3e2e3955d05472e669e16e965b6bd091567a4 @oskarb oskarb committed Jul 4, 2012
@@ -797,7 +797,7 @@ public virtual object GetIdentifier(object entry, int i)
public abstract IEnumerable Entries(ICollectionPersister persister);
- public abstract ICollection GetSnapshot(ICollectionPersister persister);
+ public abstract object GetSnapshot(ICollectionPersister persister);
public abstract bool EqualsSnapshot(ICollectionPersister persister);
@@ -30,7 +30,7 @@ public PersistentGenericMap(ISessionImplementor session, IDictionary<TKey, TValu
gmap = map;
}
- public override ICollection GetSnapshot(ICollectionPersister persister)
+ public override object GetSnapshot(ICollectionPersister persister)
{
EntityMode entityMode = Session.EntityMode;
Dictionary<TKey, TValue> clonedMap = new Dictionary<TKey, TValue>(map.Count);
@@ -87,7 +87,7 @@ public override bool RowUpdatePossible
get { return false; }
}
- public override ICollection GetSnapshot(ICollectionPersister persister)
+ public override object GetSnapshot(ICollectionPersister persister)
{
var entityMode = Session.EntityMode;
var clonedSet = new SetSnapShot<T>(set.Count);
@@ -251,7 +251,7 @@ public interface IPersistentCollection
/// <summary>
/// Return a new snapshot of the current state of the collection
/// </summary>
- ICollection GetSnapshot(ICollectionPersister persister);
+ object GetSnapshot(ICollectionPersister persister);
/// <summary>
/// To be called internally by the session, forcing
@@ -67,7 +67,7 @@ public override object GetValue()
return array;
}
- public override ICollection GetSnapshot(ICollectionPersister persister)
+ public override object GetSnapshot(ICollectionPersister persister)
{
EntityMode entityMode = Session.EntityMode;
@@ -132,7 +132,7 @@ private static int CountOccurrences(object element, IList list, IType elementTyp
return result;
}
- public override ICollection GetSnapshot(ICollectionPersister persister)
+ public override object GetSnapshot(ICollectionPersister persister)
{
EntityMode entityMode = Session.EntityMode;
List<object> clonedList = new List<object>(bag.Count);
@@ -196,7 +196,7 @@ public override bool EqualsSnapshot(ICollectionPersister persister)
public override bool IsSnapshotEmpty(object snapshot)
{
- return ((ICollection) snapshot).Count == 0;
+ return ((ISet<SnapshotElement>) snapshot).Count == 0;
}
public override IEnumerable GetDeletes(ICollectionPersister persister, bool indexIsFormula)
@@ -271,7 +271,7 @@ public override object ReadFrom(IDataReader reader, ICollectionPersister persist
return element;
}
- public override ICollection GetSnapshot(ICollectionPersister persister)
+ public override object GetSnapshot(ICollectionPersister persister)
{
EntityMode entityMode = Session.EntityMode;
@@ -51,7 +51,7 @@ public PersistentList(ISessionImplementor session, IList list) : base(session)
IsDirectlyAccessible = true;
}
- public override ICollection GetSnapshot(ICollectionPersister persister)
+ public override object GetSnapshot(ICollectionPersister persister)
{
EntityMode entityMode = Session.EntityMode;
@@ -42,7 +42,7 @@ public PersistentMap(ISessionImplementor session, IDictionary map) : base(sessio
IsDirectlyAccessible = true;
}
- public override ICollection GetSnapshot(ICollectionPersister persister)
+ public override object GetSnapshot(ICollectionPersister persister)
{
EntityMode entityMode = Session.EntityMode;
Hashtable clonedMap = new Hashtable(map.Count);

0 comments on commit f4c3e2e

Please sign in to comment.