From: Kevin W. <kev...@us...> - 2004-12-31 22:33:03
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlTypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10591 Modified Files: SqlType.cs SqlTypeFactory.cs Log Message: fixing xml comments and letting ReSharper do reformatting Index: SqlType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlTypes/SqlType.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** SqlType.cs 11 Dec 2004 16:28:28 -0000 1.5 --- SqlType.cs 31 Dec 2004 22:32:52 -0000 1.6 *************** *** 2,7 **** using System.Data; ! namespace NHibernate.SqlTypes ! { /// <summary> /// This is the base class that adds information to the <see cref="DbType" /> --- 2,7 ---- using System.Data; ! namespace NHibernate.SqlTypes ! { /// <summary> /// This is the base class that adds information to the <see cref="DbType" /> *************** *** 29,39 **** private bool _lengthDefined = false; private bool _precisionDefined = false; ! ! protected SqlType(DbType dbType) { _dbType = dbType; } ! protected SqlType(DbType dbType, int length) { _dbType = dbType; --- 29,48 ---- private bool _lengthDefined = false; private bool _precisionDefined = false; ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="dbType"></param> ! protected SqlType( DbType dbType ) { _dbType = dbType; } ! /// <summary> ! /// ! /// </summary> ! /// <param name="dbType"></param> ! /// <param name="length"></param> ! protected SqlType( DbType dbType, int length ) { _dbType = dbType; *************** *** 42,46 **** } ! protected SqlType(DbType dbType, byte precision, byte scale) { _dbType = dbType; --- 51,61 ---- } ! /// <summary> ! /// ! /// </summary> ! /// <param name="dbType"></param> ! /// <param name="precision"></param> ! /// <param name="scale"></param> ! protected SqlType( DbType dbType, byte precision, byte scale ) { _dbType = dbType; *************** *** 50,98 **** } ! public DbType DbType { ! get { return _dbType;} } ! public int Length { ! get { return _length;} } ! public byte Precision { ! get { return _precision;} } ! public byte Scale { ! get { return _scale;} } ! public bool LengthDefined { ! get { return _lengthDefined;} } ! public bool PrecisionDefined { ! get { return _precisionDefined;} } #region System.Object Members ! public override int GetHashCode() { int hashCode = 0; ! if( LengthDefined ) { hashCode = ( DbType.GetHashCode()/2 ) + ( Length.GetHashCode()/2 ); } ! else if( PrecisionDefined) { hashCode = ( DbType.GetHashCode()/3 ) + ( Precision.GetHashCode()/3 ) + ( Scale.GetHashCode()/3 ); } ! else { hashCode = DbType.GetHashCode(); --- 65,120 ---- } ! /// <summary></summary> ! public DbType DbType { ! get { return _dbType; } } ! /// <summary></summary> ! public int Length { ! get { return _length; } } ! /// <summary></summary> ! public byte Precision { ! get { return _precision; } } ! /// <summary></summary> ! public byte Scale { ! get { return _scale; } } ! /// <summary></summary> ! public bool LengthDefined { ! get { return _lengthDefined; } } ! /// <summary></summary> ! public bool PrecisionDefined { ! get { return _precisionDefined; } } #region System.Object Members ! /// <summary></summary> ! public override int GetHashCode() { int hashCode = 0; ! if( LengthDefined ) { hashCode = ( DbType.GetHashCode()/2 ) + ( Length.GetHashCode()/2 ); } ! else if( PrecisionDefined ) { hashCode = ( DbType.GetHashCode()/3 ) + ( Precision.GetHashCode()/3 ) + ( Scale.GetHashCode()/3 ); } ! else { hashCode = DbType.GetHashCode(); *************** *** 102,116 **** } ! public override bool Equals(object obj) { bool equals = false; SqlType rhsSqlType; ! // Step1: Perform an equals test ! if( obj==this ) return true; // Step 2: Instance of check rhsSqlType = obj as SqlType; ! if( rhsSqlType==null ) return false; //Step 3: Check each important field --- 124,149 ---- } ! /// <summary> ! /// ! /// </summary> ! /// <param name="obj"></param> ! /// <returns></returns> ! public override bool Equals( object obj ) { bool equals = false; SqlType rhsSqlType; ! // Step1: Perform an equals test ! if( obj == this ) ! { ! return true; ! } // Step 2: Instance of check rhsSqlType = obj as SqlType; ! if( rhsSqlType == null ) ! { ! return false; ! } //Step 3: Check each important field *************** *** 118,131 **** if( LengthDefined ) { ! equals = ( DbType.Equals( rhsSqlType.DbType ) ) ! && ( Length==rhsSqlType.Length ); } ! else if( PrecisionDefined ) { equals = ( DbType.Equals( rhsSqlType.DbType ) ) ! && ( Precision==rhsSqlType.Precision ) ! && ( Scale==rhsSqlType.Scale ); } ! else { equals = ( DbType.Equals( rhsSqlType.DbType ) ); --- 151,164 ---- if( LengthDefined ) { ! equals = ( DbType.Equals( rhsSqlType.DbType ) ) ! && ( Length == rhsSqlType.Length ); } ! else if( PrecisionDefined ) { equals = ( DbType.Equals( rhsSqlType.DbType ) ) ! && ( Precision == rhsSqlType.Precision ) ! && ( Scale == rhsSqlType.Scale ); } ! else { equals = ( DbType.Equals( rhsSqlType.DbType ) ); *************** *** 137,141 **** #endregion - } ! } --- 170,173 ---- #endregion } ! } \ No newline at end of file Index: SqlTypeFactory.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlTypes/SqlTypeFactory.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** SqlTypeFactory.cs 22 Nov 2004 03:52:18 -0000 1.8 --- SqlTypeFactory.cs 31 Dec 2004 22:32:52 -0000 1.9 *************** *** 2,6 **** using System.Collections; ! namespace NHibernate.SqlTypes { /// <summary> --- 2,6 ---- using System.Collections; ! namespace NHibernate.SqlTypes { /// <summary> *************** *** 8,17 **** /// </summary> [Serializable] ! public sealed class SqlTypeFactory { // key = typeof(sqlType).Name : ie - BinarySqlType(l), BooleanSqlType, DecimalSqlType(p,s) // value = SqlType ! private static Hashtable sqlTypes = Hashtable.Synchronized(new Hashtable(41)); ! private static object lockObject = new object(); private SqlTypeFactory() --- 8,17 ---- /// </summary> [Serializable] ! public sealed class SqlTypeFactory { // key = typeof(sqlType).Name : ie - BinarySqlType(l), BooleanSqlType, DecimalSqlType(p,s) // value = SqlType ! private static Hashtable sqlTypes = Hashtable.Synchronized( new Hashtable( 41 ) ); ! private static object lockObject = new object(); // not used !?! private SqlTypeFactory() *************** *** 19,42 **** } ! public static AnsiStringSqlType GetAnsiString(int length) { ! string key = GetKeyForLengthBased(typeof(AnsiStringSqlType).Name, length); ! AnsiStringSqlType returnSqlType = (AnsiStringSqlType) sqlTypes[key]; ! if(returnSqlType == null) { ! returnSqlType = new AnsiStringSqlType(length); ! sqlTypes.Add(key, returnSqlType); } return returnSqlType; } ! public static AnsiStringFixedLengthSqlType GetAnsiStringFixedLength(int length) { ! string key = GetKeyForLengthBased(typeof(AnsiStringFixedLengthSqlType).Name, length); ! AnsiStringFixedLengthSqlType returnSqlType = (AnsiStringFixedLengthSqlType) sqlTypes[key]; ! if(returnSqlType == null) { ! returnSqlType = new AnsiStringFixedLengthSqlType(length); ! sqlTypes.Add(key, returnSqlType); } return returnSqlType; --- 19,52 ---- } ! /// <summary> ! /// ! /// </summary> ! /// <param name="length"></param> ! /// <returns></returns> ! public static AnsiStringSqlType GetAnsiString( int length ) { ! string key = GetKeyForLengthBased( typeof( AnsiStringSqlType ).Name, length ); ! AnsiStringSqlType returnSqlType = ( AnsiStringSqlType ) sqlTypes[ key ]; ! if( returnSqlType == null ) { ! returnSqlType = new AnsiStringSqlType( length ); ! sqlTypes.Add( key, returnSqlType ); } return returnSqlType; } ! /// <summary> ! /// ! /// </summary> ! /// <param name="length"></param> ! /// <returns></returns> ! public static AnsiStringFixedLengthSqlType GetAnsiStringFixedLength( int length ) { ! string key = GetKeyForLengthBased( typeof( AnsiStringFixedLengthSqlType ).Name, length ); ! AnsiStringFixedLengthSqlType returnSqlType = ( AnsiStringFixedLengthSqlType ) sqlTypes[ key ]; ! if( returnSqlType == null ) { ! returnSqlType = new AnsiStringFixedLengthSqlType( length ); ! sqlTypes.Add( key, returnSqlType ); } return returnSqlType; *************** *** 44,281 **** } ! public static BinarySqlType GetBinary(int length) { ! string key = GetKeyForLengthBased(typeof(BinarySqlType).Name, length); ! BinarySqlType returnSqlType = (BinarySqlType)sqlTypes[key]; ! if(returnSqlType==null) { ! returnSqlType = new BinarySqlType(length); ! sqlTypes.Add(key, returnSqlType); } return returnSqlType; ! } ! public static BooleanSqlType GetBoolean() { ! string key = typeof(BooleanSqlType).Name; ! BooleanSqlType returnSqlType = (BooleanSqlType)sqlTypes[key]; ! if(returnSqlType==null) { returnSqlType = new BooleanSqlType(); ! sqlTypes.Add(key, returnSqlType); } ! return returnSqlType; } - - public static ByteSqlType GetByte() - { ! string key = typeof(ByteSqlType).Name; ! ByteSqlType returnSqlType = (ByteSqlType)sqlTypes[key]; ! if(returnSqlType==null) { returnSqlType = new ByteSqlType(); ! sqlTypes.Add(key, returnSqlType); } ! return returnSqlType; } ! public static CurrencySqlType GetCurrency() { ! string key = typeof(CurrencySqlType).Name; ! ! CurrencySqlType returnSqlType = (CurrencySqlType)sqlTypes[key]; ! if(returnSqlType==null) { returnSqlType = new CurrencySqlType(); ! sqlTypes.Add(key, returnSqlType); } ! return returnSqlType; } public static DateSqlType GetDate() { ! string key = typeof(DateSqlType).Name; ! ! DateSqlType returnSqlType = (DateSqlType)sqlTypes[key]; ! if(returnSqlType==null) { ! returnSqlType = new DateSqlType(); ! sqlTypes.Add(key, returnSqlType); ! } ! ! return returnSqlType; ! } ! public static DateTimeSqlType GetDateTime() { ! string key = typeof(DateTimeSqlType).Name; ! ! DateTimeSqlType returnSqlType = (DateTimeSqlType)sqlTypes[key]; ! if(returnSqlType==null) { returnSqlType = new DateTimeSqlType(); ! sqlTypes.Add(key, returnSqlType); } ! return returnSqlType; } ! public static DecimalSqlType GetDecimal(byte precision, byte scale) { ! string key = GetKeyForPrecisionScaleBased(typeof(DecimalSqlType).Name, precision, scale); ! ! DecimalSqlType returnSqlType = (DecimalSqlType)sqlTypes[key]; ! if(returnSqlType==null) { ! returnSqlType = new DecimalSqlType(precision, scale); ! sqlTypes.Add(key, returnSqlType); } ! return returnSqlType; } ! public static DoubleSqlType GetDouble() { ! string key = typeof(DoubleSqlType).Name; ! ! DoubleSqlType returnSqlType = (DoubleSqlType)sqlTypes[key]; ! if(returnSqlType==null) { returnSqlType = new DoubleSqlType(); ! sqlTypes.Add(key, returnSqlType); } ! return returnSqlType; } ! public static GuidSqlType GetGuid() { ! string key = typeof(GuidSqlType).Name; ! ! GuidSqlType returnSqlType = (GuidSqlType)sqlTypes[key]; ! if(returnSqlType==null) { returnSqlType = new GuidSqlType(); ! sqlTypes.Add(key, returnSqlType); } ! return returnSqlType; } ! public static Int16SqlType GetInt16() { ! string key = typeof(Int16SqlType).Name; ! ! Int16SqlType returnSqlType = (Int16SqlType)sqlTypes[key]; ! if(returnSqlType==null) { returnSqlType = new Int16SqlType(); ! sqlTypes.Add(key, returnSqlType); } ! return returnSqlType; } ! public static Int32SqlType GetInt32() { ! string key = typeof(Int32SqlType).Name; ! ! Int32SqlType returnSqlType = (Int32SqlType)sqlTypes[key]; ! if(returnSqlType==null) { returnSqlType = new Int32SqlType(); ! sqlTypes.Add(key, returnSqlType); } ! return returnSqlType; } ! public static Int64SqlType GetInt64() { ! string key = typeof(Int64SqlType).Name; ! ! Int64SqlType returnSqlType = (Int64SqlType)sqlTypes[key]; ! if(returnSqlType==null) { returnSqlType = new Int64SqlType(); ! sqlTypes.Add(key, returnSqlType); } ! return returnSqlType; } ! public static SingleSqlType GetSingle() { ! string key = typeof(SingleSqlType).Name; ! ! SingleSqlType returnSqlType = (SingleSqlType)sqlTypes[key]; ! if(returnSqlType==null) { returnSqlType = new SingleSqlType(); ! sqlTypes.Add(key, returnSqlType); } ! return returnSqlType; } ! public static StringSqlType GetString(int length) { ! string key = GetKeyForLengthBased(typeof(StringSqlType).Name, length); ! ! StringSqlType returnSqlType = (StringSqlType)sqlTypes[key]; ! if(returnSqlType==null) { ! returnSqlType = new StringSqlType(length); ! sqlTypes.Add(key, returnSqlType); } ! return returnSqlType; } ! public static StringFixedLengthSqlType GetStringFixedLength(int length) { ! string key = GetKeyForLengthBased(typeof(StringFixedLengthSqlType).Name, length); ! ! StringFixedLengthSqlType returnSqlType = (StringFixedLengthSqlType)sqlTypes[key]; ! if(returnSqlType==null) { ! returnSqlType = new StringFixedLengthSqlType(length); ! sqlTypes.Add(key, returnSqlType); } ! return returnSqlType; } ! public static TimeSqlType GetTime() { ! string key = typeof(TimeSqlType).Name; ! ! TimeSqlType returnSqlType = (TimeSqlType)sqlTypes[key]; ! if(returnSqlType==null) { returnSqlType = new TimeSqlType(); ! sqlTypes.Add(key, returnSqlType); } ! return returnSqlType; } ! private static string GetKeyForLengthBased(string name, int length) { return name + "(" + length + ")"; } ! private static string GetKeyForPrecisionScaleBased(string name, byte precision, byte scale) { return name + "(" + precision + ", " + scale + ")"; } } ! } --- 54,322 ---- } ! /// <summary> ! /// ! /// </summary> ! /// <param name="length"></param> ! /// <returns></returns> ! public static BinarySqlType GetBinary( int length ) { ! string key = GetKeyForLengthBased( typeof( BinarySqlType ).Name, length ); ! BinarySqlType returnSqlType = ( BinarySqlType ) sqlTypes[ key ]; ! if( returnSqlType == null ) { ! returnSqlType = new BinarySqlType( length ); ! sqlTypes.Add( key, returnSqlType ); } return returnSqlType; ! } ! /// <summary></summary> ! public static BooleanSqlType GetBoolean() { ! string key = typeof( BooleanSqlType ).Name; ! BooleanSqlType returnSqlType = ( BooleanSqlType ) sqlTypes[ key ]; ! if( returnSqlType == null ) { returnSqlType = new BooleanSqlType(); ! sqlTypes.Add( key, returnSqlType ); } ! return returnSqlType; } ! /// <summary></summary> ! public static ByteSqlType GetByte() ! { ! string key = typeof( ByteSqlType ).Name; ! ByteSqlType returnSqlType = ( ByteSqlType ) sqlTypes[ key ]; ! if( returnSqlType == null ) { returnSqlType = new ByteSqlType(); ! sqlTypes.Add( key, returnSqlType ); } ! return returnSqlType; } ! /// <summary></summary> ! public static CurrencySqlType GetCurrency() { ! string key = typeof( CurrencySqlType ).Name; ! ! CurrencySqlType returnSqlType = ( CurrencySqlType ) sqlTypes[ key ]; ! if( returnSqlType == null ) { returnSqlType = new CurrencySqlType(); ! sqlTypes.Add( key, returnSqlType ); } ! return returnSqlType; } + /// <summary></summary> public static DateSqlType GetDate() { ! string key = typeof( DateSqlType ).Name; ! ! DateSqlType returnSqlType = ( DateSqlType ) sqlTypes[ key ]; ! if( returnSqlType == null ) { ! returnSqlType = new DateSqlType(); ! sqlTypes.Add( key, returnSqlType ); ! } + return returnSqlType; + } ! /// <summary></summary> ! public static DateTimeSqlType GetDateTime() { ! string key = typeof( DateTimeSqlType ).Name; ! ! DateTimeSqlType returnSqlType = ( DateTimeSqlType ) sqlTypes[ key ]; ! if( returnSqlType == null ) { returnSqlType = new DateTimeSqlType(); ! sqlTypes.Add( key, returnSqlType ); } ! return returnSqlType; } ! /// <summary> ! /// ! /// </summary> ! /// <param name="precision"></param> ! /// <param name="scale"></param> ! /// <returns></returns> ! public static DecimalSqlType GetDecimal( byte precision, byte scale ) { ! string key = GetKeyForPrecisionScaleBased( typeof( DecimalSqlType ).Name, precision, scale ); ! ! DecimalSqlType returnSqlType = ( DecimalSqlType ) sqlTypes[ key ]; ! if( returnSqlType == null ) { ! returnSqlType = new DecimalSqlType( precision, scale ); ! sqlTypes.Add( key, returnSqlType ); } ! return returnSqlType; } ! /// <summary></summary> ! public static DoubleSqlType GetDouble() { ! string key = typeof( DoubleSqlType ).Name; ! ! DoubleSqlType returnSqlType = ( DoubleSqlType ) sqlTypes[ key ]; ! if( returnSqlType == null ) { returnSqlType = new DoubleSqlType(); ! sqlTypes.Add( key, returnSqlType ); } ! return returnSqlType; } ! /// <summary></summary> ! public static GuidSqlType GetGuid() { ! string key = typeof( GuidSqlType ).Name; ! ! GuidSqlType returnSqlType = ( GuidSqlType ) sqlTypes[ key ]; ! if( returnSqlType == null ) { returnSqlType = new GuidSqlType(); ! sqlTypes.Add( key, returnSqlType ); } ! return returnSqlType; } ! /// <summary></summary> ! public static Int16SqlType GetInt16() { ! string key = typeof( Int16SqlType ).Name; ! ! Int16SqlType returnSqlType = ( Int16SqlType ) sqlTypes[ key ]; ! if( returnSqlType == null ) { returnSqlType = new Int16SqlType(); ! sqlTypes.Add( key, returnSqlType ); } ! return returnSqlType; } ! /// <summary></summary> ! public static Int32SqlType GetInt32() { ! string key = typeof( Int32SqlType ).Name; ! ! Int32SqlType returnSqlType = ( Int32SqlType ) sqlTypes[ key ]; ! if( returnSqlType == null ) { returnSqlType = new Int32SqlType(); ! sqlTypes.Add( key, returnSqlType ); } ! return returnSqlType; } ! /// <summary></summary> ! public static Int64SqlType GetInt64() { ! string key = typeof( Int64SqlType ).Name; ! ! Int64SqlType returnSqlType = ( Int64SqlType ) sqlTypes[ key ]; ! if( returnSqlType == null ) { returnSqlType = new Int64SqlType(); ! sqlTypes.Add( key, returnSqlType ); } ! return returnSqlType; } ! /// <summary></summary> ! public static SingleSqlType GetSingle() { ! string key = typeof( SingleSqlType ).Name; ! ! SingleSqlType returnSqlType = ( SingleSqlType ) sqlTypes[ key ]; ! if( returnSqlType == null ) { returnSqlType = new SingleSqlType(); ! sqlTypes.Add( key, returnSqlType ); } ! return returnSqlType; } ! /// <summary> ! /// ! /// </summary> ! /// <param name="length"></param> ! /// <returns></returns> ! public static StringSqlType GetString( int length ) { ! string key = GetKeyForLengthBased( typeof( StringSqlType ).Name, length ); ! ! StringSqlType returnSqlType = ( StringSqlType ) sqlTypes[ key ]; ! if( returnSqlType == null ) { ! returnSqlType = new StringSqlType( length ); ! sqlTypes.Add( key, returnSqlType ); } ! return returnSqlType; } ! /// <summary> ! /// ! /// </summary> ! /// <param name="length"></param> ! /// <returns></returns> ! public static StringFixedLengthSqlType GetStringFixedLength( int length ) { ! string key = GetKeyForLengthBased( typeof( StringFixedLengthSqlType ).Name, length ); ! ! StringFixedLengthSqlType returnSqlType = ( StringFixedLengthSqlType ) sqlTypes[ key ]; ! if( returnSqlType == null ) { ! returnSqlType = new StringFixedLengthSqlType( length ); ! sqlTypes.Add( key, returnSqlType ); } ! return returnSqlType; } ! /// <summary></summary> ! public static TimeSqlType GetTime() { ! string key = typeof( TimeSqlType ).Name; ! ! TimeSqlType returnSqlType = ( TimeSqlType ) sqlTypes[ key ]; ! if( returnSqlType == null ) { returnSqlType = new TimeSqlType(); ! sqlTypes.Add( key, returnSqlType ); } ! return returnSqlType; } ! private static string GetKeyForLengthBased( string name, int length ) { return name + "(" + length + ")"; } ! private static string GetKeyForPrecisionScaleBased( string name, byte precision, byte scale ) { return name + "(" + precision + ", " + scale + ")"; } } ! } \ No newline at end of file |