示例#1
0
        internal static RuntimeAssembly[] OnReflectionOnlyNamespaceResolveEvent(AppDomain appDomain, RuntimeAssembly assembly, string namespaceName)
        {
            EventHandler <NamespaceResolveEventArgs> eventHandler = ReflectionOnlyNamespaceResolve;

            if (eventHandler != null)
            {
                Delegate[] ds  = eventHandler.GetInvocationList();
                int        len = ds.Length;
                for (int i = 0; i < len; i++)
                {
                    NamespaceResolveEventArgs eventArgs = new NamespaceResolveEventArgs(namespaceName, assembly);

                    ((EventHandler <NamespaceResolveEventArgs>)ds[i])(appDomain, eventArgs);

                    Collection <Assembly> assembliesCollection = eventArgs.ResolvedAssemblies;
                    if (assembliesCollection.Count > 0)
                    {
                        RuntimeAssembly[] retAssemblies = new RuntimeAssembly[assembliesCollection.Count];
                        int retIndex = 0;
                        foreach (Assembly asm in assembliesCollection)
                        {
                            retAssemblies[retIndex] = AppDomain.GetRuntimeAssembly(asm);
                            retIndex++;
                        }
                        return(retAssemblies);
                    }
                }
            }

            return(null);
        }
 internal static RuntimeAssembly[] OnReflectionOnlyNamespaceResolveEvent(AppDomain appDomain, RuntimeAssembly assembly, string namespaceName)
 {
     EventHandler<NamespaceResolveEventArgs> eventHandler = ReflectionOnlyNamespaceResolve;
     if (eventHandler != null)
     {
         Delegate[] ds = eventHandler.GetInvocationList();
         int len = ds.Length;
         for (int i = 0; i < len; i++)
         {
             NamespaceResolveEventArgs eventArgs = new NamespaceResolveEventArgs(namespaceName, assembly);
             
             ((EventHandler<NamespaceResolveEventArgs>)ds[i])(appDomain, eventArgs);
             
             Collection<Assembly> assembliesCollection = eventArgs.ResolvedAssemblies;
             if (assembliesCollection.Count > 0)
             {
                 RuntimeAssembly[] retAssemblies = new RuntimeAssembly[assembliesCollection.Count];
                 int retIndex = 0;
                 foreach (Assembly asm in assembliesCollection)
                 {
                     retAssemblies[retIndex] = AppDomain.GetRuntimeAssembly(asm);
                     retIndex++;
                 }
                 return retAssemblies;
             }
         }
     }
     
     return null;
 }
示例#3
0
        // Token: 0x060063C5 RID: 25541 RVA: 0x00152F18 File Offset: 0x00151118
        internal static RuntimeAssembly[] OnReflectionOnlyNamespaceResolveEvent(AppDomain appDomain, RuntimeAssembly assembly, string namespaceName)
        {
            EventHandler <NamespaceResolveEventArgs> reflectionOnlyNamespaceResolve = WindowsRuntimeMetadata.ReflectionOnlyNamespaceResolve;

            if (reflectionOnlyNamespaceResolve != null)
            {
                Delegate[] invocationList = reflectionOnlyNamespaceResolve.GetInvocationList();
                int        num            = invocationList.Length;
                for (int i = 0; i < num; i++)
                {
                    NamespaceResolveEventArgs namespaceResolveEventArgs = new NamespaceResolveEventArgs(namespaceName, assembly);
                    ((EventHandler <NamespaceResolveEventArgs>)invocationList[i])(appDomain, namespaceResolveEventArgs);
                    Collection <Assembly> resolvedAssemblies = namespaceResolveEventArgs.ResolvedAssemblies;
                    if (resolvedAssemblies.Count > 0)
                    {
                        RuntimeAssembly[] array = new RuntimeAssembly[resolvedAssemblies.Count];
                        int num2 = 0;
                        foreach (Assembly asm in resolvedAssemblies)
                        {
                            array[num2] = AppDomain.GetRuntimeAssembly(asm);
                            num2++;
                        }
                        return(array);
                    }
                }
            }
            return(null);
        }
        internal static RuntimeAssembly[] OnReflectionOnlyNamespaceResolveEvent(AppDomain appDomain, RuntimeAssembly assembly, string namespaceName)
        {
            // ISSUE: reference to a compiler-generated field
            EventHandler <NamespaceResolveEventArgs> eventHandler = WindowsRuntimeMetadata.ReflectionOnlyNamespaceResolve;

            if (eventHandler != null)
            {
                Delegate[] invocationList = eventHandler.GetInvocationList();
                int        length         = invocationList.Length;
                for (int index1 = 0; index1 < length; ++index1)
                {
                    NamespaceResolveEventArgs e = new NamespaceResolveEventArgs(namespaceName, (Assembly)assembly);
                    ((EventHandler <NamespaceResolveEventArgs>)invocationList[index1])((object)appDomain, e);
                    Collection <Assembly> resolvedAssemblies = e.ResolvedAssemblies;
                    if (resolvedAssemblies.Count > 0)
                    {
                        RuntimeAssembly[] runtimeAssemblyArray = new RuntimeAssembly[resolvedAssemblies.Count];
                        int index2 = 0;
                        foreach (Assembly asm in resolvedAssemblies)
                        {
                            runtimeAssemblyArray[index2] = AppDomain.GetRuntimeAssembly(asm);
                            ++index2;
                        }
                        return(runtimeAssemblyArray);
                    }
                }
            }
            return((RuntimeAssembly[])null);
        }
示例#5
0
 void ReflectionOnlyNamespaceResolve(object sender, NamespaceResolveEventArgs e)
 {
     foreach (var assembly in referenceAssemblies.Concat(inputAssemblies))
     {
         if (assembly.DefinedTypes.Any(type => type.Namespace == e.NamespaceName))
         {
             e.ResolvedAssemblies.Add(assembly);
         }
     }
 }
        private void OnReflectionOnlyNamespaceResolve( object sender, NamespaceResolveEventArgs e )
        {
            // use the winrt apis to resolve the assembly location from the specified namespace
            var paths = WindowsRuntimeMetadata.ResolveNamespace( e.NamespaceName, Enumerable.Empty<string>() ).ToArray();
            var path = paths.FirstOrDefault();

            // if the assembly is found, load it in the reflection-only context
            if ( string.IsNullOrEmpty( path ) )
            {
                Debug.WriteLine( "Failed to load assembly '{0}' into a reflection-only context.", new[] { e.NamespaceName } );
            }
            else
            {
                Debug.WriteLine( "Attempting to load assembly '{0}' into a reflection-only context from {1}.", new[] { e.NamespaceName, path } );
                e.ResolvedAssemblies.Add( Assembly.ReflectionOnlyLoadFrom( path ) );
            }
        }