/// <summary> /// 加载dll的所有类 /// </summary>[] public void Build(string[] assemblyPaths = null) { assemblyPaths = assemblyPaths ?? AssemblyPath.ToArray(); var dicList = new List <string>(); foreach (var item in AssemblyDic) { dicList.Add(item.Key); } if (assemblyPaths == null || assemblyPaths.Length == 0) { assemblyPaths = dicList.ToArray(); } foreach (var assemblyPath in assemblyPaths) { byte[] bt = File.ReadAllBytes(assemblyPath); var assembly = Assembly.Load(bt); var types = assembly.GetTypes(); foreach (var objType in types) { var interfaces = objType.GetInterfaces(); foreach (var item in interfaces) { HotUpdateServiceDescriptor model = new HotUpdateServiceDescriptor(); model.ImplementationType = objType; model.ServiceType = item; model.AssemblyObj = assembly; model.AssemblyPath = assemblyPath; CheckExistAndInsert(model); } } } }
private void CheckExistAndInsert(HotUpdateServiceDescriptor model) { var old = HotUpdateList.FirstOrDefault(c => c.AssemblyObj.GetName().Name == model.AssemblyObj.GetName().Name&& c.ServiceType.Name == model.ServiceType.Name); if (old != null) { HotUpdateList.Remove(old); HotUpdateList.Add(model); //old = ; } else { HotUpdateList.Add(model); } }