public static Assembly[] GetLoadedAssemblies() { List <Assembly> assemblies = new List <Assembly>(); using (ChoBufferProfileEx profile = new ChoBufferProfileEx(ChoType.GetLogFileName(typeof(ChoExcludedAssembly)), String.Format("Below are the excluded assemblies..."))) { Assembly[] loadedAssemblies = null; try { loadedAssemblies = AppDomain.CurrentDomain.GetAssemblies(); } catch (System.Security.SecurityException) { // Insufficient permissions to get the list of loaded assemblies } if (loadedAssemblies != null) { // Search the loaded assemblies for the type foreach (Assembly assembly in loadedAssemblies) { DiscoverNLoadAssemblies(profile, assembly, assemblies); } } return(assemblies.ToArray()); } }
public bool Initialize(bool beforeFieldInit, object state) { //Create the default/built-in objects _logFormatters = new ChoDictionary <string, IChoLogFormatter>(DefaultLogFormatters); ChoObjConfigurable.Load <IChoLogFormatter>(ChoType.GetLogFileName(typeof(ChoLogFormatterSettings)), ChoType.GetTypes(typeof(ChoLogFormatterAttribute)), _logFormatters, LogFormatterTypes); return(false); }
public bool Initialize(bool beforeFieldInit, object state) { _logManagers = new ChoDictionary <string, IChoLogManager>(DefaultLogManagers); if (!beforeFieldInit) { ChoObjConfigurable.Load <IChoLogManager>(ChoType.GetLogFileName(typeof(ChoLogManagerSettings)), ChoType.GetTypes(typeof(ChoLogManagerAttribute)), _logManagers, LogManagerTypes); } return(false); }
public static Assembly[] GetAssemblies(string[] directories) { List <Assembly> assemblies = new List <Assembly>(); using (ChoBufferProfileEx fileProfile = new ChoBufferProfileEx(ChoType.GetLogFileName(typeof(ChoCodeBaseAssembly)), String.Format("Below are the assemblies loaded from files..."))) { foreach (string directory in directories) { if (directory == null) { continue; } foreach (string file in Directory.GetFiles(directory, "*.dll;*.exe")) //TODO: Filter needs to be configurable { if (file == null) { continue; } try { Assembly assembly = Assembly.LoadFile(file); if (assembly != null) { DiscoverNLoadAssemblies(fileProfile, assembly, assemblies); fileProfile.Info(file); } } catch (ChoFatalApplicationException) { throw; } catch (Exception ex) { fileProfile.ErrorFormat("Error [{0}]: {1}", file, ex.Message); } } } } return(assemblies.ToArray()); }