private static void ReportReflectionLoad( AssemblyName assmName, Assembly assembly, Assembly requesting) { if (PluginsFactory <T> .log.get_IsWarnEnabled() && !StringComparer.Ordinal.Equals(assmName.FullName, assembly.FullName)) { PluginsFactory <T> .log.WarnFormat("inspecting [{0}] as [{1}]{2}{3}", new object[4] { (object)assmName, (object)assembly, (object)PluginsFactory <T> .FormatCodeBase(assembly), (object)PluginsFactory <T> .FormatRequest(requesting) }); } else { if (!PluginsFactory <T> .log.get_IsDebugEnabled()) { return; } PluginsFactory <T> .log.DebugFormat("inspecting [{0}] as [{1}]{2}{3}", new object[4] { (object)assmName, (object)assembly, (object)PluginsFactory <T> .FormatCodeBase(assembly), (object)PluginsFactory <T> .FormatRequest(requesting) }); } }
private static string FormatRequest(Assembly requesting) { if (!(requesting != (Assembly)null)) { return(string.Empty); } return(" requested by [" + (object)requesting + "]" + PluginsFactory <T> .FormatCodeBase(requesting)); }
public int CompareTo(PluginsFactory <T> .AssemblyVersionInfo other) { int num = this.AssemblyName.Version.CompareTo(other.AssemblyName.Version); if (num == 0) { num = this.FileVersion.CompareTo(other.FileVersion); } return(num); }
// Token: 0x060008F7 RID: 2295 RVA: 0x00040988 File Offset: 0x0003EB88 private static string FormatCodeBase(Assembly assembly) { string codeBase = PluginsFactory <T> .GetCodeBase(assembly); if (!string.IsNullOrWhiteSpace(codeBase)) { return(" at '" + codeBase + '\''); } return(codeBase); }
// Token: 0x060008F6 RID: 2294 RVA: 0x0004072C File Offset: 0x0003E92C private void Process(IEnumerable <string> files) { IEnumerable <PluginsFactory <T> .AssemblyVersionInfo> enumerable = (from name in files.Select(new Func <string, PluginsFactory <T> .AssemblyVersionInfo>(PluginsFactory <T> .AssemblyVersionInfo.Create)) orderby name descending select name).Distinct <PluginsFactory <T> .AssemblyVersionInfo>(); string basePath = Path.GetFullPath(AppDomain.CurrentDomain.BaseDirectory); Dictionary <string, FileInfo> dictionary = (from plugin in (from n in new DirectoryXmlFilePluginsProvider(OrionConfiguration.InstallPath).ReadAreas() where n.Name.Equals("BackgroundInventory") select n).SelectMany((PluginsArea area) => area.Plugins) select new FileInfo(Path.Combine(basePath, plugin.AssemblyPath)) into info where info.Exists select info).ToDictionary((FileInfo info) => info.Name, StringComparer.OrdinalIgnoreCase); List <PluginsFactory <T> .AssemblyVersionInfo> list = new List <PluginsFactory <T> .AssemblyVersionInfo>(); foreach (PluginsFactory <T> .AssemblyVersionInfo assemblyVersionInfo in enumerable) { try { FileInfo fileInfo; if (dictionary.TryGetValue(assemblyVersionInfo.FileInfo.Name, out fileInfo)) { assemblyVersionInfo = new PluginsFactory <T> .AssemblyVersionInfo(fileInfo); } list.Add(assemblyVersionInfo); } catch (Exception ex) { PluginsFactory <T> .log.ErrorFormat("Failed to process {0} @ '{1}'. {2}", assemblyVersionInfo.AssemblyName, assemblyVersionInfo.FileInfo, ex); } } ResolveEventHandler value = new ResolveEventHandler(PluginsFactory <T> .CurrentDomain_ReflectionOnlyAssemblyResolve); AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve += value; try { foreach (PluginsFactory <T> .AssemblyVersionInfo assemblyVersionInfo2 in list) { try { this.ProcessAssembly(assemblyVersionInfo2.FileInfo.FullName); } catch (Exception ex2) { PluginsFactory <T> .log.WarnFormat("Failed to initialize {0} @ '{1}'. {2}", assemblyVersionInfo2.AssemblyName, assemblyVersionInfo2.FileInfo, ex2); } } } finally { AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve -= value; } }
// Token: 0x060008F9 RID: 2297 RVA: 0x00040A20 File Offset: 0x0003EC20 private static string FormatRequest(Assembly requesting) { if (!(requesting != null)) { return(string.Empty); } return(string.Concat(new object[] { " requested by [", requesting, "]", PluginsFactory <T> .FormatCodeBase(requesting) })); }
private void Process(IEnumerable <string> files) { IEnumerable <PluginsFactory <T> .AssemblyVersionInfo> assemblyVersionInfos = files.Select <string, PluginsFactory <T> .AssemblyVersionInfo>(new Func <string, PluginsFactory <T> .AssemblyVersionInfo>(PluginsFactory <T> .AssemblyVersionInfo.Create)).OrderByDescending <PluginsFactory <T> .AssemblyVersionInfo, PluginsFactory <T> .AssemblyVersionInfo>((Func <PluginsFactory <T> .AssemblyVersionInfo, PluginsFactory <T> .AssemblyVersionInfo>)(name => name)).Distinct <PluginsFactory <T> .AssemblyVersionInfo>(); string basePath = Path.GetFullPath(AppDomain.CurrentDomain.BaseDirectory); Dictionary <string, FileInfo> dictionary = new DirectoryXmlFilePluginsProvider(OrionConfiguration.get_InstallPath()).ReadAreas().Where <PluginsArea>((Func <PluginsArea, bool>)(n => n.get_Name().Equals("BackgroundInventory"))).SelectMany <PluginsArea, Plugin>((Func <PluginsArea, IEnumerable <Plugin> >)(area => (IEnumerable <Plugin>)area.get_Plugins())).Select <Plugin, FileInfo>((Func <Plugin, FileInfo>)(plugin => new FileInfo(Path.Combine(basePath, plugin.get_AssemblyPath())))).Where <FileInfo>((Func <FileInfo, bool>)(info => info.Exists)).ToDictionary <FileInfo, string>((Func <FileInfo, string>)(info => info.Name), (IEqualityComparer <string>)StringComparer.OrdinalIgnoreCase); List <PluginsFactory <T> .AssemblyVersionInfo> assemblyVersionInfoList = new List <PluginsFactory <T> .AssemblyVersionInfo>(); foreach (PluginsFactory <T> .AssemblyVersionInfo assemblyVersionInfo1 in assemblyVersionInfos) { PluginsFactory <T> .AssemblyVersionInfo assemblyVersionInfo2 = assemblyVersionInfo1; try { FileInfo fileInfo; if (dictionary.TryGetValue(assemblyVersionInfo2.FileInfo.Name, out fileInfo)) { assemblyVersionInfo2 = new PluginsFactory <T> .AssemblyVersionInfo(fileInfo); } assemblyVersionInfoList.Add(assemblyVersionInfo2); } catch (Exception ex) { PluginsFactory <T> .log.ErrorFormat("Failed to process {0} @ '{1}'. {2}", (object)assemblyVersionInfo2.AssemblyName, (object)assemblyVersionInfo2.FileInfo, (object)ex); } } ResolveEventHandler resolveEventHandler = new ResolveEventHandler(PluginsFactory <T> .CurrentDomain_ReflectionOnlyAssemblyResolve); AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve += resolveEventHandler; try { foreach (PluginsFactory <T> .AssemblyVersionInfo assemblyVersionInfo in assemblyVersionInfoList) { try { this.ProcessAssembly(assemblyVersionInfo.FileInfo.FullName); } catch (Exception ex) { PluginsFactory <T> .log.WarnFormat("Failed to initialize {0} @ '{1}'. {2}", (object)assemblyVersionInfo.AssemblyName, (object)assemblyVersionInfo.FileInfo, (object)ex); } } } finally { AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve -= resolveEventHandler; } }
// Token: 0x060008EA RID: 2282 RVA: 0x000400C8 File Offset: 0x0003E2C8 public InventoryManager(int engineID) { this.engineID = engineID; Dictionary <string, object> dictionary = new Dictionary <string, object>(StringComparer.OrdinalIgnoreCase); IEnumerable <IBackgroundInventoryPlugin> plugins = new PluginsFactory <IBackgroundInventoryPlugin>().Plugins; if (plugins != null) { foreach (IBackgroundInventoryPlugin backgroundInventoryPlugin in plugins) { if (dictionary.ContainsKey(backgroundInventoryPlugin.FlagName)) { InventoryManager.log.ErrorFormat("Plugin with FlagName {0} already loaded", backgroundInventoryPlugin.FlagName); } dictionary.Add(backgroundInventoryPlugin.FlagName, backgroundInventoryPlugin); } } IEnumerable <IBackgroundInventoryPlugin2> plugins2 = new PluginsFactory <IBackgroundInventoryPlugin2>().Plugins; if (plugins2 != null) { foreach (IBackgroundInventoryPlugin2 backgroundInventoryPlugin2 in plugins2) { if (dictionary.ContainsKey(backgroundInventoryPlugin2.FlagName)) { InventoryManager.log.ErrorFormat("Plugin with FlagName {0} already loaded", backgroundInventoryPlugin2.FlagName); } dictionary.Add(backgroundInventoryPlugin2.FlagName, backgroundInventoryPlugin2); } } if (plugins == null && plugins2 == null) { InventoryManager.log.ErrorFormat("No Inventory plugins found", Array.Empty <object>()); } this.backgroundInventory = new BackgroundInventory(BusinessLayerSettings.Instance.BackgroundInventoryParallelTasksCount, dictionary); }
private static string FormatCodeBase(Assembly assembly) { string codeBase = PluginsFactory <T> .GetCodeBase(assembly); return(!string.IsNullOrWhiteSpace(codeBase) ? " at '" + codeBase + (object)'\'' : codeBase); }
public bool Equals(PluginsFactory <T> .AssemblyVersionInfo other) { return(StringComparer.OrdinalIgnoreCase.Equals(this.AssemblyName.Name, other.AssemblyName.Name)); }
private void ProcessAssembly(string fileName) { PluginsFactory <T> .log.DebugFormat("Loading plugins from {0}", (object)fileName); AssemblyName assemblyName = AssemblyName.GetAssemblyName(fileName); Assembly assembly1 = (Assembly)null; foreach (Assembly assembly2 in AppDomain.CurrentDomain.ReflectionOnlyGetAssemblies()) { if (AssemblyName.ReferenceMatchesDefinition(assembly2.GetName(), assemblyName)) { assembly1 = assembly2; try { string fullPath = Path.GetFullPath(new Uri(assembly1.CodeBase).LocalPath); if (!StringComparer.OrdinalIgnoreCase.Equals(fileName, fullPath)) { PluginsFactory <T> .log.WarnFormat("inspecting [{0}] at '{1}' as [{2}] at '{3}'", new object[4] { (object)assemblyName, (object)fileName, (object)assembly1, (object)fullPath }); break; } break; } catch (Exception ex) { PluginsFactory <T> .log.WarnFormat("inspecting [{0}] at '{1}' as [{2}]. {3}", new object[4] { (object)assemblyName, (object)fileName, (object)assembly1, (object)ex }); break; } } } if (assembly1 == (Assembly)null) { assembly1 = Assembly.ReflectionOnlyLoadFrom(fileName); } List <Type> derivedTypes = PluginsFactory <T> .FindDerivedTypes <T>(assembly1); if (derivedTypes.Count != 0) { derivedTypes = PluginsFactory <T> .FindDerivedTypes <T>(Assembly.LoadFrom(fileName)); } foreach (Type type in derivedTypes) { PluginsFactory <T> .log.DebugFormat("Creating plugin for {0}", (object)type); T instance = (T)Activator.CreateInstance(type); this.Plugins.Add(instance); string empty = string.Empty; PropertyInfo property = instance.GetType().GetProperty("FlagName"); if (property != (PropertyInfo)null) { empty = (string)property.GetValue((object)instance, (object[])null); } if (PluginsFactory <T> .log.get_IsInfoEnabled()) { PluginsFactory <T> .log.InfoFormat("Loaded plugin {0} for {1} from {2}", (object)type, (object)empty, (object)fileName); } } }
private static Assembly CurrentDomain_ReflectionOnlyAssemblyResolve( object sender, ResolveEventArgs args) { AssemblyName assemblyName1 = new AssemblyName(args.Name); Assembly requestingAssembly = args.RequestingAssembly; List <Exception> exceptionList = new List <Exception>(); try { Assembly assembly = Assembly.ReflectionOnlyLoad(args.Name); PluginsFactory <T> .ReportReflectionLoad(assemblyName1, assembly, requestingAssembly); return(assembly); } catch (Exception ex) { exceptionList.Add(ex); } foreach (Assembly assembly in AppDomain.CurrentDomain.ReflectionOnlyGetAssemblies()) { if (AssemblyName.ReferenceMatchesDefinition(assembly.GetName(), assemblyName1)) { PluginsFactory <T> .ReportReflectionLoad(assemblyName1, assembly, requestingAssembly); return(assembly); } } if (requestingAssembly != (Assembly)null) { try { Uri uri = new Uri(requestingAssembly.CodeBase); if (uri.IsAbsoluteUri) { string str = Path.Combine(Path.GetDirectoryName(uri.LocalPath) ?? string.Empty, assemblyName1.Name + ".dll"); if (File.Exists(str)) { AssemblyName assemblyName2 = AssemblyName.GetAssemblyName(str); if (AssemblyName.ReferenceMatchesDefinition(assemblyName1, assemblyName2)) { Assembly assembly = Assembly.ReflectionOnlyLoadFrom(str); PluginsFactory <T> .ReportReflectionLoad(assemblyName1, assembly, requestingAssembly); return(assembly); } } } } catch (Exception ex) { exceptionList.Add(ex); } } try { foreach (Assembly assembly1 in AppDomain.CurrentDomain.GetAssemblies()) { AssemblyName name = assembly1.GetName(); if (AssemblyName.ReferenceMatchesDefinition(name, assemblyName1)) { Uri uri = new Uri(name.CodeBase); if (uri.IsAbsoluteUri) { Assembly assembly2 = Assembly.ReflectionOnlyLoadFrom(uri.LocalPath); PluginsFactory <T> .ReportReflectionLoad(assemblyName1, assembly2, requestingAssembly); return(assembly2); } } } } catch (Exception ex) { exceptionList.Add(ex); } if (!PluginsFactory <T> .log.get_IsErrorEnabled()) { return((Assembly)null); } AggregateException aggregateException = new AggregateException(new StringBuilder("inspecting [").Append(args.Name).Append(']').Append(PluginsFactory <T> .FormatRequest(requestingAssembly)).Append('.').ToString(), (IEnumerable <Exception>)exceptionList); PluginsFactory <T> .log.WarnFormat("{0}", (object)aggregateException); return((Assembly)null); }
// Token: 0x060008FC RID: 2300 RVA: 0x00040D1C File Offset: 0x0003EF1C private void ProcessAssembly(string fileName) { PluginsFactory <T> .log.DebugFormat("Loading plugins from {0}", fileName); AssemblyName assemblyName = AssemblyName.GetAssemblyName(fileName); Assembly assembly = null; foreach (Assembly assembly2 in AppDomain.CurrentDomain.ReflectionOnlyGetAssemblies()) { if (AssemblyName.ReferenceMatchesDefinition(assembly2.GetName(), assemblyName)) { assembly = assembly2; try { string fullPath = Path.GetFullPath(new Uri(assembly.CodeBase).LocalPath); if (!StringComparer.OrdinalIgnoreCase.Equals(fileName, fullPath)) { PluginsFactory <T> .log.WarnFormat("inspecting [{0}] at '{1}' as [{2}] at '{3}'", new object[] { assemblyName, fileName, assembly, fullPath }); } break; } catch (Exception ex) { PluginsFactory <T> .log.WarnFormat("inspecting [{0}] at '{1}' as [{2}]. {3}", new object[] { assemblyName, fileName, assembly, ex }); break; } } } if (assembly == null) { assembly = Assembly.ReflectionOnlyLoadFrom(fileName); } List <Type> list = PluginsFactory <T> .FindDerivedTypes <T>(assembly); if (list.Count != 0) { list = PluginsFactory <T> .FindDerivedTypes <T>(Assembly.LoadFrom(fileName)); } foreach (Type type in list) { PluginsFactory <T> .log.DebugFormat("Creating plugin for {0}", type); T t = (T)((object)Activator.CreateInstance(type)); this.Plugins.Add(t); string text = string.Empty; PropertyInfo property = t.GetType().GetProperty("FlagName"); if (property != null) { text = (string)property.GetValue(t, null); } if (PluginsFactory <T> .log.IsInfoEnabled) { PluginsFactory <T> .log.InfoFormat("Loaded plugin {0} for {1} from {2}", type, text, fileName); } } }
// Token: 0x060008FB RID: 2299 RVA: 0x00040AF8 File Offset: 0x0003ECF8 private static Assembly CurrentDomain_ReflectionOnlyAssemblyResolve(object sender, ResolveEventArgs args) { AssemblyName assemblyName = new AssemblyName(args.Name); Assembly requestingAssembly = args.RequestingAssembly; List <Exception> list = new List <Exception>(); try { Assembly assembly = Assembly.ReflectionOnlyLoad(args.Name); PluginsFactory <T> .ReportReflectionLoad(assemblyName, assembly, requestingAssembly); return(assembly); } catch (Exception item) { list.Add(item); } foreach (Assembly assembly2 in AppDomain.CurrentDomain.ReflectionOnlyGetAssemblies()) { if (AssemblyName.ReferenceMatchesDefinition(assembly2.GetName(), assemblyName)) { PluginsFactory <T> .ReportReflectionLoad(assemblyName, assembly2, requestingAssembly); return(assembly2); } } if (requestingAssembly != null) { try { Uri uri = new Uri(requestingAssembly.CodeBase); if (uri.IsAbsoluteUri) { string text = Path.Combine(Path.GetDirectoryName(uri.LocalPath) ?? string.Empty, assemblyName.Name + ".dll"); if (File.Exists(text)) { AssemblyName assemblyName2 = AssemblyName.GetAssemblyName(text); if (AssemblyName.ReferenceMatchesDefinition(assemblyName, assemblyName2)) { Assembly assembly3 = Assembly.ReflectionOnlyLoadFrom(text); PluginsFactory <T> .ReportReflectionLoad(assemblyName, assembly3, requestingAssembly); return(assembly3); } } } } catch (Exception item2) { list.Add(item2); } } try { Assembly[] array = AppDomain.CurrentDomain.GetAssemblies(); for (int i = 0; i < array.Length; i++) { AssemblyName name = array[i].GetName(); if (AssemblyName.ReferenceMatchesDefinition(name, assemblyName)) { Uri uri2 = new Uri(name.CodeBase); if (uri2.IsAbsoluteUri) { Assembly assembly4 = Assembly.ReflectionOnlyLoadFrom(uri2.LocalPath); PluginsFactory <T> .ReportReflectionLoad(assemblyName, assembly4, requestingAssembly); return(assembly4); } } } } catch (Exception item3) { list.Add(item3); } if (!PluginsFactory <T> .log.IsErrorEnabled) { return(null); } AggregateException ex = new AggregateException(new StringBuilder("inspecting [").Append(args.Name).Append(']').Append(PluginsFactory <T> .FormatRequest(requestingAssembly)).Append('.').ToString(), list); PluginsFactory <T> .log.WarnFormat("{0}", ex); return(null); }