Skip to content
Browse files

Code cleanup

  • Loading branch information...
1 parent 88a4f98 commit dcdfb0642efe074f5a746fbb111ba629b637c967 @hazzik hazzik committed Sep 27, 2012
View
2 ...ernate.Test/MappingByCode/ConventionModelMapperTests/VersionOnBaseClassIntegrationTest.cs
@@ -43,7 +43,7 @@ public void WhenVersionFromBaseEntityThenShouldntMapVersionAsProperty()
var mapper = new ConventionModelMapper();
var baseEntityType = typeof(BaseEntity);
mapper.IsEntity((t, declared) => baseEntityType.IsAssignableFrom(t) && baseEntityType != t && !t.IsInterface);
- mapper.IsRootEntity((t, declared) => baseEntityType.Equals(t.BaseType));
+ mapper.IsRootEntity((t, declared) => baseEntityType == t.BaseType);
mapper.Class<BaseEntity>(
map =>
{
View
2 src/NHibernate.Test/MappingByCode/MixAutomapping/CallCustomConditions.cs
@@ -41,7 +41,7 @@ public void WhenCustomizeConditionsThenUseCustomConditionsToRecognizeRootEntitie
System.Type baseEntityType = typeof(Entity);
var inspector = new SimpleModelInspector();
inspector.IsEntity((t, declared) => baseEntityType.IsAssignableFrom(t) && baseEntityType != t && !t.IsInterface);
- inspector.IsRootEntity((t, declared) => baseEntityType.Equals(t.BaseType));
+ inspector.IsRootEntity((t, declared) => baseEntityType == t.BaseType);
var mapper = new ModelMapper(inspector);
mapper.Class<Entity>(map => map.Id(x => x.Id,
View
6 src/NHibernate.Test/NHAssert.cs
@@ -6,7 +6,7 @@
namespace NHibernate.Test
{
- public class NHAssert
+ public static class NHAssert
{
#region Serializable
@@ -30,7 +30,7 @@ public static void InheritedAreMarkedSerializable(System.Type clazz, string mess
var sb = new StringBuilder();
int failedCount = 0;
Assembly nhbA = Assembly.GetAssembly(clazz);
- IList<System.Type> types = ClassList(nhbA, clazz);
+ var types = ClassList(nhbA, clazz);
foreach (System.Type tp in types)
{
object[] atts = tp.GetCustomAttributes(typeof(SerializableAttribute), false);
@@ -54,7 +54,7 @@ public static void IsSerializable(object obj, string message, params object[] ar
}
#endregion
- private static IList<System.Type> ClassList(Assembly assembly, System.Type type)
+ private static IEnumerable<System.Type> ClassList(Assembly assembly, System.Type type)
{
IList<System.Type> result = new List<System.Type>();
if (assembly != null)
View
1 src/NHibernate.Test/UtilityTest/EnumerableExtensionsTests/AnyExtensionTests.cs
@@ -6,6 +6,7 @@
namespace NHibernate.Test.UtilityTest.EnumerableExtensionsTests
{
+ [TestFixture]
public class AnyExtensionTests
{
[Test]
View
31 src/NHibernate/Linq/ExpressionTransformers/RemoveCharToIntConversion.cs
@@ -15,18 +15,28 @@ namespace NHibernate.Linq.ExpressionTransformers
/// </remarks>
public class RemoveCharToIntConversion : IExpressionTransformer<BinaryExpression>
{
+ private static readonly ExpressionType[] _supportedExpressionTypes = new[]
+ {
+ ExpressionType.Equal,
+ ExpressionType.NotEqual,
+ ExpressionType.GreaterThan,
+ ExpressionType.GreaterThanOrEqual,
+ ExpressionType.LessThan,
+ ExpressionType.LessThanOrEqual
+ };
+
public Expression Transform(BinaryExpression expression)
{
var lhs = expression.Left;
var rhs = expression.Right;
- bool lhsIsConvertExpression = IsConvertExpression(lhs);
- bool rhsIsConvertExpression = IsConvertExpression(rhs);
+ var lhsIsConvertExpression = IsConvertExpression(lhs);
+ var rhsIsConvertExpression = IsConvertExpression(rhs);
if (!lhsIsConvertExpression && !rhsIsConvertExpression) return expression;
- bool lhsIsConstantExpression = IsConstantExpression(lhs);
- bool rhsIsConstantExpression = IsConstantExpression(rhs);
+ var lhsIsConstantExpression = IsConstantExpression(lhs);
+ var rhsIsConstantExpression = IsConstantExpression(rhs);
if (!lhsIsConstantExpression && !rhsIsConstantExpression) return expression;
@@ -58,18 +68,7 @@ private static bool IsConstantExpression(Expression expression)
public ExpressionType[] SupportedExpressionTypes
{
- get
- {
- return new[]
- {
- ExpressionType.Equal,
- ExpressionType.NotEqual,
- ExpressionType.GreaterThan,
- ExpressionType.GreaterThanOrEqual,
- ExpressionType.LessThan,
- ExpressionType.LessThanOrEqual
- };
- }
+ get { return _supportedExpressionTypes; }
}
}
}
View
2 src/NHibernate/Linq/Expressions/NhAverageExpression.cs
@@ -12,7 +12,7 @@ public NhAverageExpression(Expression expression) : base(expression, CalculateAv
private static System.Type CalculateAverageType(System.Type inputType)
{
- bool isNullable = false;
+ var isNullable = false;
if (inputType.IsNullable())
{
View
21 src/NHibernate/NHibernateUtil.cs
@@ -51,28 +51,25 @@ public static IType GuessType(object obj)
/// <returns></returns>
public static IType GuessType(System.Type type)
{
- if(type.IsGenericType && typeof(Nullable<>).Equals(type.GetGenericTypeDefinition()))
+ if(type.IsGenericType && typeof(Nullable<>) == type.GetGenericTypeDefinition())
{
type = type.GetGenericArguments()[0];
}
if (clrTypeToNHibernateType.ContainsKey(type))
{
return clrTypeToNHibernateType[type];
- }
- else if (type.IsEnum)
+ }
+ if (type.IsEnum)
{
return (IType) Activator.CreateInstance(typeof (EnumType<>).MakeGenericType(type));
- }
- else if (
- typeof(IUserType).IsAssignableFrom(type) ||
+ }
+ if (typeof(IUserType).IsAssignableFrom(type) ||
typeof(ICompositeUserType).IsAssignableFrom(type))
{
return Custom(type);
- }
- else
- {
- return Entity(type);
- }
+ }
+
+ return Entity(type);
}
/// <summary>
@@ -283,7 +280,7 @@ public static IType GuessType(System.Type type)
public static readonly NullableType XmlDoc = new XmlDocType();
- public static readonly NullableType XDoc = new XDocType();
+ public static readonly NullableType XDoc = new XDocType();
public static readonly NullableType Uri = new UriType();
View
2 src/NHibernate/Util/TypeExtensions.cs
@@ -12,7 +12,7 @@ public static bool IsEnumerableOfT(this System.Type type)
public static bool IsNullable(this System.Type type)
{
- return (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>));
+ return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>);
}
public static bool IsNullableOrReference(this System.Type type)

0 comments on commit dcdfb06

Please sign in to comment.
Something went wrong with that request. Please try again.