示例#1
0
 private static bool TryFindWildcardAssemblyMatch(
     AssemblyName referenceName,
     out Assembly assembly)
 {
     foreach (Assembly discoverableAssembly in DefaultAssemblyResolver.GetAllDiscoverableAssemblies())
     {
         if (AssemblyName.ReferenceMatchesDefinition(referenceName, new AssemblyName(discoverableAssembly.FullName)))
         {
             assembly = discoverableAssembly;
             return(true);
         }
     }
     assembly = (Assembly)null;
     return(false);
 }
示例#2
0
        private static IEnumerable <Assembly> GetAllDiscoverableAssemblies()
        {
            Assembly           entryAssembly = Assembly.GetEntryAssembly();
            HashSet <Assembly> source        = new HashSet <Assembly>((IEqualityComparer <Assembly>)DefaultAssemblyResolver.AssemblyComparer.Instance);

            foreach (Assembly nonSystemAssembly in DefaultAssemblyResolver.GetAlreadyLoadedNonSystemAssemblies())
            {
                source.Add(nonSystemAssembly);
            }
            AspProxy aspProxy = new AspProxy();

            if (!aspProxy.IsAspNetEnvironment())
            {
                if (entryAssembly == (Assembly)null)
                {
                    return((IEnumerable <Assembly>)source);
                }
                source.Add(entryAssembly);
                foreach (Assembly referencedAssembly in MetadataAssemblyHelper.GetNonSystemReferencedAssemblies(entryAssembly))
                {
                    source.Add(referencedAssembly);
                }
                return((IEnumerable <Assembly>)source);
            }
            if (aspProxy.HasBuildManagerType())
            {
                IEnumerable <Assembly> referencedAssemblies = aspProxy.GetBuildManagerReferencedAssemblies();
                if (referencedAssemblies != null)
                {
                    foreach (Assembly assembly in referencedAssemblies)
                    {
                        if (!MetadataAssemblyHelper.ShouldFilterAssembly(assembly))
                        {
                            source.Add(assembly);
                        }
                    }
                }
            }
            return(source.Where <Assembly>((Func <Assembly, bool>)(a => a != (Assembly)null)));
        }
示例#3
0
        internal virtual Assembly ResolveAssembly(AssemblyName referenceName)
        {
            Assembly assembly = (Assembly)null;

            foreach (Assembly nonSystemAssembly in DefaultAssemblyResolver.GetAlreadyLoadedNonSystemAssemblies())
            {
                if (AssemblyName.ReferenceMatchesDefinition(referenceName, new AssemblyName(nonSystemAssembly.FullName)))
                {
                    return(nonSystemAssembly);
                }
            }
            if (assembly == (Assembly)null)
            {
                assembly = MetadataAssemblyHelper.SafeLoadReferencedAssembly(referenceName);
                if (assembly != (Assembly)null)
                {
                    return(assembly);
                }
            }
            DefaultAssemblyResolver.TryFindWildcardAssemblyMatch(referenceName, out assembly);
            return(assembly);
        }
示例#4
0
 internal override IEnumerable <Assembly> GetWildcardAssemblies()
 {
     return(DefaultAssemblyResolver.GetAllDiscoverableAssemblies());
 }