From: Kevin W. <kev...@us...> - 2004-12-31 16:36:58
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Collection In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7676 Modified Files: ArrayHolder.cs Bag.cs CollectionPersister.cs IdentifierBag.cs List.cs Map.cs PersistentCollection.cs Set.cs SortedMap.cs SortedSet.cs Log Message: fixing xml comments and letting ReSharper do reformatting Index: Bag.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Collection/Bag.cs,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Bag.cs 29 Nov 2004 04:45:50 -0000 1.10 --- Bag.cs 31 Dec 2004 16:36:46 -0000 1.11 *************** *** 2,6 **** using System.Collections; using System.Data; - using NHibernate.Engine; using NHibernate.Type; --- 2,5 ---- *************** *** 22,37 **** private IList bagIdentifiers; ! public Bag(ISessionImplementor session) : base(session) { } ! public Bag(ISessionImplementor session, ICollection coll) : base(session) { bag = coll as IList; ! ! if(bag == null) { bag = new ArrayList(); ! ((ArrayList)bag).AddRange(coll); } --- 21,45 ---- private IList bagIdentifiers; ! /// <summary> ! /// ! /// </summary> ! /// <param name="session"></param> ! public Bag( ISessionImplementor session ) : base( session ) { } ! /// <summary> ! /// ! /// </summary> ! /// <param name="session"></param> ! /// <param name="coll"></param> ! public Bag( ISessionImplementor session, ICollection coll ) : base( session ) { bag = coll as IList; ! ! if( bag == null ) { bag = new ArrayList(); ! ( ( ArrayList ) bag ).AddRange( coll ); } *************** *** 40,54 **** } ! public Bag(ISessionImplementor session, CollectionPersister persister, object disassembled, object owner) : base(session) { ! BeforeInitialize(persister); ! object[] array = (object[])disassembled; ! for(int i=0; i<array.Length; i++) { ! bag.Add(persister.ElementType.Assemble(array[i], session, owner)); } initialized = true; } public override ICollection Elements() { --- 48,73 ---- } ! /// <summary> ! /// ! /// </summary> ! /// <param name="session"></param> ! /// <param name="persister"></param> ! /// <param name="disassembled"></param> ! /// <param name="owner"></param> ! public Bag( ISessionImplementor session, CollectionPersister persister, object disassembled, object owner ) : base( session ) { ! BeforeInitialize( persister ); ! object[ ] array = ( object[ ] ) disassembled; ! for( int i = 0; i < array.Length; i++ ) { ! bag.Add( persister.ElementType.Assemble( array[ i ], session, owner ) ); } initialized = true; } + /// <summary> + /// + /// </summary> + /// <returns></returns> public override ICollection Elements() { *************** *** 56,64 **** } public override bool Empty { ! get{ return bag.Count==0;} } public override ICollection Entries() { --- 75,90 ---- } + /// <summary> + /// + /// </summary> public override bool Empty { ! get { return bag.Count == 0; } } + /// <summary> + /// + /// </summary> + /// <returns></returns> public override ICollection Entries() { *************** *** 66,78 **** } ! public override void EndRead(CollectionPersister persister, object owner) { ! for(int i = 0 ;i < bagIdentifiers.Count; i++) { ! object element = persister.ElementType.ResolveIdentifier(bagIdentifiers[i], session, owner); bag.Add( element ); } ! if( Additions!=null ) { DelayedAddAll( Additions ); --- 92,109 ---- } ! /// <summary> ! /// ! /// </summary> ! /// <param name="persister"></param> ! /// <param name="owner"></param> ! public override void EndRead( CollectionPersister persister, object owner ) { ! for( int i = 0; i < bagIdentifiers.Count; i++ ) { ! object element = persister.ElementType.ResolveIdentifier( bagIdentifiers[ i ], session, owner ); bag.Add( element ); } ! if( Additions != null ) { DelayedAddAll( Additions ); *************** *** 82,99 **** ! public override object ReadFrom(IDataReader reader, CollectionPersister persister, object owner) { ! object elementIdentifier = persister.ReadElementIdentifier(reader, owner, session); bagIdentifiers.Add( elementIdentifier ); ! return elementIdentifier; } ! public override void WriteTo(IDbCommand st, CollectionPersister persister, object entry, int i, bool writeOrder) { ! persister.WriteElement(st, entry, writeOrder, session); } ! public override void BeforeInitialize(CollectionPersister persister) { this.bag = new ArrayList(); --- 113,149 ---- ! /// <summary> ! /// ! /// </summary> ! /// <param name="reader"></param> ! /// <param name="persister"></param> ! /// <param name="owner"></param> ! /// <returns></returns> ! public override object ReadFrom( IDataReader reader, CollectionPersister persister, object owner ) { ! object elementIdentifier = persister.ReadElementIdentifier( reader, owner, session ); bagIdentifiers.Add( elementIdentifier ); ! return elementIdentifier; } ! /// <summary> ! /// ! /// </summary> ! /// <param name="st"></param> ! /// <param name="persister"></param> ! /// <param name="entry"></param> ! /// <param name="i"></param> ! /// <param name="writeOrder"></param> ! public override void WriteTo( IDbCommand st, CollectionPersister persister, object entry, int i, bool writeOrder ) { ! persister.WriteElement( st, entry, writeOrder, session ); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="persister"></param> ! public override void BeforeInitialize( CollectionPersister persister ) { this.bag = new ArrayList(); *************** *** 101,123 **** } ! public override bool EqualsSnapshot(IType elementType) { ! IList sn = (IList)GetSnapshot(); ! if(sn.Count!=bag.Count) return false; ! foreach(object elt in bag) { ! if ( CountOccurrences(elt, bag, elementType)!=CountOccurrences(elt, sn, elementType) ) return false; } ! return true; } ! private int CountOccurrences(object element, IList list, IType elementType) { int result = 0; ! foreach(object obj in list) { ! if ( elementType.Equals(element, obj) ) result++; } --- 151,194 ---- } ! /// <summary> ! /// ! /// </summary> ! /// <param name="elementType"></param> ! /// <returns></returns> ! public override bool EqualsSnapshot( IType elementType ) { ! IList sn = ( IList ) GetSnapshot(); ! if( sn.Count != bag.Count ) ! { ! return false; ! } ! foreach( object elt in bag ) { ! if( CountOccurrences( elt, bag, elementType ) != CountOccurrences( elt, sn, elementType ) ) ! { ! return false; ! } } ! return true; } ! /// <summary> ! /// ! /// </summary> ! /// <param name="element"></param> ! /// <param name="list"></param> ! /// <param name="elementType"></param> ! /// <returns></returns> ! private int CountOccurrences( object element, IList list, IType elementType ) { int result = 0; ! foreach( object obj in list ) { ! if( elementType.Equals( element, obj ) ) ! { ! result++; ! } } *************** *** 125,155 **** } ! protected override object Snapshot(CollectionPersister persister) { ArrayList clonedList = new ArrayList( bag.Count ); ! foreach(object obj in bag) { ! clonedList.Add( persister.ElementType.DeepCopy(obj) ); } return clonedList; } ! public override ICollection GetOrphans(object snapshot) { ! IList sn = (IList)snapshot; ArrayList result = new ArrayList(); ! result.AddRange(sn); ! PersistentCollection.IdentityRemoveAll(result, bag, session); return result; } ! public override object Disassemble(CollectionPersister persister) { int length = bag.Count; ! object[] result = new object[length]; ! for(int i = 0; i<length; i++) { ! result[i] = persister.ElementType.Disassemble(bag[i], session); } --- 196,241 ---- } ! /// <summary> ! /// ! /// </summary> ! /// <param name="persister"></param> ! /// <returns></returns> ! protected override object Snapshot( CollectionPersister persister ) { ArrayList clonedList = new ArrayList( bag.Count ); ! foreach( object obj in bag ) { ! clonedList.Add( persister.ElementType.DeepCopy( obj ) ); } return clonedList; } ! /// <summary> ! /// ! /// </summary> ! /// <param name="snapshot"></param> ! /// <returns></returns> ! public override ICollection GetOrphans( object snapshot ) { ! IList sn = ( IList ) snapshot; ArrayList result = new ArrayList(); ! result.AddRange( sn ); ! PersistentCollection.IdentityRemoveAll( result, bag, session ); return result; } ! /// <summary> ! /// ! /// </summary> ! /// <param name="persister"></param> ! /// <returns></returns> ! public override object Disassemble( CollectionPersister persister ) { int length = bag.Count; ! object[ ] result = new object[length]; ! for( int i = 0; i < length; i++ ) { ! result[ i ] = persister.ElementType.Disassemble( bag[ i ], session ); } *************** *** 168,172 **** /// <c>many-to-many</c> so it is just recreated. /// </returns> ! public override bool NeedsRecreate(CollectionPersister persister) { return !persister.IsOneToMany; --- 254,258 ---- /// <c>many-to-many</c> so it is just recreated. /// </returns> ! public override bool NeedsRecreate( CollectionPersister persister ) { return !persister.IsOneToMany; *************** *** 178,206 **** // same element twice. It could be considered a bug // in the mapping dtd that <bag> allows <one-to-many>. ! // Anyway, here we implement <set> semantics for a // <one-to-many> <bag>! ! ! public override ICollection GetDeletes(IType elemType) { ArrayList deletes = new ArrayList(); ! IList sn = (IList)GetSnapshot(); int i = 0; ! ! foreach(object oldObject in sn) { bool found = false; ! if(bag.Count>i && elemType.Equals(oldObject, bag[i++])) { //a shortcut if its location didn't change! found = true; } ! else { //search for it ! foreach(object newObject in bag) { ! if( elemType.Equals(oldObject, newObject) ) { found = true; --- 264,297 ---- // same element twice. It could be considered a bug // in the mapping dtd that <bag> allows <one-to-many>. ! // Anyway, here we implement <set> semantics for a // <one-to-many> <bag>! ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="elemType"></param> ! /// <returns></returns> ! public override ICollection GetDeletes( IType elemType ) { ArrayList deletes = new ArrayList(); ! IList sn = ( IList ) GetSnapshot(); int i = 0; ! ! foreach( object oldObject in sn ) { bool found = false; ! if( bag.Count > i && elemType.Equals( oldObject, bag[ i++ ] ) ) { //a shortcut if its location didn't change! found = true; } ! else { //search for it ! foreach( object newObject in bag ) { ! if( elemType.Equals( oldObject, newObject ) ) { found = true; *************** *** 209,213 **** } } ! if(!found) deletes.Add(oldObject); } --- 300,307 ---- } } ! if( !found ) ! { ! deletes.Add( oldObject ); ! } } *************** *** 215,232 **** } ! public override bool NeedsInserting(object entry, int i, IType elemType) { ! IList sn = (IList)GetSnapshot(); ! if( sn.Count>i && elemType.Equals(sn[i], entry) ) { // a shortcut if its location didn't change return false; } ! else { //search for it ! foreach( object oldObject in sn ) { ! if( elemType.Equals(oldObject, entry) ) return false; } return true; --- 309,336 ---- } ! /// <summary> ! /// ! /// </summary> ! /// <param name="entry"></param> ! /// <param name="i"></param> ! /// <param name="elemType"></param> ! /// <returns></returns> ! public override bool NeedsInserting( object entry, int i, IType elemType ) { ! IList sn = ( IList ) GetSnapshot(); ! if( sn.Count > i && elemType.Equals( sn[ i ], entry ) ) { // a shortcut if its location didn't change return false; } ! else { //search for it ! foreach( object oldObject in sn ) { ! if( elemType.Equals( oldObject, entry ) ) ! { ! return false; ! } } return true; *************** *** 234,245 **** } ! public override bool NeedsUpdating(object entry, int i, IType elemType) { return false; } - #region IList Members public bool IsReadOnly { --- 338,358 ---- } ! /// <summary> ! /// ! /// </summary> ! /// <param name="entry"></param> ! /// <param name="i"></param> ! /// <param name="elemType"></param> ! /// <returns></returns> ! public override bool NeedsUpdating( object entry, int i, IType elemType ) { return false; } #region IList Members + /// <summary> + /// + /// </summary> public bool IsReadOnly { *************** *** 247,288 **** } ! public object this[int index] { ! get ! { Read(); ! return bag[index]; } set { Write(); ! bag[index] = value; } } ! public void RemoveAt(int index) { Write(); ! bag.RemoveAt(index); } ! public void Insert(int index, object value) { Write(); ! bag.Insert(index, value); } ! public void Remove(object value) { Write(); ! bag.Remove(value); } ! public bool Contains(object value) { Read(); ! return bag.Contains(value); } public void Clear() { --- 360,425 ---- } ! /// <summary> ! /// ! /// </summary> ! public object this[ int index ] { ! get ! { Read(); ! return bag[ index ]; } set { Write(); ! bag[ index ] = value; } } ! /// <summary> ! /// ! /// </summary> ! /// <param name="index"></param> ! public void RemoveAt( int index ) { Write(); ! bag.RemoveAt( index ); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="index"></param> ! /// <param name="value"></param> ! public void Insert( int index, object value ) { Write(); ! bag.Insert( index, value ); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="value"></param> ! public void Remove( object value ) { Write(); ! bag.Remove( value ); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="value"></param> ! /// <returns></returns> ! public bool Contains( object value ) { Read(); ! return bag.Contains( value ); } + /// <summary> + /// + /// </summary> public void Clear() { *************** *** 291,308 **** } ! public int IndexOf(object value) { Read(); ! return bag.IndexOf(value); } ! public int Add(object value) { ! if ( !QueueAdd(value) ) { Write(); ! return bag.Add(value); } ! else { //TODO: take a look at this - I don't like it because it changes the --- 428,455 ---- } ! /// <summary> ! /// ! /// </summary> ! /// <param name="value"></param> ! /// <returns></returns> ! public int IndexOf( object value ) { Read(); ! return bag.IndexOf( value ); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="value"></param> ! /// <returns></returns> ! public int Add( object value ) { ! if( !QueueAdd( value ) ) { Write(); ! return bag.Add( value ); } ! else { //TODO: take a look at this - I don't like it because it changes the *************** *** 313,316 **** --- 460,466 ---- } + /// <summary> + /// + /// </summary> public bool IsFixedSize { *************** *** 322,325 **** --- 472,478 ---- #region ICollection Members + /// <summary> + /// + /// </summary> public override bool IsSynchronized { *************** *** 327,330 **** --- 480,486 ---- } + /// <summary> + /// + /// </summary> public override int Count { *************** *** 336,348 **** } ! public override void CopyTo(Array array, int index) { Read(); ! bag.CopyTo(array, index); } public override object SyncRoot { ! get { return this; } } --- 492,512 ---- } ! /// <summary> ! /// ! /// </summary> ! /// <param name="array"></param> ! /// <param name="index"></param> ! public override void CopyTo( Array array, int index ) { Read(); ! bag.CopyTo( array, index ); } + /// <summary> + /// + /// </summary> public override object SyncRoot { ! get { return this; } } *************** *** 351,354 **** --- 515,522 ---- #region IEnumerable Members + /// <summary> + /// + /// </summary> + /// <returns></returns> public override IEnumerator GetEnumerator() { *************** *** 358,381 **** #endregion ! ! public override void DelayedAddAll(ICollection coll) { ! foreach(object obj in coll) { ! bag.Add(obj); } } ! public override object GetIndex(object entry, int i) { ! throw new NotSupportedException("Bags don't have indexes"); } ! public override bool EntryExists(object entry, int i) { ! return entry!=null; } } ! } --- 526,565 ---- #endregion ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="coll"></param> ! public override void DelayedAddAll( ICollection coll ) { ! foreach( object obj in coll ) { ! bag.Add( obj ); } } ! /// <summary> ! /// ! /// </summary> ! /// <param name="entry"></param> ! /// <param name="i"></param> ! /// <returns></returns> ! public override object GetIndex( object entry, int i ) { ! throw new NotSupportedException( "Bags don't have indexes" ); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="entry"></param> ! /// <param name="i"></param> ! /// <returns></returns> ! public override bool EntryExists( object entry, int i ) { ! return entry != null; } } ! } \ No newline at end of file Index: Map.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Collection/Map.cs,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** Map.cs 22 Sep 2004 22:33:05 -0000 1.16 --- Map.cs 31 Dec 2004 16:36:46 -0000 1.17 *************** *** 1,9 **** using System; - using System.Data; using System.Collections; using NHibernate.Engine; using NHibernate.Type; ! namespace NHibernate.Collection { /// <summary> --- 1,10 ---- using System; using System.Collections; + using System.Collections.Specialized; + using System.Data; using NHibernate.Engine; using NHibernate.Type; ! namespace NHibernate.Collection { /// <summary> *************** *** 12,44 **** /// </summary> [Serializable] ! public class Map : PersistentCollection, IDictionary { ! protected IDictionary map; protected IDictionary mapIdentifiers; ! protected override object Snapshot(CollectionPersister persister) { Hashtable clonedMap = new Hashtable( map.Count ); ! foreach(DictionaryEntry e in map) { ! clonedMap[e.Key] = persister.ElementType.DeepCopy( e.Value ); } return clonedMap; } ! public override ICollection GetOrphans(object snapshot) { ! IDictionary sn = (IDictionary)snapshot; ! ArrayList result = new ArrayList(sn.Values.Count); ! result.AddRange(sn.Values); ! PersistentCollection.IdentityRemoveAll(result, map.Values, session); return result; } ! public override bool EqualsSnapshot(IType elementType) { ! IDictionary xmap = (IDictionary) GetSnapshot(); ! if ( xmap.Count!=this.map.Count ) return false; ! foreach(DictionaryEntry entry in map) { ! if ( elementType.IsDirty( entry.Value, xmap[entry.Key], session)) return false; } return true; --- 13,70 ---- /// </summary> [Serializable] ! public class Map : PersistentCollection, IDictionary { ! /// <summary></summary> protected IDictionary map; + /// <summary></summary> protected IDictionary mapIdentifiers; ! /// <summary> ! /// ! /// </summary> ! /// <param name="persister"></param> ! /// <returns></returns> ! protected override object Snapshot( CollectionPersister persister ) ! { Hashtable clonedMap = new Hashtable( map.Count ); ! foreach( DictionaryEntry e in map ) ! { ! clonedMap[ e.Key ] = persister.ElementType.DeepCopy( e.Value ); } return clonedMap; } ! /// <summary> ! /// ! /// </summary> ! /// <param name="snapshot"></param> ! /// <returns></returns> ! public override ICollection GetOrphans( object snapshot ) { ! IDictionary sn = ( IDictionary ) snapshot; ! ArrayList result = new ArrayList( sn.Values.Count ); ! result.AddRange( sn.Values ); ! PersistentCollection.IdentityRemoveAll( result, map.Values, session ); return result; } ! /// <summary> ! /// ! /// </summary> ! /// <param name="elementType"></param> ! /// <returns></returns> ! public override bool EqualsSnapshot( IType elementType ) { ! IDictionary xmap = ( IDictionary ) GetSnapshot(); ! if( xmap.Count != this.map.Count ) ! { ! return false; ! } ! foreach( DictionaryEntry entry in map ) ! { ! if( elementType.IsDirty( entry.Value, xmap[ entry.Key ], session ) ) ! { ! return false; ! } } return true; *************** *** 49,54 **** /// </summary> /// <param name="session">The ISession the Map should be a part of.</param> ! public Map(ISessionImplementor session) : base(session) { } ! /// <summary> /// Construct an initialized Map from its disassembled state. --- 75,82 ---- /// </summary> /// <param name="session">The ISession the Map should be a part of.</param> ! public Map( ISessionImplementor session ) : base( session ) ! { ! } ! /// <summary> /// Construct an initialized Map from its disassembled state. *************** *** 58,67 **** /// <param name="disassembled">The disassembled Map.</param> /// <param name="owner">The owner object.</param> ! public Map(ISessionImplementor session, CollectionPersister persister, object disassembled, object owner) : base(session) { ! BeforeInitialize(persister); ! object[] array = (object[]) disassembled; ! for (int i=0; i<array.Length; i+=2) ! map[ persister.IndexType.Assemble( array[i], session, owner) ] = ! persister.ElementType.Assemble( array[i+1], session, owner ); initialized = true; } --- 86,98 ---- /// <param name="disassembled">The disassembled Map.</param> /// <param name="owner">The owner object.</param> ! public Map( ISessionImplementor session, CollectionPersister persister, object disassembled, object owner ) : base( session ) ! { ! BeforeInitialize( persister ); ! object[ ] array = ( object[ ] ) disassembled; ! for( int i = 0; i < array.Length; i += 2 ) ! { ! map[ persister.IndexType.Assemble( array[ i ], session, owner ) ] = ! persister.ElementType.Assemble( array[ i + 1 ], session, owner ); ! } initialized = true; } *************** *** 72,76 **** /// <param name="session">The ISession the Map should be a part of.</param> /// <param name="map">The IDictionary that contains the initial values.</param> ! public Map(ISessionImplementor session, IDictionary map) : base(session) { this.map = map; --- 103,107 ---- /// <param name="session">The ISession the Map should be a part of.</param> /// <param name="map">The IDictionary that contains the initial values.</param> ! public Map( ISessionImplementor session, IDictionary map ) : base( session ) { this.map = map; *************** *** 79,95 **** } ! ! public override void BeforeInitialize(CollectionPersister persister) { ! ! if(persister.HasOrdering) { // if this Persister has an Ordering then use the ListDictionary because // it maintains items in the Dictionary in the same order as they were // added. ! this.map = new System.Collections.Specialized.ListDictionary(); ! this.mapIdentifiers = new System.Collections.Specialized.ListDictionary(); } ! else { this.map = new Hashtable(); --- 110,128 ---- } ! /// <summary> ! /// ! /// </summary> ! /// <param name="persister"></param> ! public override void BeforeInitialize( CollectionPersister persister ) { ! if( persister.HasOrdering ) { // if this Persister has an Ordering then use the ListDictionary because // it maintains items in the Dictionary in the same order as they were // added. ! this.map = new ListDictionary(); ! this.mapIdentifiers = new ListDictionary(); } ! else { this.map = new Hashtable(); *************** *** 98,103 **** } ! public override int Count { ! get { Read(); return map.Count; --- 131,139 ---- } ! /// <summary></summary> ! public override int Count ! { ! get ! { Read(); return map.Count; *************** *** 105,274 **** } ! public override bool IsSynchronized { get { return false; } } ! public bool IsFixedSize { get { return false; } } ! public bool IsReadOnly { get { return false; } } ! public override object SyncRoot { get { return this; } } ! public ICollection Keys { ! get ! { Read(); ! return map.Keys; } } ! public ICollection Values { ! get ! { Read(); return map.Values; } ! } ! public override IEnumerator GetEnumerator() { Read(); return map.GetEnumerator(); ! } ! IEnumerator IEnumerable.GetEnumerator() { Read(); return map.GetEnumerator(); ! } ! IDictionaryEnumerator IDictionary.GetEnumerator() { Read(); return map.GetEnumerator(); } ! public override void CopyTo(System.Array array, int index) { Read(); ! map.CopyTo(array, index); } ! public void Add(object key, object value) { Write(); ! map.Add(key, value); } ! public bool Contains(object key) { Read(); ! return map.Contains(key); } ! public object this [object key] { ! get { Read(); ! return map[key]; } ! set { Write(); ! map[key] = value; } } ! public void Remove(object key) { Write(); ! map.Remove(key); } ! public void Clear() { Write(); map.Clear(); } ! public override void EndRead(CollectionPersister persister, object owner) { ! foreach(DictionaryEntry entry in mapIdentifiers){ object index = entry.Key; object elementIdentifier = entry.Value; ! object element = persister.ElementType.ResolveIdentifier(elementIdentifier, session, owner); ! map[index] = element; } } ! public override ICollection Elements() { return map.Values; } ! public override bool Empty { ! get { return map.Count==0; } } ! public override string ToString() { Read(); return map.ToString(); } ! public override void WriteTo(IDbCommand st, CollectionPersister persister, object entry, int i, bool writeOrder) { ! DictionaryEntry e = (DictionaryEntry) entry; ! persister.WriteElement(st, e.Value, writeOrder, session); ! persister.WriteIndex(st, e.Key, writeOrder, session); } ! public override object ReadFrom(IDataReader rs, CollectionPersister persister, object owner) { //object element = persister.ReadElement(rs, owner, session); ! object elementIdentifier = persister.ReadElementIdentifier(rs, owner, session); ! object index = persister.ReadIndex(rs, session); ! map[index] = null; ! mapIdentifiers[index] = elementIdentifier; return elementIdentifier; } ! public override ICollection Entries() { ArrayList entries = new ArrayList(); ! foreach(DictionaryEntry entry in map) { ! entries.Add(entry); } return entries; } ! public override object Disassemble(CollectionPersister persister) { ! object[] result = new object[map.Count * 2]; ! int i=0; ! foreach(DictionaryEntry e in map) { ! result[i++] = persister.IndexType.Disassemble( e.Key, session ); ! result[i++] = persister.ElementType.Disassemble( e.Value, session ); } return result; } ! public override ICollection GetDeletes(IType elemType) { IList deletes = new ArrayList(); ! foreach(DictionaryEntry e in ((IDictionary)GetSnapshot())) { object key = e.Key; ! if ( e.Value!=null && map[key]==null ) deletes.Add(key); } return deletes; } ! public override bool NeedsInserting(object entry, int i, IType elemType) { ! IDictionary sn = (IDictionary) GetSnapshot(); ! DictionaryEntry e = (DictionaryEntry) entry; ! return (e.Value!=null && sn[e.Key] == null); } ! public override bool NeedsUpdating(object entry, int i, IType elemType) { ! IDictionary sn = (IDictionary) GetSnapshot(); ! DictionaryEntry e = (DictionaryEntry) entry; ! object snValue = sn[e.Key]; ! return (e.Value != null && snValue!=null && elemType.IsDirty(snValue, e.Value, session) ); } ! public override object GetIndex(object entry, int i) { ! return ((DictionaryEntry)entry).Key; } ! public override bool EntryExists(object entry, int i) { ! return ( (DictionaryEntry)entry).Value!=null; } - } ! } --- 141,446 ---- } ! /// <summary></summary> ! public override bool IsSynchronized ! { get { return false; } } ! ! /// <summary></summary> ! public bool IsFixedSize ! { get { return false; } } ! ! /// <summary></summary> ! public bool IsReadOnly ! { get { return false; } } ! ! /// <summary></summary> ! public override object SyncRoot ! { get { return this; } } ! ! /// <summary></summary> ! public ICollection Keys { ! get ! { Read(); ! return map.Keys; } } ! ! /// <summary></summary> ! public ICollection Values { ! get ! { Read(); return map.Values; } ! } ! ! /// <summary></summary> ! public override IEnumerator GetEnumerator() ! { Read(); return map.GetEnumerator(); ! } ! /// <summary></summary> ! IEnumerator IEnumerable.GetEnumerator() ! { Read(); return map.GetEnumerator(); ! } ! /// <summary></summary> ! IDictionaryEnumerator IDictionary.GetEnumerator() ! { Read(); return map.GetEnumerator(); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="array"></param> ! /// <param name="index"></param> ! public override void CopyTo( Array array, int index ) ! { Read(); ! map.CopyTo( array, index ); } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="key"></param> ! /// <param name="value"></param> ! public void Add( object key, object value ) ! { Write(); ! map.Add( key, value ); } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="key"></param> ! /// <returns></returns> ! public bool Contains( object key ) ! { Read(); ! return map.Contains( key ); } ! /// <summary></summary> ! public object this[ object key ] ! { ! get ! { Read(); ! return map[ key ]; } ! set ! { Write(); ! map[ key ] = value; } } ! /// <summary> ! /// ! /// </summary> ! /// <param name="key"></param> ! public void Remove( object key ) ! { Write(); ! map.Remove( key ); } ! /// <summary></summary> ! public void Clear() ! { Write(); map.Clear(); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="persister"></param> ! /// <param name="owner"></param> ! public override void EndRead( CollectionPersister persister, object owner ) ! { ! foreach( DictionaryEntry entry in mapIdentifiers ) ! { object index = entry.Key; object elementIdentifier = entry.Value; ! object element = persister.ElementType.ResolveIdentifier( elementIdentifier, session, owner ); ! map[ index ] = element; } } ! /// <summary></summary> ! public override ICollection Elements() ! { return map.Values; } ! ! /// <summary></summary> ! public override bool Empty ! { ! get { return map.Count == 0; } } ! ! /// <summary></summary> ! public override string ToString() ! { Read(); return map.ToString(); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="st"></param> ! /// <param name="persister"></param> ! /// <param name="entry"></param> ! /// <param name="i"></param> ! /// <param name="writeOrder"></param> ! public override void WriteTo( IDbCommand st, CollectionPersister persister, object entry, int i, bool writeOrder ) ! { ! DictionaryEntry e = ( DictionaryEntry ) entry; ! persister.WriteElement( st, e.Value, writeOrder, session ); ! persister.WriteIndex( st, e.Key, writeOrder, session ); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="rs"></param> ! /// <param name="persister"></param> ! /// <param name="owner"></param> ! /// <returns></returns> ! public override object ReadFrom( IDataReader rs, CollectionPersister persister, object owner ) ! { //object element = persister.ReadElement(rs, owner, session); ! object elementIdentifier = persister.ReadElementIdentifier( rs, owner, session ); ! object index = persister.ReadIndex( rs, session ); ! map[ index ] = null; ! mapIdentifiers[ index ] = elementIdentifier; return elementIdentifier; } ! /// <summary></summary> ! public override ICollection Entries() ! { ArrayList entries = new ArrayList(); ! foreach( DictionaryEntry entry in map ) ! { ! entries.Add( entry ); } return entries; } ! /// <summary> ! /// ! /// </summary> ! /// <param name="persister"></param> ! /// <returns></returns> ! public override object Disassemble( CollectionPersister persister ) ! { ! object[ ] result = new object[map.Count*2]; ! int i = 0; ! foreach( DictionaryEntry e in map ) ! { ! result[ i++ ] = persister.IndexType.Disassemble( e.Key, session ); ! result[ i++ ] = persister.ElementType.Disassemble( e.Value, session ); } return result; } ! /// <summary> ! /// ! /// </summary> ! /// <param name="elemType"></param> ! /// <returns></returns> ! public override ICollection GetDeletes( IType elemType ) ! { IList deletes = new ArrayList(); ! foreach( DictionaryEntry e in ( ( IDictionary ) GetSnapshot() ) ) ! { object key = e.Key; ! if( e.Value != null && map[ key ] == null ) ! { ! deletes.Add( key ); ! } } return deletes; } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="entry"></param> ! /// <param name="i"></param> ! /// <param name="elemType"></param> ! /// <returns></returns> ! public override bool NeedsInserting( object entry, int i, IType elemType ) ! { ! IDictionary sn = ( IDictionary ) GetSnapshot(); ! DictionaryEntry e = ( DictionaryEntry ) entry; ! return ( e.Value != null && sn[ e.Key ] == null ); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="entry"></param> ! /// <param name="i"></param> ! /// <param name="elemType"></param> ! /// <returns></returns> ! public override bool NeedsUpdating( object entry, int i, IType elemType ) ! { ! IDictionary sn = ( IDictionary ) GetSnapshot(); ! DictionaryEntry e = ( DictionaryEntry ) entry; ! object snValue = sn[ e.Key ]; ! return ( e.Value != null && snValue != null && elemType.IsDirty( snValue, e.Value, session ) ); } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="entry"></param> ! /// <param name="i"></param> ! /// <returns></returns> ! public override object GetIndex( object entry, int i ) ! { ! return ( ( DictionaryEntry ) entry ).Key; } ! /// <summary> ! /// ! /// </summary> ! /// <param name="entry"></param> ! /// <param name="i"></param> ! /// <returns></returns> ! public override bool EntryExists( object entry, int i ) ! { ! return ( ( DictionaryEntry ) entry ).Value != null; } } ! } \ No newline at end of file Index: PersistentCollection.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Collection/PersistentCollection.cs,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** PersistentCollection.cs 29 Nov 2004 04:45:50 -0000 1.17 --- PersistentCollection.cs 31 Dec 2004 16:36:46 -0000 1.18 *************** *** 1,9 **** using System; - using System.Data; using System.Collections; using NHibernate.Engine; using NHibernate.Type; ! namespace NHibernate.Collection { /// <summary> --- 1,10 ---- using System; using System.Collections; + using System.Data; + using log4net; using NHibernate.Engine; using NHibernate.Type; ! namespace NHibernate.Collection { /// <summary> *************** *** 36,69 **** public abstract class PersistentCollection : ICollection { ! private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(PersistentCollection)); ! [NonSerialized] protected ISessionImplementor session; protected bool initialized; ! [NonSerialized] private ArrayList additions; private ICollectionSnapshot collectionSnapshot; ! [NonSerialized] protected bool directlyAccessible; //careful: these methods do not initialize the collection public abstract ICollection Elements(); public abstract bool Empty { get; } ! public void Read() { ! Initialize(false); } ! private bool IsConnectedToSession ! { ! get {return session!=null && session.IsOpen;} } ! protected void Write() { ! Initialize(true); ! if (IsConnectedToSession) { ! session.Dirty(this); ! } ! else { collectionSnapshot.SetDirty(); --- 37,86 ---- public abstract class PersistentCollection : ICollection { ! private static readonly ILog log = LogManager.GetLogger( typeof( PersistentCollection ) ); ! /// <summary></summary> ! [NonSerialized] ! protected ISessionImplementor session; ! ! /// <summary></summary> protected bool initialized; ! ! [NonSerialized] ! private ArrayList additions; ! private ICollectionSnapshot collectionSnapshot; ! ! /// <summary></summary> ! [NonSerialized] ! protected bool directlyAccessible; //careful: these methods do not initialize the collection + + /// <summary></summary> public abstract ICollection Elements(); + + /// <summary></summary> public abstract bool Empty { get; } ! /// <summary></summary> ! public void Read() { ! Initialize( false ); } ! private bool IsConnectedToSession ! { ! get { return session != null && session.IsOpen; } } ! /// <summary></summary> ! protected void Write() { ! Initialize( true ); ! if( IsConnectedToSession ) { ! session.Dirty( this ); ! } ! else { collectionSnapshot.SetDirty(); *************** *** 71,95 **** } ! private bool MayQueueAdd { ! get { ! return !initialized && ! IsConnectedToSession && ! session.IsInverseCollection(this); } } ! protected bool QueueAdd(object element) { ! if ( MayQueueAdd ) { ! if (additions == null) additions = new ArrayList(10); ! additions.Add(element); ! session.Dirty(this); //needed so that we remove this collection from the JCS cache return true; ! } ! else { return false; --- 88,116 ---- } ! private bool MayQueueAdd { ! get { ! return !initialized && ! IsConnectedToSession && ! session.IsInverseCollection( this ); } } ! /// <summary></summary> ! protected bool QueueAdd( object element ) { ! if( MayQueueAdd ) { ! if( additions == null ) ! { ! additions = new ArrayList( 10 ); ! } ! additions.Add( element ); ! session.Dirty( this ); //needed so that we remove this collection from the JCS cache return true; ! } ! else { return false; *************** *** 97,109 **** } ! protected bool QueueAddAll(ICollection coll) { ! if ( MayQueueAdd ) { ! if (additions==null) additions = new ArrayList(20); ! additions.AddRange(coll); return true; ! } ! else { return false; --- 118,134 ---- } ! /// <summary></summary> ! protected bool QueueAddAll( ICollection coll ) { ! if( MayQueueAdd ) { ! if( additions == null ) ! { ! additions = new ArrayList( 20 ); ! } ! additions.AddRange( coll ); return true; ! } ! else { return false; *************** *** 112,124 **** //TODO: H2.0.3 new method ! public virtual void DelayedAddAll(ICollection coll) { ! throw new AssertionFailure("Collection does not support delayed initialization."); } // TODO: h2.0.3 synhc - I don't see AddAll in the H code... ! public virtual bool AddAll(ICollection coll) { ! throw new AssertionFailure("Collection does not support delayed initialization"); } --- 137,158 ---- //TODO: H2.0.3 new method ! /// <summary> ! /// ! /// </summary> ! /// <param name="coll"></param> ! public virtual void DelayedAddAll( ICollection coll ) { ! throw new AssertionFailure( "Collection does not support delayed initialization." ); } // TODO: h2.0.3 synhc - I don't see AddAll in the H code... ! /// <summary> ! /// ! /// </summary> ! /// <param name="coll"></param> ! /// <returns></returns> ! public virtual bool AddAll( ICollection coll ) { ! throw new AssertionFailure( "Collection does not support delayed initialization" ); } *************** *** 128,132 **** /// </summary> /// <value>An <see cref="ArrayList"/> of objects or null.</value> ! protected ArrayList Additions { get { return additions; } --- 162,166 ---- /// </summary> /// <value>An <see cref="ArrayList"/> of objects or null.</value> ! protected ArrayList Additions { get { return additions; } *************** *** 142,148 **** /// any Queued Additions. /// </remarks> ! public virtual void PostFlush() { ! if( additions!=null ) { additions.Clear(); --- 176,182 ---- /// any Queued Additions. /// </remarks> ! public virtual void PostFlush() { ! if( additions != null ) { additions.Clear(); *************** *** 150,154 **** } ! protected PersistentCollection(ISessionImplementor session) { this.session = session; --- 184,192 ---- } ! /// <summary> ! /// ! /// </summary> ! /// <param name="session"></param> ! protected PersistentCollection( ISessionImplementor session ) { this.session = session; *************** *** 161,169 **** /// <param name="lazy"></param> /// <returns></returns> ! public virtual object GetInitialValue(bool lazy) { ! if ( !lazy ) { ! session.Initialize(this, false); initialized = true; } --- 199,207 ---- /// <param name="lazy"></param> /// <returns></returns> ! public virtual object GetInitialValue( bool lazy ) { ! if( !lazy ) { ! session.Initialize( this, false ); initialized = true; } *************** *** 171,175 **** } ! public virtual object GetCachedValue() { initialized = true; //TODO: only needed for query FETCH so should move out of here --- 209,214 ---- } ! /// <summary></summary> ! public virtual object GetCachedValue() { initialized = true; //TODO: only needed for query FETCH so should move out of here *************** *** 180,194 **** /// Override on some subclasses /// </summary> ! public virtual void BeginRead() { // override on some subclasses } ! /// <summary> /// It is my thoughts to have this be the portion that takes care of /// converting the Identifier to the element... /// </summary> ! [Obsolete("Should be replaced with EndRead(CollectionPersister, object) - need to verify")] ! public virtual void EndRead() { // override on some subclasses --- 219,233 ---- /// Override on some subclasses /// </summary> ! public virtual void BeginRead() { // override on some subclasses } ! /// <summary> /// It is my thoughts to have this be the portion that takes care of /// converting the Identifier to the element... /// </summary> ! [Obsolete( "Should be replaced with EndRead(CollectionPersister, object) - need to verify" )] ! public virtual void EndRead() { // override on some subclasses *************** *** 202,245 **** /// <param name="persister"></param> /// <param name="owner"></param> ! public abstract void EndRead(CollectionPersister persister, object owner) ; ! public void Initialize(bool writing) { ! if (!initialized) { ! if ( IsConnectedToSession ) { ! try { ! session.Initialize(this, writing); initialized = true; // do this after setting initialized to true or it will recurse ! if (additions!=null) { ! DelayedAddAll(additions); additions = null; } ! } ! catch (Exception e) { ! log.Error("Failed to lazily initialize a collection", e); ! throw new LazyInitializationException("Failed to lazily initialize a collection", e); } ! } ! else { ! throw new LazyInitializationException("Failed to lazily initialize a collection - no session"); } } } ! public bool UnsetSession(ISessionImplementor session) { ! if (session==this.session) { ! this.session=null; return true; } ! else { return false; --- 241,293 ---- /// <param name="persister"></param> /// <param name="owner"></param> ! public abstract void EndRead( CollectionPersister persister, object owner ); ! /// <summary> ! /// ! /// </summary> ! /// <param name="writing"></param> ! public void Initialize( bool writing ) { ! if( !initialized ) { ! if( IsConnectedToSession ) { ! try { ! session.Initialize( this, writing ); initialized = true; // do this after setting initialized to true or it will recurse ! if( additions != null ) { ! DelayedAddAll( additions ); additions = null; } ! } ! catch( Exception e ) { ! log.Error( "Failed to lazily initialize a collection", e ); ! throw new LazyInitializationException( "Failed to lazily initialize a collection", e ); } ! } ! else { ! throw new LazyInitializationException( "Failed to lazily initialize a collection - no session" ); } } } ! /// <summary> ! /// ! /// </summary> ! /// <param name="session"></param> ! /// <returns></returns> ! public bool UnsetSession( ISessionImplementor session ) { ! if( session == this.session ) { ! this.session = null; return true; } ! else { return false; *************** *** 247,263 **** } ! public bool SetSession(ISessionImplementor session) { ! if (session == this.session) { return false; ! } ! else { ! if ( IsConnectedToSession ) { ! throw new HibernateException("Illegal attempt to associate a collection with two open sessions"); ! } ! else { this.session = session; --- 295,316 ---- } ! /// <summary> ! /// ! /// </summary> ! /// <param name="session"></param> ! /// <returns></returns> ! public bool SetSession( ISessionImplementor session ) { ! if( session == this.session ) { return false; ! } ! else { ! if( IsConnectedToSession ) { ! throw new HibernateException( "Illegal attempt to associate a collection with two open sessions" ); ! } ! else { this.session = session; *************** *** 281,295 **** /// <c>Read()</c> or <c>Write()</c>. /// </remarks> ! public virtual bool IsDirectlyAccessible { get { return directlyAccessible; } } ! public virtual bool IsArrayHolder { get { return false; } } public abstract ICollection Entries(); ! /// <summary> /// Reads the elements Identifier from the reader. --- 334,356 ---- /// <c>Read()</c> or <c>Write()</c>. /// </remarks> ! public virtual bool IsDirectlyAccessible { get { return directlyAccessible; } } ! /// <summary> ! /// ! /// </summary> ! public virtual bool IsArrayHolder ! { get { return false; } } + /// <summary> + /// + /// </summary> + /// <returns></returns> public abstract ICollection Entries(); ! /// <summary> /// Reads the elements Identifier from the reader. *************** *** 299,312 **** /// <param name="owner">The owner of this Collection.</param> /// <returns>The value of the Identifier.</returns> ! public abstract object ReadFrom(IDataReader reader, CollectionPersister role, object owner); ! ! public abstract void WriteTo(IDbCommand st, CollectionPersister role, object entry, int i, bool writeOrder); ! public abstract object GetIndex(object entry, int i); ! public abstract void BeforeInitialize(CollectionPersister persister); ! public abstract bool EqualsSnapshot(IType elementType); ! protected abstract object Snapshot(CollectionPersister persister); ! public abstract object Disassemble(CollectionPersister persister); /// <summary> --- 360,409 ---- /// <param name="owner">The owner of this Collection.</param> /// <returns>The value of the Identifier.</returns> ! public abstract object ReadFrom( IDataReader reader, CollectionPersister role, object owner ); ! /// <summary> ! /// ! /// </summary> ! /// <param name="st"></param> ! /// <param name="role"></param> ! /// <param name="entry"></param> ! /// <param name="i"></param> ! /// <param name="writeOrder"></param> ! public abstract void WriteTo( IDbCommand st, CollectionPersister role, object entry, int i, bool writeOrder ); ! /// <summary> ! /// ! /// </summary> ! /// <param name="entry"></param> ! /// <param name="i"></param> ! /// <returns></returns> ! public abstract object GetIndex( object entry, int i ); ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="persister"></param> ! public abstract void BeforeInitialize( CollectionPersister persister ); ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="elementType"></param> ! /// <returns></returns> ! public abstract bool EqualsSnapshot( IType elementType ); ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="persister"></param> ! /// <returns></returns> ! protected abstract object Snapshot( CollectionPersister persister ); ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="persister"></param> ! /// <returns></returns> ! public abstract object Disassemble( CollectionPersister persister ); /// <summary> *************** *** 320,331 **** /// need to be recreated. /// </returns> ! public virtual bool NeedsRecreate(CollectionPersister persister) { return false; } ! public object GetSnapshot(CollectionPersister persister) { ! return (persister==null) ? null : Snapshot(persister); } --- 417,433 ---- /// need to be recreated. /// </returns> ! public virtual bool NeedsRecreate( CollectionPersister persister ) { return false; } ! /// <summary> ! /// ! /// </summary> ! /// <param name="persister"></param> ! /// <returns></returns> ! public object GetSnapshot( CollectionPersister persister ) { ! return ( persister == null ) ? null : Snapshot( persister ); } *************** *** 334,368 **** /// </summary> /// TODO: H2.0.3 declares this as final ! public void ForceLoad() { Read(); } ! public abstract bool EntryExists(object entry, int i); ! public abstract bool NeedsInserting(object entry, int i, IType elemType); ! public abstract bool NeedsUpdating(object entry, int i, IType elemType); ! public abstract ICollection GetDeletes(IType elemType); ! protected object GetSnapshot() { ! return session.GetSnapshot(this); } ! public bool WasInitialized { get { return initialized; } } ! public bool HasQueuedAdds { ! get { return additions!= null; } } ! public ICollection QueuedAddsCollection { get { return additions; } } ! public virtual ICollectionSnapshot CollectionSnapshot { get { return collectionSnapshot; } --- 436,504 ---- /// </summary> /// TODO: H2.0.3 declares this as final ! public void ForceLoad() { Read(); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="entry"></param> ! /// <param name="i"></param> ! /// <returns></returns> ! public abstract bool EntryExists( object entry, int i ); ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="entry"></param> ! /// <param name="i"></param> ! /// <param name="elemType"></param> ! /// <returns></returns> ! public abstract bool NeedsInserting( object entry, int i, IType elemType ); ! /// <summary> ! /// ! /// </summary> ! /// <param name="entry"></param> ! /// <param name="i"></param> ! /// <param name="elemType"></param> ! /// <returns></returns> ! public abstract bool NeedsUpdating( object entry, int i, IType elemType ); ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="elemType"></param> ! /// <returns></returns> ! public abstract ICollection GetDeletes( IType elemType ); ! ! ! /// <summary></summary> ! protected object GetSnapshot() { ! return session.GetSnapshot( this ); } ! /// <summary></summary> ! public bool WasInitialized { get { return initialized; } } ! /// <summary></summary> ! public bool HasQueuedAdds { ! get { return additions != null; } } ! /// <summary></summary> ! public ICollection QueuedAddsCollection { get { return additions; } } ! /// <summary></summary> ! public virtual ICollectionSnapshot CollectionSnapshot { get { return collectionSnapshot; } *************** *** 381,404 **** /// </param> /// <param name="i">The index of the Entry while enumerating through the Collection.</param> ! public virtual void PreInsert(CollectionPersister persister, object entry, int i) {} ! ! public abstract ICollection GetOrphans(object snapshot); ! public static void IdentityRemoveAll(IList list, ICollection collection, ISessionImplementor session) { IEnumerator enumer = collection.GetEnumerator(); ! while(enumer.MoveNext()) PersistentCollection.IdentityRemove(list, enumer.Current, session); } ! public static void IdentityRemove(IList list, object obj, ISessionImplementor session) { int indexOfEntityToRemove = -1; ! if(session.IsSaved(obj)) { ! object idOfCurrent = session.GetEntityIdentifierIfNotUnsaved(obj); ! for(int i = 0; i < list.Count; i++) { ! object idOfOld = session.GetEntityIdentifierIfNotUnsaved(list[i]); ! if(idOfCurrent.Equals(idOfOld) ) { // in hibernate this used the Iterator to remove the item - since in .NET --- 517,563 ---- /// </param> /// <param name="i">The index of the Entry while enumerating through the Collection.</param> ! public virtual void PreInsert( CollectionPersister persister, object entry, int i ) ! { ! } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="snapshot"></param> ! /// <returns></returns> ! public abstract ICollection GetOrphans( object snapshot ); ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="list"></param> ! /// <param name="collection"></param> ! /// <param name="session"></param> ! public static void IdentityRemoveAll( IList list, ICollection collection, ISessionImplementor session ) { IEnumerator enumer = collection.GetEnumerator(); ! while( enumer.MoveNext() ) ! { ! PersistentCollection.IdentityRemove( list, enumer.Current, session ); ! } } ! /// <summary> ! /// ! /// </summary> ! /// <param name="list"></param> ! /// <param name="obj"></param> ! /// <param name="session"></param> ! public static void IdentityRemove( IList list, object obj, ISessionImplementor session ) { int indexOfEntityToRemove = -1; ! if( session.IsSaved( obj ) ) { ! object idOfCurrent = session.GetEntityIdentifierIfNotUnsaved( obj ); ! for( int i = 0; i < list.Count; i++ ) { ! object idOfOld = session.GetEntityIdentifierIfNotUnsaved( list[ i ] ); ! if( idOfCurrent.Equals( idOfOld ) ) { // in hibernate this used the Iterator to remove the item - since in .NET *************** *** 409,417 **** } ! if(indexOfEntityToRemove != -1) list.RemoveAt(indexOfEntityToRemove); } } - #region - Hibernate Collection Proxy Classes --- 568,578 ---- } ! if( indexOfEntityToRemove != -1 ) ! { ! list.RemoveAt( indexOfEntityToRemove ); ! } } } #region - Hibernate Collection Proxy Classes *************** *** 421,426 **** * Hibernate needs to be made aware of. If .net changes their collection interfaces * then we can readd these back in. ! */ ! #endregion --- 582,586 ---- * Hibernate needs to be made aware of. If .net changes their collection interfaces * then we can readd these back in. ! */ #endregion *************** *** 428,447 **** #region ICollection Members ! public abstract bool IsSynchronized ! { ! get; ! } ! public abstract int Count ! { ! get; ! } ! public abstract void CopyTo(Array array, int index); ! public abstract object SyncRoot ! { ! get; ! } #endregion --- 588,606 ---- #region ICollection Members ! /// <summary></summary> ! public abstract bool IsSynchronized { get; } ! /// <summary></summary> ! public abstract int Count { get; } ! /// <summary> ! /// ! /// </summary> ! /// <param name="array"></param> ! /// <param name="index"></param> ! public abstract void CopyTo( Array array, int index ); ! /// <summary></summary> ! public abstract object SyncRoot { get; } #endregion *************** *** 449,452 **** --- 608,612 ---- #region IEnumerable Members + /// <summary></summary> public abstract IEnumerator GetEnumerator(); *************** *** 454,459 **** } - ! ! } --- 614,617 ---- } ! } \ No newline at end of file Index: List.cs =======... [truncated message content] |