Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/TypeHandlers/TimeSpanTypeHandler.cs URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/TypeHandlers/TimeSpanTypeHandler.cs?rev=697593&r1=697592&r2=697593&view=diff ============================================================================== --- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/TypeHandlers/TimeSpanTypeHandler.cs (original) +++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/TypeHandlers/TimeSpanTypeHandler.cs Sun Sep 21 12:25:16 2008 @@ -24,14 +24,10 @@ ********************************************************************************/ #endregion -#region Using - using System; using System.Data; -using System.Globalization; using Apache.Ibatis.DataMapper.Model.ResultMapping; -#endregion namespace Apache.Ibatis.DataMapper.TypeHandlers { @@ -52,7 +48,6 @@ dataParameter.Value = ((TimeSpan)parameterValue).Ticks; } - /// <summary> /// Gets a column value by the name /// </summary> @@ -63,14 +58,11 @@ { int index = dataReader.GetOrdinal(mapping.ColumnName); - if (dataReader.IsDBNull(index) == true) - { - return System.DBNull.Value; - } - else + if (dataReader.IsDBNull(index)) { - return new TimeSpan( Convert.ToInt64(dataReader.GetValue(index)) ); + return DBNull.Value; } + return new TimeSpan( Convert.ToInt64(dataReader.GetValue(index)) ); } @@ -80,19 +72,16 @@ /// <param name="mapping"></param> /// <param name="dataReader"></param> /// <returns></returns> - public override object GetValueByIndex(ResultProperty mapping, IDataReader dataReader) - { - if (dataReader.IsDBNull(mapping.ColumnIndex) == true) - { - return System.DBNull.Value; - } - else + public override object GetValueByIndex(ResultProperty mapping, IDataReader dataReader) + { + if (dataReader.IsDBNull(mapping.ColumnIndex)) { - return new TimeSpan( Convert.ToInt64(dataReader.GetValue(mapping.ColumnIndex)) ); + return DBNull.Value; } - } + return new TimeSpan( Convert.ToInt64(dataReader.GetValue(mapping.ColumnIndex)) ); + } - /// <summary> + /// <summary> /// Retrieve ouput database value of an output parameter /// </summary> /// <param name="outputValue">ouput database value</param>
Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/TypeHandlers/TypeHandlerFactory.cs URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/TypeHandlers/TypeHandlerFactory.cs?rev=697593&r1=697592&r2=697593&view=diff ============================================================================== --- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/TypeHandlers/TypeHandlerFactory.cs (original) +++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/TypeHandlers/TypeHandlerFactory.cs Sun Sep 21 12:25:16 2008 @@ -196,19 +196,16 @@ /// <param name="type">the type you want a TypeHandler for</param> /// <param name="dbType">the database type</param> /// <returns>the handler</returns> - public ITypeHandler GetTypeHandler(Type type, string dbType) + public ITypeHandler GetTypeHandler(Type type, string dbType) { - if (type.IsEnum) + if (type.IsEnum) { return GetPrivateTypeHandler(typeof(Enum), dbType); } - else - { - return GetPrivateTypeHandler(type, dbType); - } + return GetPrivateTypeHandler(type, dbType); } - /// <summary> + /// <summary> /// Get a TypeHandler for a type and a dbType type /// </summary> /// <param name="type">the type</param> @@ -360,7 +357,7 @@ else if (typeof(IDictionary).IsAssignableFrom(classType) || typeof(DataRow).IsAssignableFrom(classType)) { // IDictionary or DataTable - if (memberType == null || memberType.Length == 0) + if (string.IsNullOrEmpty(memberType)) { handler = GetUnkownTypeHandler(); } @@ -385,7 +382,7 @@ else { // .NET object - if (memberType == null || memberType.Length == 0) + if (string.IsNullOrEmpty(memberType)) { Type type = null; if (forSetter) @@ -435,7 +432,7 @@ else if (typeof(IDictionary).IsAssignableFrom(argumentType) || typeof(DataRow).IsAssignableFrom(argumentType)) { // IDictionary or - if (clrType == null || clrType.Length == 0) + if (string.IsNullOrEmpty(clrType)) { handler = GetUnkownTypeHandler(); } @@ -460,7 +457,7 @@ else { // .NET object - if (clrType == null || clrType.Length == 0) + if (string.IsNullOrEmpty(clrType)) { handler = GetUnkownTypeHandler(); } @@ -488,19 +485,16 @@ /// </summary> /// <param name="id">The id of the TypeAlias.</param> /// <returns>The TypeAlias.</returns> - public TypeAlias GetTypeAlias(string id) + public TypeAlias GetTypeAlias(string id) { - if (typeAliasMaps.ContainsKey(id)) + if (typeAliasMaps.ContainsKey(id)) { return typeAliasMaps[id]; } - else - { - throw new ConfigurationException("There's no type alias with the name:" + id); - } + throw new ConfigurationException("There's no type alias with the name:" + id); } - /// <summary> + /// <summary> /// Gets the type object from the specific class name. /// </summary> /// <param name="className">The supplied class name.</param> @@ -530,7 +524,7 @@ /// <param name="typeAlias"> The TypeAlias.</param> public void AddTypeAlias(string key, TypeAlias typeAlias) { - if (typeAliasMaps.ContainsKey(key) == true) + if (typeAliasMaps.ContainsKey(key)) { throw new DataMapperException(" Alias name conflict occurred. The type alias '" + key + "' is already mapped to the value '"+typeAlias +"'."); } Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/TypeHandlers/UInt16TypeHandler.cs URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/TypeHandlers/UInt16TypeHandler.cs?rev=697593&r1=697592&r2=697593&view=diff ============================================================================== --- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/TypeHandlers/UInt16TypeHandler.cs (original) +++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/TypeHandlers/UInt16TypeHandler.cs Sun Sep 21 12:25:16 2008 @@ -24,14 +24,10 @@ ********************************************************************************/ #endregion -#region Using - using System; using System.Data; using Apache.Ibatis.DataMapper.Model.ResultMapping; -#endregion - namespace Apache.Ibatis.DataMapper.TypeHandlers { /// <summary> @@ -39,8 +35,6 @@ /// </summary> public sealed class UInt16TypeHandler : BaseTypeHandler { - - /// <summary> /// Gets a column value by the name /// </summary> @@ -51,15 +45,12 @@ { int index = dataReader.GetOrdinal(mapping.ColumnName); - if (dataReader.IsDBNull(index) == true) + if (dataReader.IsDBNull(index)) { return DBNull.Value; } - else - { - // Don't used dataReader.GetInt32 to fix oracle who alwray return decimal type - return Convert.ToUInt16(dataReader.GetValue(index)); - } + // Don't used dataReader.GetInt32 to fix oracle who alwray return decimal type + return Convert.ToUInt16(dataReader.GetValue(index)); } /// <summary> @@ -70,15 +61,12 @@ /// <returns></returns> public override object GetValueByIndex(ResultProperty mapping, IDataReader dataReader) { - if (dataReader.IsDBNull(mapping.ColumnIndex) == true) + if (dataReader.IsDBNull(mapping.ColumnIndex)) { return DBNull.Value; } - else - { - // Don't used dataReader.GetInt32 to fix oracle who alwray return decimal type - return Convert.ToUInt16(dataReader.GetValue(mapping.ColumnIndex)); - } + // Don't used dataReader.GetInt32 to fix oracle who alwray return decimal type + return Convert.ToUInt16(dataReader.GetValue(mapping.ColumnIndex)); } /// <summary> Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/TypeHandlers/UInt32TypeHandler.cs URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/TypeHandlers/UInt32TypeHandler.cs?rev=697593&r1=697592&r2=697593&view=diff ============================================================================== --- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/TypeHandlers/UInt32TypeHandler.cs (original) +++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/TypeHandlers/UInt32TypeHandler.cs Sun Sep 21 12:25:16 2008 @@ -24,14 +24,10 @@ ********************************************************************************/ #endregion -#region Using - using System; using System.Data; using Apache.Ibatis.DataMapper.Model.ResultMapping; -#endregion - namespace Apache.Ibatis.DataMapper.TypeHandlers { /// <summary> @@ -40,7 +36,6 @@ public sealed class UInt32TypeHandler : BaseTypeHandler { - /// <summary> /// Gets a column value by the name /// </summary> @@ -51,14 +46,11 @@ { int index = dataReader.GetOrdinal(mapping.ColumnName); - if (dataReader.IsDBNull(index) == true) + if (dataReader.IsDBNull(index)) { return DBNull.Value; } - else - { - return Convert.ToUInt32(dataReader.GetValue(index)); - } + return Convert.ToUInt32(dataReader.GetValue(index)); } /// <summary> @@ -69,14 +61,11 @@ /// <returns></returns> public override object GetValueByIndex(ResultProperty mapping, IDataReader dataReader) { - if (dataReader.IsDBNull(mapping.ColumnIndex) == true) + if (dataReader.IsDBNull(mapping.ColumnIndex)) { return DBNull.Value; } - else - { - return Convert.ToUInt32(dataReader.GetValue(mapping.ColumnIndex)); - } + return Convert.ToUInt32(dataReader.GetValue(mapping.ColumnIndex)); } /// <summary> Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/TypeHandlers/UInt64TypeHandler.cs URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/TypeHandlers/UInt64TypeHandler.cs?rev=697593&r1=697592&r2=697593&view=diff ============================================================================== --- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/TypeHandlers/UInt64TypeHandler.cs (original) +++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/TypeHandlers/UInt64TypeHandler.cs Sun Sep 21 12:25:16 2008 @@ -24,14 +24,9 @@ ********************************************************************************/ #endregion -#region Using - using System; using System.Data; -using Apache.Ibatis.DataMapper.Model.ParameterMapping; using Apache.Ibatis.DataMapper.Model.ResultMapping; -#endregion - namespace Apache.Ibatis.DataMapper.TypeHandlers { @@ -40,8 +35,6 @@ /// </summary> public sealed class UInt64TypeHandler : BaseTypeHandler { - - /// <summary> /// Gets a column value by the name /// </summary> @@ -52,14 +45,11 @@ { int index = dataReader.GetOrdinal(mapping.ColumnName); - if (dataReader.IsDBNull(index) == true) + if (dataReader.IsDBNull(index)) { - return System.DBNull.Value; - } - else - { - return Convert.ToUInt64(dataReader.GetValue(index)); + return DBNull.Value; } + return Convert.ToUInt64(dataReader.GetValue(index)); } /// <summary> @@ -70,14 +60,11 @@ /// <returns></returns> public override object GetValueByIndex(ResultProperty mapping, IDataReader dataReader) { - if (dataReader.IsDBNull(mapping.ColumnIndex) == true) - { - return System.DBNull.Value; - } - else + if (dataReader.IsDBNull(mapping.ColumnIndex)) { - return Convert.ToUInt64(dataReader.GetValue(mapping.ColumnIndex)); + return DBNull.Value; } + return Convert.ToUInt64(dataReader.GetValue(mapping.ColumnIndex)); } /// <summary> Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/TypeHandlers/UnknownTypeHandler.cs URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/TypeHandlers/UnknownTypeHandler.cs?rev=697593&r1=697592&r2=697593&view=diff ============================================================================== --- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/TypeHandlers/UnknownTypeHandler.cs (original) +++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/TypeHandlers/UnknownTypeHandler.cs Sun Sep 21 12:25:16 2008 @@ -23,15 +23,10 @@ ********************************************************************************/ #endregion -#region Using - using System; using System.Data; -using Apache.Ibatis.DataMapper.Model.ParameterMapping; using Apache.Ibatis.DataMapper.Model.ResultMapping; -#endregion - namespace Apache.Ibatis.DataMapper.TypeHandlers { /// <summary> @@ -39,8 +34,7 @@ /// </summary> public sealed class UnknownTypeHandler : BaseTypeHandler { - - private TypeHandlerFactory _factory = null; + private readonly TypeHandlerFactory _factory = null; /// <summary> /// Constructor to create via a factory @@ -68,7 +62,7 @@ { // When sending a null parameter value to the server, // the user must specify DBNull, not null. - dataParameter.Value = System.DBNull.Value; + dataParameter.Value = DBNull.Value; } } @@ -82,14 +76,11 @@ { int index = dataReader.GetOrdinal(mapping.ColumnName); - if (dataReader.IsDBNull(index) == true) + if (dataReader.IsDBNull(index)) { - return System.DBNull.Value; + return DBNull.Value; } - else - { - return dataReader.GetValue(index); - } + return dataReader.GetValue(index); } /// <summary> @@ -99,18 +90,15 @@ /// <param name="dataReader"></param> /// <returns></returns> public override object GetValueByIndex(ResultProperty mapping, IDataReader dataReader) - { - if (dataReader.IsDBNull(mapping.ColumnIndex) == true) + { + if (dataReader.IsDBNull(mapping.ColumnIndex)) { - return System.DBNull.Value; + return DBNull.Value; } - else - { - return dataReader.GetValue(mapping.ColumnIndex); - } - } + return dataReader.GetValue(mapping.ColumnIndex); + } - /// <summary> + /// <summary> /// Converts the String to the type that this handler deals with /// </summary> /// <param name="type">the tyepe of the property (used only for enum conversion)</param> @@ -160,13 +148,10 @@ if (obj == null || str == null) { return (string)obj == str; - } - else - { - ITypeHandler handler = _factory.GetTypeHandler(obj.GetType()); - object castedObject = handler.ValueOf(obj.GetType(), str); - return obj.Equals(castedObject); } + ITypeHandler handler = _factory.GetTypeHandler(obj.GetType()); + object castedObject = handler.ValueOf(obj.GetType(), str); + return obj.Equals(castedObject); } } }
