@@ -192,37 +192,53 @@ public static System.Type ClassForName(string name)
192
192
/// the method try to find the System.Type scanning all Assemblies of the <see cref="AppDomain.CurrentDomain"/>.
193
193
/// </remarks>
194
194
/// <exception cref="TypeLoadException">If no System.Type was found for <paramref name="classFullName"/>.</exception>
195
- public static System . Type ClassForFullName ( string classFullName )
195
+ public static System . Type ClassForFullName ( string classFullName )
196
196
{
197
- System . Type result = null ;
198
- AssemblyQualifiedTypeName parsedName = TypeNameParser . Parse ( classFullName ) ;
199
- if ( ! string . IsNullOrEmpty ( parsedName . Assembly ) )
200
- {
201
- result = TypeFromAssembly ( parsedName , false ) ;
202
- }
203
- else
204
- {
205
- if ( ! string . IsNullOrEmpty ( classFullName ) )
206
- {
207
- Assembly [ ] ass = AppDomain . CurrentDomain . GetAssemblies ( ) ;
208
- foreach ( Assembly a in ass )
209
- {
210
- result = a . GetType ( classFullName , false , false ) ;
211
- if ( result != null )
212
- break ; //<<<<<================
213
- }
214
- }
215
- }
216
- if ( result == null )
217
- {
218
- string message = "Could not load type " + classFullName + ". Possible cause: the assembly was not loaded or not specified." ;
219
- throw new TypeLoadException ( message ) ;
220
- }
221
-
222
- return result ;
197
+ var result = ClassForFullNameOrNull ( classFullName ) ;
198
+ if ( result == null )
199
+ {
200
+ string message = "Could not load type " + classFullName + ". Possible cause: the assembly was not loaded or not specified." ;
201
+ throw new TypeLoadException ( message ) ;
202
+ }
203
+
204
+ return result ;
223
205
}
224
206
225
- public static System . Type TypeFromAssembly ( string type , string assembly , bool throwIfError )
207
+ /// <summary>
208
+ /// Load a System.Type given is't name.
209
+ /// </summary>
210
+ /// <param name="classFullName">The class FullName or AssemblyQualifiedName</param>
211
+ /// <returns>The System.Type or null</returns>
212
+ /// <remarks>
213
+ /// If the <paramref name="classFullName"/> don't represent an <see cref="System.Type.AssemblyQualifiedName"/>
214
+ /// the method try to find the System.Type scanning all Assemblies of the <see cref="AppDomain.CurrentDomain"/>.
215
+ /// </remarks>
216
+ public static System . Type ClassForFullNameOrNull ( string classFullName )
217
+ {
218
+ System . Type result = null ;
219
+ AssemblyQualifiedTypeName parsedName = TypeNameParser . Parse ( classFullName ) ;
220
+ if ( ! string . IsNullOrEmpty ( parsedName . Assembly ) )
221
+ {
222
+ result = TypeFromAssembly ( parsedName , false ) ;
223
+ }
224
+ else
225
+ {
226
+ if ( ! string . IsNullOrEmpty ( classFullName ) )
227
+ {
228
+ Assembly [ ] ass = AppDomain . CurrentDomain . GetAssemblies ( ) ;
229
+ foreach ( Assembly a in ass )
230
+ {
231
+ result = a . GetType ( classFullName , false , false ) ;
232
+ if ( result != null )
233
+ break ; //<<<<<================
234
+ }
235
+ }
236
+ }
237
+
238
+ return result ;
239
+ }
240
+
241
+ public static System . Type TypeFromAssembly ( string type , string assembly , bool throwIfError )
226
242
{
227
243
return TypeFromAssembly ( new AssemblyQualifiedTypeName ( type , assembly ) , throwIfError ) ;
228
244
}
0 commit comments