public override sealed Type ResolveType(Assembly containingAssemblyIfAny, GetTypeOptions getTypeOptions) { containingAssemblyIfAny = getTypeOptions.CoreResolveAssembly(_assemblyName); if (containingAssemblyIfAny == null) return null; return _nonQualifiedTypeName.ResolveType(containingAssemblyIfAny, getTypeOptions); }
// // Retrieves a type by name. Helper to implement Type.GetType(); // public Type GetType(String typeName, Func<AssemblyName, Assembly> assemblyResolver, Func<Assembly, string, bool, Type> typeResolver, bool throwOnError, bool ignoreCase, IList<string> defaultAssemblyNames) { if (typeName == null) throw new ArgumentNullException(); if (typeName.Length == 0) { if (throwOnError) throw new TypeLoadException(SR.Arg_TypeLoadNullStr); else return null; } TypeName parsedName = TypeParser.ParseAssemblyQualifiedTypeName(typeName, throwOnError: throwOnError); if (parsedName == null) return null; CoreAssemblyResolver coreAssemblyResolver = CreateCoreAssemblyResolver(assemblyResolver); CoreTypeResolver coreTypeResolver = CreateCoreTypeResolver(typeResolver, defaultAssemblyNames, throwOnError: throwOnError, ignoreCase: ignoreCase); GetTypeOptions getTypeOptions = new GetTypeOptions(coreAssemblyResolver, coreTypeResolver, throwOnError: throwOnError, ignoreCase: ignoreCase); return parsedName.ResolveType(null, getTypeOptions); }
/// <summary> /// Helper for the Type.GetType() family of apis. "containingAssemblyIsAny" is the assembly to search for (as determined /// by a qualifying assembly string in the original type string passed to Type.GetType(). If null, it means the type stream /// didn't specify an assembly name. How to respond to that is up to the type resolver delegate in getTypeOptions - this class /// is just a middleman. /// </summary> public abstract Type ResolveType(Assembly containingAssemblyIfAny, GetTypeOptions getTypeOptions);
public override sealed Type ResolveType(Assembly containingAssemblyIfAny, GetTypeOptions getTypeOptions) { return ElementTypeName.ResolveType(containingAssemblyIfAny, getTypeOptions)?.MakePointerType(); }
public override sealed Type ResolveType(Assembly containingAssemblyIfAny, GetTypeOptions getTypeOptions) { Type declaringType = _declaringType.ResolveType(containingAssemblyIfAny, getTypeOptions); if (declaringType == null) return null; // Desktop compat note: If there is more than one nested type that matches the name in a case-blind match, // we might not return the same one that the desktop returns. The actual selection method is influenced both by the type's // placement in the IL and the implementation details of the CLR's internal hashtables so it would be very // hard to replicate here. // // Desktop compat note #2: Case-insensitive lookups: If we don't find a match, we do *not* go back and search // other declaring types that might match the case-insensitive search and contain the nested type being sought. // Though this is somewhat unsatisfactory, the desktop CLR has the same limitation. // Don't change these flags - we may be talking to a third party type here and we need to invoke it the way CoreClr does. BindingFlags bf = BindingFlags.Public | BindingFlags.NonPublic; if (getTypeOptions.IgnoreCase) bf |= BindingFlags.IgnoreCase; Type nestedType = declaringType.GetNestedType(_nestedTypeName, bf); if (nestedType == null && getTypeOptions.ThrowOnError) throw Helpers.CreateTypeLoadException(ToString(), containingAssemblyIfAny); return nestedType; }
public override sealed Type ResolveType(Assembly containingAssemblyIfAny, GetTypeOptions getTypeOptions) { return getTypeOptions.CoreResolveType(containingAssemblyIfAny, _fullName); }
public override sealed Type ResolveType(Assembly containingAssemblyIfAny, GetTypeOptions getTypeOptions) { Type genericTypeDefinition = _genericTypeDefinition.ResolveType(containingAssemblyIfAny, getTypeOptions); if (genericTypeDefinition == null) return null; int numGenericArguments = _genericTypeArguments.Count; Type[] genericArgumentTypes = new Type[numGenericArguments]; for (int i = 0; i < numGenericArguments; i++) { // Do not pass containingAssemblyIfAny down to ResolveType for the generic type arguments. if ((genericArgumentTypes[i] = _genericTypeArguments[i].ResolveType(null, getTypeOptions)) == null) return null; } return genericTypeDefinition.MakeGenericType(genericArgumentTypes); }