From: Kevin W. <kev...@us...> - 2004-12-31 19:51:05
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12394 Modified Files: CollectionEntry.cs Log Message: fixing xml comments and letting ReSharper do reformatting Index: CollectionEntry.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/CollectionEntry.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CollectionEntry.cs 11 Dec 2004 20:58:46 -0000 1.2 --- CollectionEntry.cs 31 Dec 2004 19:50:54 -0000 1.3 *************** *** 1,5 **** using System; using System.Collections; ! using NHibernate.Collection; using NHibernate.Engine; --- 1,5 ---- using System; using System.Collections; ! using log4net; using NHibernate.Collection; using NHibernate.Engine; *************** *** 12,21 **** /// </summary> [Serializable] ! internal class CollectionEntry : ICollectionSnapshot { ! private static readonly log4net.ILog log = log4net.LogManager.GetLogger( typeof(CollectionEntry) ); internal bool dirty; ! /// <summary> /// Indicates that the Collection can still be reached by an Entity --- 12,22 ---- /// </summary> [Serializable] ! internal class CollectionEntry : ICollectionSnapshot { ! private static readonly ILog log = LogManager.GetLogger( typeof( CollectionEntry ) ); + /// <summary></summary> internal bool dirty; ! /// <summary> /// Indicates that the Collection can still be reached by an Entity *************** *** 26,37 **** /// two Entities. /// </remarks> ! [NonSerialized] internal bool reached; ! /// <summary> /// Indicates that the Collection has been processed and is ready /// to have its state synchronized with the database. /// </summary> ! [NonSerialized] internal bool processed; ! /// <summary> /// Indicates that a Collection needs to be updated. --- 27,40 ---- /// two Entities. /// </remarks> ! [NonSerialized] ! internal bool reached; ! /// <summary> /// Indicates that the Collection has been processed and is ready /// to have its state synchronized with the database. /// </summary> ! [NonSerialized] ! internal bool processed; ! /// <summary> /// Indicates that a Collection needs to be updated. *************** *** 41,46 **** /// have been changed. /// </remarks> ! [NonSerialized] internal bool doupdate; ! /// <summary> /// Indicates that a Collection has old elements that need to be removed. --- 44,50 ---- /// have been changed. /// </remarks> ! [NonSerialized] ! internal bool doupdate; ! /// <summary> /// Indicates that a Collection has old elements that need to be removed. *************** *** 50,55 **** /// the key changes and it has a loadedPersister - ie - it was loaded by NHibernate. /// </remarks> ! [NonSerialized] internal bool doremove; ! /// <summary> /// Indicates that a Collection needs to be recreated. --- 54,60 ---- /// the key changes and it has a loadedPersister - ie - it was loaded by NHibernate. /// </remarks> ! [NonSerialized] ! internal bool doremove; ! /// <summary> /// Indicates that a Collection needs to be recreated. *************** *** 59,69 **** /// or the owner changes. /// </remarks> ! [NonSerialized] internal bool dorecreate; ! /// <summary> /// Indicates that the Collection has been fully initialized. /// </summary> internal bool initialized; ! /// <summary> /// The <see cref="CollectionPersister"/> that is currently responsible --- 64,75 ---- /// or the owner changes. /// </remarks> ! [NonSerialized] ! internal bool dorecreate; ! /// <summary> /// Indicates that the Collection has been fully initialized. /// </summary> internal bool initialized; ! /// <summary> /// The <see cref="CollectionPersister"/> that is currently responsible *************** *** 74,79 **** /// unreachable collection. /// </remarks> ! [NonSerialized] internal CollectionPersister currentPersister; ! /// <summary> /// The <see cref="CollectionPersister"/> when the Collection was loaded. --- 80,86 ---- /// unreachable collection. /// </remarks> ! [NonSerialized] ! internal CollectionPersister currentPersister; ! /// <summary> /// The <see cref="CollectionPersister"/> when the Collection was loaded. *************** *** 83,92 **** /// was passed in along with a transient object. /// </remarks> ! [NonSerialized] internal CollectionPersister loadedPersister; ! [NonSerialized] internal object currentKey; internal object loadedKey; internal object snapshot; //session-start/post-flush persistent state internal string role; ! /// <summary> /// Initializes a new instance of <see cref="CollectionEntry"/>. --- 90,109 ---- /// was passed in along with a transient object. /// </remarks> ! [NonSerialized] ! internal CollectionPersister loadedPersister; ! ! /// <summary></summary> ! [NonSerialized] ! internal object currentKey; ! ! /// <summary></summary> internal object loadedKey; + + /// <summary></summary> internal object snapshot; //session-start/post-flush persistent state + + /// <summary></summary> internal string role; ! /// <summary> /// Initializes a new instance of <see cref="CollectionEntry"/>. *************** *** 96,100 **** /// has already been initialized. /// </remarks> ! public CollectionEntry() { this.dirty = false; --- 113,117 ---- /// has already been initialized. /// </remarks> ! public CollectionEntry() { this.dirty = false; *************** *** 108,117 **** /// <param name="loadedID">The identifier of the Entity that is the owner of this Collection.</param> /// <param name="initialized">A boolean indicating if the collection has been initialized.</param> ! public CollectionEntry(CollectionPersister loadedPersister, object loadedID, bool initialized) { this.dirty = false; this.initialized = initialized; this.loadedKey = loadedID; ! SetLoadedPersister(loadedPersister); } --- 125,134 ---- /// <param name="loadedID">The identifier of the Entity that is the owner of this Collection.</param> /// <param name="initialized">A boolean indicating if the collection has been initialized.</param> ! public CollectionEntry( CollectionPersister loadedPersister, object loadedID, bool initialized ) { this.dirty = false; this.initialized = initialized; this.loadedKey = loadedID; ! SetLoadedPersister( loadedPersister ); } *************** *** 126,130 **** /// <c>cs</c> parameter. /// </remarks> ! public CollectionEntry(ICollectionSnapshot cs, ISessionFactoryImplementor factory) { this.dirty = cs.Dirty; --- 143,147 ---- /// <c>cs</c> parameter. /// </remarks> ! public CollectionEntry( ICollectionSnapshot cs, ISessionFactoryImplementor factory ) { this.dirty = cs.Dirty; *************** *** 144,148 **** /// default behavior; will be overridden in deep lazy collections /// </remarks> ! public virtual bool IsDirty(PersistentCollection coll) { // if this has already been marked as dirty or the collection can not --- 161,165 ---- /// default behavior; will be overridden in deep lazy collections /// </remarks> ! public virtual bool IsDirty( PersistentCollection coll ) { // if this has already been marked as dirty or the collection can not *************** *** 150,160 **** // wrappers are used) and the elements in the collection are not mutable // then return the dirty flag. ! if ( dirty || ( !coll.IsDirectlyAccessible && !loadedPersister.ElementType.IsMutable ! ) ) { return dirty; ! } ! else { // need to have the coll determine if it is the same as the snapshot --- 167,177 ---- // wrappers are used) and the elements in the collection are not mutable // then return the dirty flag. ! if( dirty || ( !coll.IsDirectlyAccessible && !loadedPersister.ElementType.IsMutable ! ) ) { return dirty; ! } ! else { // need to have the coll determine if it is the same as the snapshot *************** *** 168,181 **** /// </summary> /// <param name="collection">The <see cref="PersistentCollection"/> that this CollectionEntry will be responsible for flushing.</param> ! public void PreFlush(PersistentCollection collection) { // if the collection is initialized and it was previously persistent // initialize the dirty flag ! dirty = ( initialized && loadedPersister!=null && IsDirty(collection) ) || ! (!initialized && dirty ); //only need this so collection with queued adds will be removed from JCS cache ! if ( log.IsDebugEnabled && dirty && loadedPersister!=null ) { ! log.Debug("Collection dirty: " + MessageHelper.InfoString(loadedPersister, loadedKey) ); } --- 185,198 ---- /// </summary> /// <param name="collection">The <see cref="PersistentCollection"/> that this CollectionEntry will be responsible for flushing.</param> ! public void PreFlush( PersistentCollection collection ) { // if the collection is initialized and it was previously persistent // initialize the dirty flag ! dirty = ( initialized && loadedPersister != null && IsDirty( collection ) ) || ! ( !initialized && dirty ); //only need this so collection with queued adds will be removed from JCS cache ! if( log.IsDebugEnabled && dirty && loadedPersister != null ) { ! log.Debug( "Collection dirty: " + MessageHelper.InfoString( loadedPersister, loadedKey ) ); } *************** *** 194,201 **** /// </summary> /// <param name="collection">The initialized <see cref="PersistentCollection"/> that this Entry is for.</param> ! public void PostInitialize(PersistentCollection collection) { initialized = true; ! snapshot = collection.GetSnapshot(loadedPersister); } --- 211,218 ---- /// </summary> /// <param name="collection">The initialized <see cref="PersistentCollection"/> that this Entry is for.</param> ! public void PostInitialize( PersistentCollection collection ) { initialized = true; ! snapshot = collection.GetSnapshot( loadedPersister ); } *************** *** 204,213 **** /// </summary> /// <param name="collection">The <see cref="PersistentCollection"/> that was flushed.</param> ! public void PostFlush(PersistentCollection collection) { // the CollectionEntry should be processed if we are in the PostFlush() ! if( !processed ) { ! throw new AssertionFailure("Hibernate has a bug processing collections"); } --- 221,230 ---- /// </summary> /// <param name="collection">The <see cref="PersistentCollection"/> that was flushed.</param> ! public void PostFlush( PersistentCollection collection ) { // the CollectionEntry should be processed if we are in the PostFlush() ! if( !processed ) { ! throw new AssertionFailure( "Hibernate has a bug processing collections" ); } *************** *** 218,222 **** SetLoadedPersister( currentPersister ); dirty = false; ! // collection needs to know its' representation in memory and with // the db is now in synch - esp important for collections like a bag --- 235,239 ---- SetLoadedPersister( currentPersister ); dirty = false; ! // collection needs to know its' representation in memory and with // the db is now in synch - esp important for collections like a bag *************** *** 226,232 **** // if it was initialized or any of the scheduled actions were performed then // need to resnpashot the contents of the collection. ! if ( initialized && ( doremove || dorecreate || doupdate ) ) { ! snapshot = collection.GetSnapshot(loadedPersister); //re-snapshot } } --- 243,249 ---- // if it was initialized or any of the scheduled actions were performed then // need to resnpashot the contents of the collection. ! if( initialized && ( doremove || dorecreate || doupdate ) ) { ! snapshot = collection.GetSnapshot( loadedPersister ); //re-snapshot } } *************** *** 234,267 **** #region Engine.ICollectionSnapshot Members ! public object Key { get { return loadedKey; } } ! ! public string Role { get { return role; } } ! ! public object Snapshot { get { return snapshot; } } ! public bool Dirty { get { return dirty; } } ! ! public void SetDirty() { dirty = true; } ! public bool IsInitialized { ! get { return initialized;} } - #endregion --- 251,290 ---- #region Engine.ICollectionSnapshot Members ! /// <summary></summary> ! public object Key { get { return loadedKey; } } ! ! /// <summary></summary> ! public string Role { get { return role; } } ! ! /// <summary></summary> ! public object Snapshot { get { return snapshot; } } ! /// <summary></summary> ! public bool Dirty { get { return dirty; } } ! ! /// <summary></summary> ! public void SetDirty() { dirty = true; } ! ! /// <summary></summary> ! public bool IsInitialized { ! get { return initialized; } } #endregion *************** *** 274,289 **** /// responsible for the Collection. /// </param> ! private void SetLoadedPersister(CollectionPersister persister) { loadedPersister = persister; ! if (persister!=null) { ! role=persister.Role; } } ! public bool SnapshotIsEmpty { ! get { //TODO: implementation here is non-extensible ... --- 297,313 ---- /// responsible for the Collection. /// </param> ! private void SetLoadedPersister( CollectionPersister persister ) { loadedPersister = persister; ! if( persister != null ) { ! role = persister.Role; } } ! /// <summary></summary> ! public bool SnapshotIsEmpty { ! get { //TODO: implementation here is non-extensible ... *************** *** 294,313 **** // (snapshot.GetType().IsArray && ( (Array) snapshot).Length==0 )// if snapshot is an array // ); ! // TODO: in .NET an IList, IDictionary, and Array are all collections so we might be able // to just cast it to a ICollection instead of all the diff collections. ! return initialized && snapshot!=null && ( ! ( snapshot is IList && ( (IList) snapshot ).Count==0 ) || // if snapshot is a collection ! ( snapshot is IDictionary && ( (IDictionary) snapshot ).Count==0 ) || // if snapshot is a map ! (snapshot.GetType().IsArray && ( (Array) snapshot).Length==0 )// if snapshot is an array ! ); } ! } ! public bool IsNew { // TODO: is this correct implementation - h2.0.3 ! get { return initialized && (snapshot==null); } } } ! ! } --- 318,339 ---- // (snapshot.GetType().IsArray && ( (Array) snapshot).Length==0 )// if snapshot is an array // ); ! // TODO: in .NET an IList, IDictionary, and Array are all collections so we might be able // to just cast it to a ICollection instead of all the diff collections. ! return initialized && snapshot != null && ( ! ( snapshot is IList && ( ( IList ) snapshot ).Count == 0 ) || // if snapshot is a collection ! ( snapshot is IDictionary && ( ( IDictionary ) snapshot ).Count == 0 ) || // if snapshot is a map ! ( snapshot.GetType().IsArray && ( ( Array ) snapshot ).Length == 0 ) // if snapshot is an array ! ); } ! } ! ! /// <summary></summary> ! public bool IsNew { // TODO: is this correct implementation - h2.0.3 ! get { return initialized && ( snapshot == null ); } } } ! ! } \ No newline at end of file |