You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ibatis.apache.org by gb...@apache.org on 2007/02/19 18:52:43 UTC

svn commit: r509271 - /ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/TypeUtils.cs

Author: gbayon
Date: Mon Feb 19 09:52:43 2007
New Revision: 509271

URL: http://svn.apache.org/viewvc?view=rev&rev=509271
Log:
Refactoring after remark of Michael Schall

Modified:
    ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/TypeUtils.cs

Modified: ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/TypeUtils.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/TypeUtils.cs?view=diff&rev=509271&r1=509270&r2=509271
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/TypeUtils.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/TypeUtils.cs Mon Feb 19 09:52:43 2007
@@ -227,36 +227,28 @@
         public static bool IsImplementGenericIListInterface(Type type)
         {
             bool ret = false;
-            
-            if (!type.IsGenericType)
-            {
-                ret = false;  
-            }
 
-            Type genericTypeDef = null;
-            try
+            if (!type.IsGenericType)
             {
-                genericTypeDef = type.GetGenericTypeDefinition();
+                ret = false;
             }
-            catch {}
 
-            // Check if it is IList<T>
-            if (genericTypeDef!=null && typeof(IList<>).IsAssignableFrom(genericTypeDef))
+            if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(IList<>))
             {
-                ret = true;
+                return true;
             }
             else // check if one of the derived interfaces is IList<>
             {
                 Type[] interfaceTypes = type.GetInterfaces();
                 foreach (Type interfaceType in interfaceTypes)
                 {
-                    if (interfaceType.IsGenericType &&
-                      interfaceType.GetGenericTypeDefinition() == typeof(IList<>))
+                    ret = IsImplementGenericIListInterface(interfaceType);
+                    if (ret)
                     {
-                        ret = true;
+                        break;
                     }
                 }
-            }                
+            }
             return ret;
         } 
 #endif