示例#1
0
 /// <summary>
 /// 移除文件对应的引用
 /// </summary>
 /// <param name="path">文件路径,插件或者生成的DLL</param>
 public virtual void Remove(string path)
 {
     if (path != null)
     {
         if (DllAssemblies.ContainsKey(path))
         {
             var shortName = Path.GetFileNameWithoutExtension(path);
             ReferencesFromFile.Remove(shortName);
             Assembly assembly = DllAssemblies.Remove(path);
             RemoveAssemblyEvent?.Invoke(assembly);
         }
     }
 }
示例#2
0
        public bool RemoveAssembly(Assembly assembly)
        {
            if (assembly == default)
            {
                throw new NullReferenceException("Assembly is null!  This method can't be passed a null instance.");
            }



            if (AssemblyMappings.ContainsKey(assembly))
            {
                if (PathMapping.ContainsKey(assembly))
                {
                    var path = PathMapping[assembly];
                    while (!ShortReferenceMappings.TryRemove(Path.GetFileName(path), out var _))
                    {
                    }
                    ;


                    while (!OutfileMapping.TryRemove(path, out var _))
                    {
                    }
                    ;
                    while (!PathMapping.TryRemove(assembly, out var _))
                    {
                    }
                    ;
                    RemoveAssemblyEvent?.Invoke(path, assembly);
                }

                lock (ReferencesCache)
                {
                    var info = AssemblyMappings[assembly];
                    if (ReferencesCache.Contains(info.Reference.Value))
                    {
                        ReferencesCache.Remove(info.Reference);
                    }
                }
                while (!AssemblyMappings.TryRemove(assembly, out var _))
                {
                }
                ;


                return(true);
            }

            return(false);
        }
示例#3
0
 /// <summary>
 /// 移除程序集对应的引用
 /// </summary>
 /// <param name="assembly">程序集</param>
 public virtual void Remove(Assembly assembly)
 {
     if (assembly != null)
     {
         if (ReferencesFromStream.ContainsKey(assembly))
         {
             ReferencesFromStream.Remove(assembly);
             RemoveAssemblyEvent?.Invoke(assembly);
         }
         else if (assembly.Location != "" && assembly.Location != default)
         {
             Remove(assembly.Location);
         }
     }
 }
示例#4
0
 /// <summary>
 /// 移除文件对应的引用
 /// </summary>
 /// <param name="path">文件路径,插件或者生成的DLL</param>
 public virtual void Remove(string path)
 {
     if (path != null)
     {
         if (DllAssemblies.ContainsKey(path))
         {
             var shortName = Path.GetFileNameWithoutExtension(path);
             while (!ReferencesFromFile.TryRemove(shortName, out _))
             {
             }
             Assembly assembly;
             while (!DllAssemblies.TryRemove(path, out assembly))
             {
             }
             RemoveAssemblyEvent?.Invoke(assembly);
         }
     }
 }