/// <summary> /// Returns true if <paramref name="type"/> is a generic interface type implemented by arrays. /// </summary> public bool IsGenericArrayInterfaceType(TypeDesc type) { // Hardcode the fact that all generic interfaces on array types have arity 1 if (!type.IsInterface || type.Instantiation.Length != 1) { return(false); } if (_arrayOfTInterfaces == null) { DefType[] implementedInterfaces = SystemModule.GetKnownType("System", "Array`1").ExplicitlyImplementedInterfaces; TypeDesc[] interfaceDefinitions = new TypeDesc[implementedInterfaces.Length]; for (int i = 0; i < interfaceDefinitions.Length; i++) { interfaceDefinitions[i] = implementedInterfaces[i].GetTypeDefinition(); } Interlocked.CompareExchange(ref _arrayOfTInterfaces, interfaceDefinitions, null); } TypeDesc interfaceDefinition = type.GetTypeDefinition(); foreach (var arrayInterfaceDefinition in _arrayOfTInterfaces) { if (interfaceDefinition == arrayInterfaceDefinition) { return(true); } } return(false); }
protected override RuntimeInterfacesAlgorithm GetRuntimeInterfacesAlgorithmForNonPointerArrayType(ArrayType type) { if (_arrayOfTRuntimeInterfacesAlgorithm == null) { _arrayOfTRuntimeInterfacesAlgorithm = new ArrayOfTRuntimeInterfacesAlgorithm(SystemModule.GetKnownType("System", "Array`1")); } return(_arrayOfTRuntimeInterfacesAlgorithm); }