From: Kevin W. <kev...@us...> - 2004-12-31 23:53:04
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Type In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24292 Modified Files: EntityType.cs GuidType.cs IAbstractComponentType.cs IAssociationType.cs IdentifierBagType.cs Log Message: fixing xml comments and letting ReSharper do reformatting Index: IAssociationType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/IAssociationType.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** IAssociationType.cs 10 Feb 2004 18:41:42 -0000 1.5 --- IAssociationType.cs 31 Dec 2004 23:52:52 -0000 1.6 *************** *** 1,22 **** - using System; - using NHibernate.Engine; ! namespace NHibernate.Type { ! /// <summary> /// Represents directionality of the foreign key constraint /// </summary> ! public abstract class ForeignKeyType { ! protected ForeignKeyType() { } ! private class ForeignKeyToParentClass : ForeignKeyType { ! public override bool CascadeNow(CascadePoint cascadePoint) { return cascadePoint != CascadePoint.CascadeBeforeInsertAfterDelete; } } ! private class ForeignKeyFromParentClass : ForeignKeyType { ! public override bool CascadeNow(CascadePoint cascadePoint) { return cascadePoint != CascadePoint.CascadeAfterInsertBeforeDelete; } --- 1,28 ---- using NHibernate.Engine; ! namespace NHibernate.Type ! { /// <summary> /// Represents directionality of the foreign key constraint /// </summary> ! public abstract class ForeignKeyType ! { ! /// <summary></summary> ! protected ForeignKeyType() ! { ! } ! private class ForeignKeyToParentClass : ForeignKeyType ! { ! public override bool CascadeNow( CascadePoint cascadePoint ) ! { return cascadePoint != CascadePoint.CascadeBeforeInsertAfterDelete; } } ! private class ForeignKeyFromParentClass : ForeignKeyType ! { ! public override bool CascadeNow( CascadePoint cascadePoint ) ! { return cascadePoint != CascadePoint.CascadeAfterInsertBeforeDelete; } *************** *** 26,30 **** /// Should we cascade at this cascade point? /// </summary> ! public abstract bool CascadeNow(CascadePoint cascadePoint); /// <summary> --- 32,36 ---- /// Should we cascade at this cascade point? /// </summary> ! public abstract bool CascadeNow( CascadePoint cascadePoint ); /// <summary> *************** *** 43,48 **** /// An <see cref="IType"/> that represents some kind of association between entities. /// </summary> ! public interface IAssociationType { ! /// <summary> /// When implemented by a class, gets the type of foreign key directionality --- 49,54 ---- /// An <see cref="IType"/> that represents some kind of association between entities. /// </summary> ! public interface IAssociationType ! { /// <summary> /// When implemented by a class, gets the type of foreign key directionality Index: EntityType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/EntityType.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** EntityType.cs 29 Nov 2004 18:43:23 -0000 1.6 --- EntityType.cs 31 Dec 2004 23:52:52 -0000 1.7 *************** *** 1,8 **** - using System; using System.Data; - - using NHibernate.Util; using NHibernate.Engine; using NHibernate.Persister; namespace NHibernate.Type --- 1,6 ---- using System.Data; using NHibernate.Engine; using NHibernate.Persister; + using NHibernate.Util; namespace NHibernate.Type *************** *** 16,38 **** private readonly bool niceEquals; ! public override sealed bool IsEntityType { get { return true; } ! } ! ! public System.Type PersistentClass { get { return persistentClass; } ! } ! public override sealed bool Equals(object x, object y) { ! return x==y; } ! protected EntityType(System.Type persistentClass) { this.persistentClass = persistentClass; ! this.niceEquals = !ReflectHelper.OverridesEquals(persistentClass); } ! ! public override object NullSafeGet(IDataReader rs, string name, ISessionImplementor session, object owner) { ! return NullSafeGet( rs, new string[] {name}, session, owner ); } --- 14,61 ---- private readonly bool niceEquals; ! /// <summary></summary> ! public override sealed bool IsEntityType ! { get { return true; } ! } ! ! /// <summary></summary> ! public System.Type PersistentClass ! { get { return persistentClass; } ! } ! /// <summary> ! /// ! /// </summary> ! /// <param name="x"></param> ! /// <param name="y"></param> ! /// <returns></returns> ! public override sealed bool Equals( object x, object y ) ! { ! return x == y; } ! /// <summary> ! /// ! /// </summary> ! /// <param name="persistentClass"></param> ! protected EntityType( System.Type persistentClass ) ! { this.persistentClass = persistentClass; ! this.niceEquals = !ReflectHelper.OverridesEquals( persistentClass ); } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="rs"></param> ! /// <param name="name"></param> ! /// <param name="session"></param> ! /// <param name="owner"></param> ! /// <returns></returns> ! public override object NullSafeGet( IDataReader rs, string name, ISessionImplementor session, object owner ) ! { ! return NullSafeGet( rs, new string[ ] {name}, session, owner ); } *************** *** 41,94 **** * it should return the proxy class, but it doesn't. */ ! public override sealed System.Type ReturnedClass { get { return persistentClass; } - } - - protected object GetIdentifier(object value, ISessionImplementor session) { - return session.GetEntityIdentifierIfNotUnsaved(value); } ! ! public override string ToXML(object value, ISessionFactoryImplementor factory) { ! IClassPersister persister = factory.GetPersister(persistentClass); ! return ( value==null ) ? null : persister.IdentifierType.ToXML( persister.GetIdentifier(value), factory ); } ! public override string Name { get { return persistentClass.Name; } } ! ! public override object DeepCopy(object value) { return value; //special case ... this is the leaf of the containment graph, even though not immutable } ! ! public override bool IsMutable { get { return false; } } public abstract bool IsOneToOne { get; } ! ! public override object Disassemble(object value, ISessionImplementor session) { ! if (value==null) { return null; } ! else { ! object id = session.GetIdentifier(value); ! if (id==null) { ! throw new AssertionFailure("cannot cache a reference to an object with a null id"); } return GetIdentifierType( session ).Disassemble( id, session ); } } ! ! protected IType GetIdentifierType(ISessionImplementor session) { return session.Factory.GetIdentifierType( persistentClass ); } ! ! public override object Assemble(object oid, ISessionImplementor session, object owner) { object assembledId = GetIdentifierType( session ).Assemble( oid, session, owner ); --- 64,163 ---- * it should return the proxy class, but it doesn't. */ ! ! /// <summary></summary> ! public override sealed System.Type ReturnedClass ! { get { return persistentClass; } } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="value"></param> ! /// <param name="session"></param> ! /// <returns></returns> ! protected object GetIdentifier( object value, ISessionImplementor session ) ! { ! return session.GetEntityIdentifierIfNotUnsaved( value ); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="value"></param> ! /// <param name="factory"></param> ! /// <returns></returns> ! public override string ToXML( object value, ISessionFactoryImplementor factory ) ! { ! IClassPersister persister = factory.GetPersister( persistentClass ); ! return ( value == null ) ? null : persister.IdentifierType.ToXML( persister.GetIdentifier( value ), factory ); ! } ! ! /// <summary></summary> ! public override string Name ! { get { return persistentClass.Name; } } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="value"></param> ! /// <returns></returns> ! public override object DeepCopy( object value ) ! { return value; //special case ... this is the leaf of the containment graph, even though not immutable } ! ! /// <summary></summary> ! public override bool IsMutable ! { get { return false; } } + /// <summary></summary> public abstract bool IsOneToOne { get; } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="value"></param> ! /// <param name="session"></param> ! /// <returns></returns> ! public override object Disassemble( object value, ISessionImplementor session ) { ! if( value == null ) { return null; } ! else { ! object id = session.GetIdentifier( value ); ! if( id == null ) { ! throw new AssertionFailure( "cannot cache a reference to an object with a null id" ); } return GetIdentifierType( session ).Disassemble( id, session ); } } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="session"></param> ! /// <returns></returns> ! protected IType GetIdentifierType( ISessionImplementor session ) { return session.Factory.GetIdentifierType( persistentClass ); } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="oid"></param> ! /// <param name="session"></param> ! /// <param name="owner"></param> ! /// <returns></returns> ! public override object Assemble( object oid, ISessionImplementor session, object owner ) { object assembledId = GetIdentifierType( session ).Assemble( oid, session, owner ); *************** *** 97,108 **** } ! public override bool HasNiceEquals { get { return niceEquals; } } ! ! public override bool IsAssociationType { get { return true; } } ! /// <summary> /// Converts the id contained in the <see cref="IDataReader"/> to an object. --- 166,181 ---- } ! /// <summary></summary> ! public override bool HasNiceEquals ! { get { return niceEquals; } } ! ! /// <summary></summary> ! public override bool IsAssociationType ! { get { return true; } } ! /// <summary> /// Converts the id contained in the <see cref="IDataReader"/> to an object. *************** *** 115,132 **** /// An instance of the object or <c>null</c> if the identifer was null. /// </returns> ! public override sealed object NullSafeGet(IDataReader rs, string[] names, ISessionImplementor session, object owner) { ! return ResolveIdentifier( Hydrate(rs, names, session, owner), session, owner ); } ! ! public override abstract object Hydrate(IDataReader rs, string[] names, ISessionImplementor session, object owner); ! ! public override bool IsDirty(object old, object current, ISessionImplementor session) { ! if ( Equals(old, current) ) return false; ! ! object oldid = GetIdentifier(old, session); ! object newid = GetIdentifier(current, session); ! return !GetIdentifierType(session).Equals(oldid, newid); } } --- 188,223 ---- /// An instance of the object or <c>null</c> if the identifer was null. /// </returns> ! public override sealed object NullSafeGet( IDataReader rs, string[ ] names, ISessionImplementor session, object owner ) { ! return ResolveIdentifier( Hydrate( rs, names, session, owner ), session, owner ); } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="rs"></param> ! /// <param name="names"></param> ! /// <param name="session"></param> ! /// <param name="owner"></param> ! /// <returns></returns> ! public abstract override object Hydrate( IDataReader rs, string[ ] names, ISessionImplementor session, object owner ); ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="old"></param> ! /// <param name="current"></param> ! /// <param name="session"></param> ! /// <returns></returns> ! public override bool IsDirty( object old, object current, ISessionImplementor session ) { ! if( Equals( old, current ) ) ! { ! return false; ! } ! ! object oldid = GetIdentifier( old, session ); ! object newid = GetIdentifier( current, session ); ! return !GetIdentifierType( session ).Equals( oldid, newid ); } } Index: IdentifierBagType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/IdentifierBagType.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** IdentifierBagType.cs 3 May 2004 04:56:44 -0000 1.1 --- IdentifierBagType.cs 31 Dec 2004 23:52:52 -0000 1.2 *************** *** 1,5 **** - using System; using System.Collections; - using NHibernate.Collection; using NHibernate.Engine; --- 1,3 ---- *************** *** 12,41 **** public class IdentifierBagType : PersistentCollectionType { ! public IdentifierBagType(string role) : base(role) { } ! public override PersistentCollection Instantiate(ISessionImplementor session, CollectionPersister persister) { ! return new IdentifierBag(session); } ! public override System.Type ReturnedClass { ! get { return typeof(ICollection); } } ! public override PersistentCollection Wrap(ISessionImplementor session, object collection) { ! return new IdentifierBag(session, (ICollection)collection); } ! ! public override PersistentCollection AssembleCachedCollection(ISessionImplementor session, CollectionPersister persister, object disassembled, object owner) { ! return new IdentifierBag(session, persister, disassembled, owner); } } ! } --- 10,63 ---- public class IdentifierBagType : PersistentCollectionType { ! /// <summary> ! /// ! /// </summary> ! /// <param name="role"></param> ! public IdentifierBagType( string role ) : base( role ) { } ! /// <summary> ! /// ! /// </summary> ! /// <param name="session"></param> ! /// <param name="persister"></param> ! /// <returns></returns> ! public override PersistentCollection Instantiate( ISessionImplementor session, CollectionPersister persister ) { ! return new IdentifierBag( session ); } ! /// <summary></summary> ! public override System.Type ReturnedClass { ! get { return typeof( ICollection ); } } ! /// <summary> ! /// ! /// </summary> ! /// <param name="session"></param> ! /// <param name="collection"></param> ! /// <returns></returns> ! public override PersistentCollection Wrap( ISessionImplementor session, object collection ) { ! return new IdentifierBag( session, ( ICollection ) collection ); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="session"></param> ! /// <param name="persister"></param> ! /// <param name="disassembled"></param> ! /// <param name="owner"></param> ! /// <returns></returns> ! public override PersistentCollection AssembleCachedCollection( ISessionImplementor session, CollectionPersister persister, object disassembled, object owner ) { ! return new IdentifierBag( session, persister, disassembled, owner ); } } ! } \ No newline at end of file Index: IAbstractComponentType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/IAbstractComponentType.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** IAbstractComponentType.cs 10 Feb 2004 18:41:42 -0000 1.7 --- IAbstractComponentType.cs 31 Dec 2004 23:52:52 -0000 1.8 *************** *** 1,26 **** - using System; - - using NHibernate.Loader; using NHibernate.Engine; ! namespace NHibernate.Type { ! /// <summary> /// Enables other Component-like types to hold collections and have cascades, etc. /// </summary> ! public interface IAbstractComponentType : IType { ! ! /// <summary> ! /// ! /// </summary> ! /// <value></value> ! IType[] Subtypes {get;} - /// <summary> - /// - /// </summary> - /// <value></value> - string[] PropertyNames {get;} - /// <summary> /// --- 1,18 ---- using NHibernate.Engine; + using NHibernate.Loader; ! namespace NHibernate.Type ! { /// <summary> /// Enables other Component-like types to hold collections and have cascades, etc. /// </summary> ! public interface IAbstractComponentType : IType ! { ! /// <summary></summary> ! IType[ ] Subtypes { get; } ! ! /// <summary></summary> ! string[ ] PropertyNames { get; } /// <summary> /// *************** *** 29,34 **** /// <param name="session"></param> /// <returns></returns> ! object[] GetPropertyValues(object component, ISessionImplementor session); ! /// <summary> /// --- 21,26 ---- /// <param name="session"></param> /// <returns></returns> ! object[ ] GetPropertyValues( object component, ISessionImplementor session ); ! /// <summary> /// *************** *** 36,41 **** /// <param name="component"></param> /// <param name="values"></param> ! void SetPropertyValues(object component, object[] values); ! /// <summary> /// --- 28,33 ---- /// <param name="component"></param> /// <param name="values"></param> ! void SetPropertyValues( object component, object[ ] values ); ! /// <summary> /// *************** *** 45,50 **** /// <param name="session"></param> /// <returns></returns> ! object GetPropertyValue(object component, int i, ISessionImplementor session); ! /// <summary> /// --- 37,42 ---- /// <param name="session"></param> /// <returns></returns> ! object GetPropertyValue( object component, int i, ISessionImplementor session ); ! /// <summary> /// *************** *** 52,57 **** /// <param name="i"></param> /// <returns></returns> ! Cascades.CascadeStyle Cascade(int i); ! /// <summary> /// --- 44,49 ---- /// <param name="i"></param> /// <returns></returns> ! Cascades.CascadeStyle Cascade( int i ); ! /// <summary> /// *************** *** 59,63 **** /// <param name="i"></param> /// <returns></returns> ! OuterJoinLoaderType EnableJoinedFetch(int i); } } \ No newline at end of file --- 51,55 ---- /// <param name="i"></param> /// <returns></returns> ! OuterJoinLoaderType EnableJoinedFetch( int i ); } } \ No newline at end of file Index: GuidType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/GuidType.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** GuidType.cs 8 Nov 2004 18:33:57 -0000 1.6 --- GuidType.cs 31 Dec 2004 23:52:52 -0000 1.7 *************** *** 1,8 **** using System; using System.Data; - using NHibernate.SqlTypes; ! namespace NHibernate.Type { /// <summary> --- 1,7 ---- using System; using System.Data; using NHibernate.SqlTypes; ! namespace NHibernate.Type { /// <summary> *************** *** 10,56 **** /// to a <see cref="DbType.Guid"/> column. /// </summary> ! public class GuidType : ValueTypeType, IDiscriminatorType { ! ! internal GuidType() : base( new GuidSqlType() ) { } ! public override object Get(IDataReader rs, int index) { ! return new Guid( Convert.ToString(rs[index]) ); } ! public override object Get(IDataReader rs, string name) { ! return new Guid( Convert.ToString(rs[name]) ); } ! public override System.Type ReturnedClass { ! get { return typeof(System.Guid); } } ! ! public override void Set(IDbCommand cmd, object value, int index) { ! IDataParameter parm = cmd.Parameters[index] as IDataParameter; parm.Value = value; } ! public override string Name { get { return "Guid"; } } ! public override string ObjectToSQLString(object value) { return "'" + value.ToString() + "'"; } ! public object StringToObject(string xml) { ! return new Guid(xml); } } ! } --- 9,85 ---- /// to a <see cref="DbType.Guid"/> column. /// </summary> ! public class GuidType : ValueTypeType, IDiscriminatorType { ! /// <summary></summary> ! internal GuidType() : base( new GuidSqlType() ) { } ! /// <summary> ! /// ! /// </summary> ! /// <param name="rs"></param> ! /// <param name="index"></param> ! /// <returns></returns> ! public override object Get( IDataReader rs, int index ) { ! return new Guid( Convert.ToString( rs[ index ] ) ); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="rs"></param> ! /// <param name="name"></param> ! /// <returns></returns> ! public override object Get( IDataReader rs, string name ) { ! return new Guid( Convert.ToString( rs[ name ] ) ); } ! /// <summary></summary> ! public override System.Type ReturnedClass { ! get { return typeof( Guid ); } } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="cmd"></param> ! /// <param name="value"></param> ! /// <param name="index"></param> ! public override void Set( IDbCommand cmd, object value, int index ) { ! IDataParameter parm = cmd.Parameters[ index ] as IDataParameter; parm.Value = value; } ! /// <summary></summary> ! public override string Name { get { return "Guid"; } } ! /// <summary> ! /// ! /// </summary> ! /// <param name="value"></param> ! /// <returns></returns> ! public override string ObjectToSQLString( object value ) { return "'" + value.ToString() + "'"; } ! /// <summary> ! /// ! /// </summary> ! /// <param name="xml"></param> ! /// <returns></returns> ! public object StringToObject( string xml ) { ! return new Guid( xml ); } } ! } \ No newline at end of file |