From: Kevin W. <kev...@us...> - 2004-12-31 23:55:46
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Type In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24740 Modified Files: SerializableType.cs SerializationException.cs SetType.cs SingleType.cs SortedMapType.cs Log Message: fixing xml comments and letting ReSharper do reformatting Index: SortedMapType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/SortedMapType.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** SortedMapType.cs 27 Apr 2004 15:49:22 -0000 1.2 --- SortedMapType.cs 31 Dec 2004 23:55:34 -0000 1.3 *************** *** 1,5 **** - using System; using System.Collections; - using NHibernate.Collection; using NHibernate.Engine; --- 1,3 ---- *************** *** 14,25 **** private IComparer comparer; ! public SortedMapType(string role, IComparer comparer) : base(role) { this.comparer = comparer; } ! public override PersistentCollection Instantiate(ISessionImplementor session, CollectionPersister persister) { ! SortedMap sortedMap = new SortedMap(session, comparer); return sortedMap; } --- 12,34 ---- private IComparer comparer; ! /// <summary> ! /// ! /// </summary> ! /// <param name="role"></param> ! /// <param name="comparer"></param> ! public SortedMapType( string role, IComparer comparer ) : base( role ) { this.comparer = comparer; } ! /// <summary> ! /// ! /// </summary> ! /// <param name="session"></param> ! /// <param name="persister"></param> ! /// <returns></returns> ! public override PersistentCollection Instantiate( ISessionImplementor session, CollectionPersister persister ) { ! SortedMap sortedMap = new SortedMap( session, comparer ); return sortedMap; } *************** *** 29,41 **** // doesn't have that I don't need to override it. ! public override PersistentCollection Wrap(ISessionImplementor session, object collection) { ! return new SortedMap(session, (IDictionary)collection, comparer); } ! public override PersistentCollection AssembleCachedCollection(ISessionImplementor session, CollectionPersister persister, object disassembled, object owner) { ! return new SortedMap(session, persister, comparer, disassembled, owner); } } ! } --- 38,64 ---- // doesn't have that I don't need to override it. ! /// <summary> ! /// ! /// </summary> ! /// <param name="session"></param> ! /// <param name="collection"></param> ! /// <returns></returns> ! public override PersistentCollection Wrap( ISessionImplementor session, object collection ) { ! return new SortedMap( session, ( IDictionary ) collection, comparer ); } ! /// <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 SortedMap( session, persister, comparer, disassembled, owner ); } } ! } \ No newline at end of file Index: SetType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/SetType.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** SetType.cs 18 Nov 2004 02:44:10 -0000 1.4 --- SetType.cs 31 Dec 2004 23:55:34 -0000 1.5 *************** *** 1,16 **** - using System; using System.Collections; ! using NHibernate.Collection; using NHibernate.Engine; ! namespace NHibernate.Type { ! /// <summary> /// Summary description for SetType. /// </summary> ! public class SetType : PersistentCollectionType { ! ! public SetType(string role) : base(role){ } --- 1,21 ---- using System.Collections; ! using Iesi.Collections; using NHibernate.Collection; using NHibernate.Engine; + using Set = NHibernate.Collection.Set; ! namespace NHibernate.Type ! { /// <summary> /// Summary description for SetType. /// </summary> ! public class SetType : PersistentCollectionType ! { ! /// <summary> ! /// ! /// </summary> ! /// <param name="role"></param> ! public SetType( string role ) : base( role ) ! { } *************** *** 18,23 **** /// <see cref="PersistentCollectionType.Instantiate"/> /// </summary> ! public override PersistentCollection Instantiate(ISessionImplementor session, CollectionPersister persister) { ! return new Set(session); } --- 23,31 ---- /// <see cref="PersistentCollectionType.Instantiate"/> /// </summary> ! /// <param name="persister"></param> ! /// <param name="session"></param> ! public override PersistentCollection Instantiate( ISessionImplementor session, CollectionPersister persister ) ! { ! return new Set( session ); } *************** *** 25,30 **** /// <see cref="AbstractType.ReturnedClass"/> /// </summary> ! public override System.Type ReturnedClass { ! get {return typeof(Iesi.Collections.ISet);} } --- 33,39 ---- /// <see cref="AbstractType.ReturnedClass"/> /// </summary> ! public override System.Type ReturnedClass ! { ! get { return typeof( ISet ); } } *************** *** 32,37 **** /// <see cref="PersistentCollectionType.Wrap"/> /// </summary> ! public override PersistentCollection Wrap(ISessionImplementor session, object collection) { ! return new Set(session, (Iesi.Collections.ISet)collection); } --- 41,49 ---- /// <see cref="PersistentCollectionType.Wrap"/> /// </summary> ! /// <param name="collection"></param> ! /// <param name="session"></param> ! public override PersistentCollection Wrap( ISessionImplementor session, object collection ) ! { ! return new Set( session, ( ISet ) collection ); } *************** *** 39,53 **** /// <see cref="PersistentCollectionType.AssembleCachedCollection"/> /// </summary> ! public override PersistentCollection AssembleCachedCollection(ISessionImplementor session, CollectionPersister persister, object disassembled, object owner) { ! return new Set(session, persister, disassembled, owner); } ! public override ICollection GetElementsCollection(object collection) { ! return (ICollection)collection; } - } ! } --- 51,75 ---- /// <see cref="PersistentCollectionType.AssembleCachedCollection"/> /// </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 Set( session, persister, disassembled, owner ); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="collection"></param> ! /// <returns></returns> ! public override ICollection GetElementsCollection( object collection ) { ! return ( ICollection ) collection; } } ! } \ No newline at end of file Index: SerializableType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/SerializableType.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** SerializableType.cs 25 Oct 2004 05:37:56 -0000 1.6 --- SerializableType.cs 31 Dec 2004 23:55:34 -0000 1.7 *************** *** 3,12 **** using System.IO; using System.Runtime.Serialization.Formatters.Binary; - using NHibernate.Engine; using NHibernate.SqlTypes; ! namespace NHibernate.Type { ! /// <summary> /// Maps an instance of a <see cref="System.Object" /> that has the <see cref="System.SerializableAttribute" /> --- 3,11 ---- using System.IO; using System.Runtime.Serialization.Formatters.Binary; using NHibernate.Engine; using NHibernate.SqlTypes; ! namespace NHibernate.Type ! { /// <summary> /// Maps an instance of a <see cref="System.Object" /> that has the <see cref="System.SerializableAttribute" /> *************** *** 24,28 **** /// </para> /// </remarks> ! public class SerializableType : MutableType { private System.Type serializableClass; --- 23,27 ---- /// </para> /// </remarks> ! public class SerializableType : MutableType { private System.Type serializableClass; *************** *** 30,110 **** private BinaryType binaryType; ! internal SerializableType() : this( typeof(Object) ) { } ! internal SerializableType(System.Type serializableClass) : base( new BinarySqlType() ) { this.serializableClass = serializableClass; ! this.binaryType = (BinaryType)NHibernate.Binary; ! } ! ! internal SerializableType(System.Type serializableClass, BinarySqlType sqlType) : base(sqlType) { this.serializableClass = serializableClass; ! binaryType = (BinaryType)TypeFactory.GetBinaryType(sqlType.Length); } ! public override void Set(IDbCommand st, object value, int index) { ! binaryType.Set(st, ToBytes(value), index); } ! public override object Get(IDataReader rs, int index) { ! byte[] bytes = (byte[]) binaryType.Get(rs, index); ! if ( bytes == null ) { return null; ! } else { ! return FromBytes(bytes); } } ! public override object Get(IDataReader rs, string name) { ! return Get(rs, rs.GetOrdinal(name)); } ! public override System.Type ReturnedClass { get { return serializableClass; } } ! public override bool Equals(object x, object y) { ! if (x==y) return true; ! if (x==null || y==null) return false; ! return binaryType.Equals(ToBytes(x), ToBytes(y)); } ! public override string ToXML(object value) { ! return (value==null) ? null : binaryType.ToXML( ToBytes(value) ); } ! public override string Name { get { return "serializable - " + serializableClass.FullName; } } ! public override object DeepCopyNotNull(object value) { ! return FromBytes( ToBytes(value) ); } ! private byte[] ToBytes(object obj) { ! try { BinaryFormatter bf = new BinaryFormatter(); MemoryStream stream = new MemoryStream(); ! bf.Serialize(stream, obj); return stream.ToArray(); ! } catch (Exception e) { ! throw new SerializationException("Could not serialize a serializable property: ", e); } } ! public object FromBytes(byte[] bytes) { ! try { BinaryFormatter bf = new BinaryFormatter(); ! return bf.Deserialize(new MemoryStream(bytes)); ! } catch (Exception e) { ! throw new SerializationException("Could not deserialize a serializable property: ", e); } } ! public override object Assemble(object cached, ISessionImplementor session, object owner) { ! return (cached==null) ? null : FromBytes( (byte[]) cached ); } ! public override object Disassemble(object value, ISessionImplementor session) { ! return (value==null) ? null : ToBytes(value); } } ! } --- 29,215 ---- private BinaryType binaryType; ! /// <summary></summary> ! internal SerializableType() : this( typeof( Object ) ) { } ! /// <summary> ! /// ! /// </summary> ! /// <param name="serializableClass"></param> ! internal SerializableType( System.Type serializableClass ) : base( new BinarySqlType() ) { this.serializableClass = serializableClass; ! this.binaryType = ( BinaryType ) NHibernate.Binary; ! } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="serializableClass"></param> ! /// <param name="sqlType"></param> ! internal SerializableType( System.Type serializableClass, BinarySqlType sqlType ) : base( sqlType ) ! { this.serializableClass = serializableClass; ! binaryType = ( BinaryType ) TypeFactory.GetBinaryType( sqlType.Length ); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="st"></param> ! /// <param name="value"></param> ! /// <param name="index"></param> ! public override void Set( IDbCommand st, object value, int index ) ! { ! binaryType.Set( st, ToBytes( value ), index ); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="rs"></param> ! /// <param name="index"></param> ! /// <returns></returns> ! public override object Get( IDataReader rs, int index ) ! { ! byte[ ] bytes = ( byte[ ] ) binaryType.Get( rs, index ); ! if( bytes == null ) ! { return null; ! } ! else ! { ! return FromBytes( bytes ); } } ! /// <summary> ! /// ! /// </summary> ! /// <param name="rs"></param> ! /// <param name="name"></param> ! /// <returns></returns> ! public override object Get( IDataReader rs, string name ) ! { ! return Get( rs, rs.GetOrdinal( name ) ); } ! /// <summary> ! /// ! /// </summary> ! public override System.Type ReturnedClass ! { get { return serializableClass; } } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="x"></param> ! /// <param name="y"></param> ! /// <returns></returns> ! public override bool Equals( object x, object y ) ! { ! if( x == y ) ! { ! return true; ! } ! if( x == null || y == null ) ! { ! return false; ! } ! return binaryType.Equals( ToBytes( x ), ToBytes( y ) ); } ! ! /// <summary></summary> ! public override int GetHashCode() ! { ! return base.GetHashCode(); } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="value"></param> ! /// <returns></returns> ! public override string ToXML( object value ) ! { ! return ( value == null ) ? null : binaryType.ToXML( ToBytes( value ) ); ! } ! ! /// <summary></summary> ! public override string Name ! { get { return "serializable - " + serializableClass.FullName; } } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="value"></param> ! /// <returns></returns> ! public override object DeepCopyNotNull( object value ) ! { ! return FromBytes( ToBytes( value ) ); } ! ! private byte[ ] ToBytes( object obj ) ! { ! try ! { BinaryFormatter bf = new BinaryFormatter(); MemoryStream stream = new MemoryStream(); ! bf.Serialize( stream, obj ); return stream.ToArray(); ! } ! catch( Exception e ) ! { ! throw new SerializationException( "Could not serialize a serializable property: ", e ); } } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="bytes"></param> ! /// <returns></returns> ! public object FromBytes( byte[ ] bytes ) ! { ! try ! { BinaryFormatter bf = new BinaryFormatter(); ! return bf.Deserialize( new MemoryStream( bytes ) ); ! } ! catch( Exception e ) ! { ! throw new SerializationException( "Could not deserialize a serializable property: ", e ); } } ! /// <summary> ! /// ! /// </summary> ! /// <param name="cached"></param> ! /// <param name="session"></param> ! /// <param name="owner"></param> ! /// <returns></returns> ! public override object Assemble( object cached, ISessionImplementor session, object owner ) ! { ! return ( cached == null ) ? null : FromBytes( ( byte[ ] ) cached ); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="value"></param> ! /// <param name="session"></param> ! /// <returns></returns> ! public override object Disassemble( object value, ISessionImplementor session ) ! { ! return ( value == null ) ? null : ToBytes( value ); } } ! } \ No newline at end of file Index: SerializationException.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/SerializationException.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** SerializationException.cs 22 Nov 2004 03:50:04 -0000 1.4 --- SerializationException.cs 31 Dec 2004 23:55:34 -0000 1.5 *************** *** 1,5 **** using System; ! namespace NHibernate.Type { /// <summary> --- 1,5 ---- using System; ! namespace NHibernate.Type { /// <summary> *************** *** 7,13 **** /// </summary> [Serializable] ! public class SerializationException : HibernateException { ! public SerializationException(string message, Exception root) : base(message, root) { } } ! } --- 7,20 ---- /// </summary> [Serializable] ! public class SerializationException : HibernateException { ! /// <summary> ! /// ! /// </summary> ! /// <param name="message"></param> ! /// <param name="root"></param> ! public SerializationException( string message, Exception root ) : base( message, root ) ! { ! } } ! } \ No newline at end of file Index: SingleType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/SingleType.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** SingleType.cs 25 Oct 2004 05:37:56 -0000 1.6 --- SingleType.cs 31 Dec 2004 23:55:34 -0000 1.7 *************** *** 1,10 **** using System; using System.Data; - using NHibernate.SqlTypes; ! namespace NHibernate.Type { - /// <summary> /// Maps a <see cref="System.Single" /> Property to an --- 1,8 ---- using System; using System.Data; using NHibernate.SqlTypes; ! namespace NHibernate.Type { /// <summary> /// Maps a <see cref="System.Single" /> Property to an *************** *** 15,54 **** /// matches up with the capabilities of <see cref="System.Single" /> /// </remarks> ! public class SingleType : ValueTypeType { ! internal SingleType() : base( new SingleSqlType() ) { } ! public override object Get(IDataReader rs, int index) { ! return Convert.ToSingle(rs[index]); } ! public override object Get(IDataReader rs, string name) { ! return Convert.ToSingle(rs[name]); } ! public override System.Type ReturnedClass { ! get { return typeof(System.Single); } } ! public override void Set(IDbCommand st, object value, int index) { ! IDataParameter parm = st.Parameters[index] as IDataParameter; parm.Value = value; } ! public override string Name { get { return "Single"; } } ! public override string ObjectToSQLString(object value) { return value.ToString(); } } ! } --- 13,78 ---- /// matches up with the capabilities of <see cref="System.Single" /> /// </remarks> ! public class SingleType : ValueTypeType { ! /// <summary></summary> ! internal SingleType() : base( new SingleSqlType() ) { } ! /// <summary> ! /// ! /// </summary> ! /// <param name="rs"></param> ! /// <param name="index"></param> ! /// <returns></returns> ! public override object Get( IDataReader rs, int index ) { ! return Convert.ToSingle( rs[ index ] ); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="rs"></param> ! /// <param name="name"></param> ! /// <returns></returns> ! public override object Get( IDataReader rs, string name ) { ! return Convert.ToSingle( rs[ name ] ); } ! /// <summary></summary> ! public override System.Type ReturnedClass { ! get { return typeof( Single ); } } ! /// <summary> ! /// ! /// </summary> ! /// <param name="st"></param> ! /// <param name="value"></param> ! /// <param name="index"></param> ! public override void Set( IDbCommand st, object value, int index ) { ! IDataParameter parm = st.Parameters[ index ] as IDataParameter; parm.Value = value; } ! /// <summary></summary> ! public override string Name { get { return "Single"; } } ! /// <summary> ! /// ! /// </summary> ! /// <param name="value"></param> ! /// <returns></returns> ! public override string ObjectToSQLString( object value ) { return value.ToString(); } } ! } \ No newline at end of file |