Ejemplo n.º 1
0
    public static AssemblyModel IsolatedShadowClone(this AssemblyModel assembly)
    {
        var referencedAssemblies = new HashSet <string>();

        foreach (var item in assembly.References)
        {
            item.AppendReferencedAssemblyNames(referencedAssemblies);
        }

        var limitedReferencesProvider = referencedAssemblies.Select(x => assembly.ReferenceProvider[x]).ToDictionary(x => x.AssemblyFullName, x => x.ShadowClone());

        foreach (var item in limitedReferencesProvider)
        {
            item.Value.LoadedAssembly = item.Value.LoadedAssembly.ShadowClone(limitedReferencesProvider);
        }

        var clone = assembly.ShadowClone(limitedReferencesProvider);

        clone.ParentLinkNames.Clear();

        limitedReferencesProvider.CleanNotExistingParentLink(clone.FullName);

        return(clone);
    }