コード例 #1
0
        private void GetReferencesFromFile(Stack <AssemblyName> newAssemblies, HashSet <AssemblyName> visitedAssemblies, string currentFile)
        {
            var assemblyObj = ResolvedAssemblyObject.CreateFrom(currentFile);

            AssemblyName[] refs = assemblyObj.GetAssemblyReferences();

            foreach (var newFile in refs)
            {
                ResolvedAssemblyResultEnum resolveResult = TryResolveAssembly(newFile, out AssemblyName an);

                _assemblyLoadedDelegate?.Invoke(currentFile,
                                                resolveResult == ResolvedAssemblyResultEnum.NoMatch ? newFile : an,
                                                resolveResult);

                // If there is no match, move on to the next reference.
                if (resolveResult == ResolvedAssemblyResultEnum.NoMatch)
                {
                    continue;
                }

                if (!new AssemblyNameComparer().Equals(newFile, an))
                {
                    // we loaded a different assembly than what the reference was saying.
                    _assemblyVersionMismatchDelegate?.Invoke(newFile, an);

                    // we overwrite the one that was loaded because the closure is based on what is referenced, not what we end up loading.
                    newFile.CodeBase = an.CodeBase;
                    an = newFile;
                }

                // if we haven't seen this already
                if (!visitedAssemblies.Contains(an))
                {
                    newAssemblies.Push(an);
                }
            }
        }
コード例 #2
0
        public static ReferencedTypeObject CreateFrom(ResolvedAssemblyObject ao, TypeReference typeRef, ResolveAssemblyDelegate resolveAssembly)
        {
            ReferencedTypeObject to = new ReferencedTypeObject(ao._fs, ao._peReader, ao._metaReader, typeRef, resolveAssembly);

            return(to);
        }
コード例 #3
0
 public static ReferencedTypeObject CreateFrom(ResolvedAssemblyObject ao, TypeReference typeRef)
 {
     return(CreateFrom(ao, typeRef, null));
 }
コード例 #4
0
        public static ExportedTypeObject CreateFrom(ResolvedAssemblyObject ao, ExportedType exportedType, ResolveAssemblyDelegate resolveAssembly)
        {
            ExportedTypeObject to = new ExportedTypeObject(ao._fs, ao._peReader, ao._metaReader, exportedType, resolveAssembly);

            return(to);
        }
コード例 #5
0
 public static ExportedTypeObject CreateFrom(ResolvedAssemblyObject ao, ExportedType exportedType)
 {
     return(CreateFrom(ao, exportedType, null));
 }
コード例 #6
0
 public static DeclaredTypeObject CreateFrom(ResolvedAssemblyObject ao, TypeDefinition typeDef)
 {
     DeclaredTypeObject to = new DeclaredTypeObject(ao._fs, ao._peReader, ao._metaReader, typeDef);
     to.Assembly = ao;
     return to;
 }