From: <fab...@us...> - 2009-01-10 15:40:12
|
Revision: 3989 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3989&view=rev Author: fabiomaulo Date: 2009-01-10 15:40:05 +0000 (Sat, 10 Jan 2009) Log Message: ----------- Refactoring (removed compilation warning) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Util/ReflectHelper.cs Modified: trunk/nhibernate/src/NHibernate/Util/ReflectHelper.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Util/ReflectHelper.cs 2009-01-10 15:20:49 UTC (rev 3988) +++ trunk/nhibernate/src/NHibernate/Util/ReflectHelper.cs 2009-01-10 15:40:05 UTC (rev 3989) @@ -11,23 +11,15 @@ /// <summary> /// Helper class for Reflection related code. /// </summary> - public sealed class ReflectHelper + public static class ReflectHelper { - private const BindingFlags defaultBindingFlags = - BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly; - private static readonly ILog log = LogManager.GetLogger(typeof(ReflectHelper)); - public static BindingFlags AnyVisibilityInstance = BindingFlags.Instance | BindingFlags.Public | + public const BindingFlags AnyVisibilityInstance = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; - private ReflectHelper() - { - // not creatable - } + private static readonly System.Type[] NoClasses = System.Type.EmptyTypes; - private static System.Type[] NoClasses = System.Type.EmptyTypes; - private static readonly MethodInfo Exception_InternalPreserveStackTrace = typeof(Exception).GetMethod("InternalPreserveStackTrace", BindingFlags.Instance | BindingFlags.NonPublic); @@ -41,7 +33,7 @@ { try { - MethodInfo equals = clazz.GetMethod("Equals", new System.Type[] { typeof(object) }); + MethodInfo equals = clazz.GetMethod("Equals", new[] { typeof(object) }); if (equals == null) { return false; @@ -199,7 +191,7 @@ } else { - if (classFullName != null && classFullName.Length > 0) + if (!string.IsNullOrEmpty(classFullName)) { Assembly[] ass = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly a in ass) @@ -404,9 +396,9 @@ throw new InstantiationException(FormatConstructorNotFoundMessage(types), null, type); } - private static string FormatConstructorNotFoundMessage(IType[] types) + private static string FormatConstructorNotFoundMessage(IEnumerable<IType> types) { - StringBuilder result = new StringBuilder("no constructor compatible with ("); + var result = new StringBuilder("no constructor compatible with ("); bool first = true; foreach (IType type in types) { @@ -486,8 +478,6 @@ /// </remarks> public static MethodInfo TryGetMethod(IEnumerable<System.Type> types, MethodInfo method) { - var bindingFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; - // This method will be used when we support multiple proxy interfaces. if (types == null) { @@ -526,7 +516,7 @@ private static MethodInfo SafeGetMethod(System.Type type, MethodInfo method, System.Type[] tps) { - var bindingFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; + const BindingFlags bindingFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; try { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |