示例#1
0
            internal AssemblyInfoToLoadedTypes(TypeFilter typeFilter, AssemblyLoadInfo loadInfo)
            {
                ErrorUtilities.VerifyThrowArgumentNull(typeFilter, "typefilter");
                ErrorUtilities.VerifyThrowArgumentNull(loadInfo, nameof(loadInfo));

                _isDesiredType        = typeFilter;
                _assemblyLoadInfo     = loadInfo;
                _typeNameToType       = new Concurrent.ConcurrentDictionary <string, Type>(StringComparer.OrdinalIgnoreCase);
                _publicTypeNameToType = new Dictionary <string, Type>(StringComparer.OrdinalIgnoreCase);
            }
示例#2
0
        private LoadedType GetLoadedType(Concurrent.ConcurrentDictionary <TypeFilter, Concurrent.ConcurrentDictionary <AssemblyLoadInfo, AssemblyInfoToLoadedTypes> > cache, string typeName, AssemblyLoadInfo assembly)
        {
            // A given type filter have been used on a number of assemblies, Based on the type filter we will get another dictionary which
            // will map a specific AssemblyLoadInfo to a AssemblyInfoToLoadedTypes class which knows how to find a typeName in a given assembly.
            Concurrent.ConcurrentDictionary <AssemblyLoadInfo, AssemblyInfoToLoadedTypes> loadInfoToType =
                cache.GetOrAdd(_isDesiredType, (_) => new Concurrent.ConcurrentDictionary <AssemblyLoadInfo, AssemblyInfoToLoadedTypes>());

            // Get an object which is able to take a typename and determine if it is in the assembly pointed to by the AssemblyInfo.
            AssemblyInfoToLoadedTypes typeNameToType =
                loadInfoToType.GetOrAdd(assembly, (_) => new AssemblyInfoToLoadedTypes(_isDesiredType, _));

            return(typeNameToType.GetLoadedTypeByTypeName(typeName));
        }