示例#1
0
        /// <summary>
        /// Loads the runtime's version of this assembly and runs it through the appropriate policy evaluator.
        /// </summary>
        /// <param name="assemblyName">The assembly name to load.</param>
        /// <param name="scriptRuntimeAssembly">The policy evaluator details.</param>
        /// <param name="runtimeAssembly">The runtime's assembly.</param>
        /// <returns>true if the policy evaluation succeeded, otherwise, false.</returns>
        private bool TryLoadRuntimeAssembly(AssemblyName assemblyName, ScriptRuntimeAssembly scriptRuntimeAssembly, out Assembly runtimeAssembly)
        {
            // If this is a private runtime assembly, return function dependency
            if (string.Equals(scriptRuntimeAssembly.ResolutionPolicy, PrivateDependencyResolutionPolicy))
            {
                runtimeAssembly = LoadCore(assemblyName);
                return(true);
            }

            // Attempt to load the runtime version of the assembly based on the unification policy evaluation result.
            if (TryLoadHostEnvironmentAssembly(assemblyName, allowPartialNameMatch: true, out runtimeAssembly))
            {
                var policyEvaluator = GetResolutionPolicyEvaluator(scriptRuntimeAssembly.ResolutionPolicy);
                return(policyEvaluator.Invoke(assemblyName, runtimeAssembly));
            }

            runtimeAssembly = null;
            return(false);
        }
示例#2
0
 private bool TryGetRuntimeAssembly(AssemblyName assemblyName, out ScriptRuntimeAssembly assembly)
 => _runtimeAssemblies.Value.TryGetValue(assemblyName.Name, out assembly);