public AppDomainAssemblyResolver( ILogProvider logProvider, IFileSystem fileSystem, IAssemblyResolver resolver, IAssemblyUtility assemblyUtility, IDictionary<string, AssemblyInfo> assemblyInfoMap = null, Func<object, ResolveEventArgs, Assembly> resolveHandler = null) { Guard.AgainstNullArgument("logProvider", logProvider); Guard.AgainstNullArgument("fileSystem", fileSystem); Guard.AgainstNullArgument("resolver", resolver); Guard.AgainstNullArgument("assemblyUtility", assemblyUtility); _assemblyInfoMap = assemblyInfoMap ?? new Dictionary<string, AssemblyInfo>(); _assemblyUtility = assemblyUtility; _logger = logProvider.ForCurrentType(); _fileSystem = fileSystem; _resolver = resolver; if (resolveHandler == null) { resolveHandler = AssemblyResolve; } AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(resolveHandler); }
public ModuleLoader(IAssemblyResolver resolver, ILog logger, Action<Assembly, AggregateCatalog> addToCatalog, Func<CompositionContainer, IEnumerable<Lazy<IModule, IModuleMetadata>>> getLazyModules, IFileSystem fileSystem, IAssemblyUtility assemblyUtility) { _resolver = resolver; _logger = logger; if (addToCatalog == null) { addToCatalog = (assembly, catalog) => { try { var assemblyCatalog = new AssemblyCatalog(assembly); catalog.Catalogs.Add(assemblyCatalog); } catch (Exception exception) { logger.DebugFormat("Module Loader exception: {0}", exception.Message); } }; } _addToCatalog = addToCatalog; if (getLazyModules == null) { getLazyModules = container => container.GetExports<IModule, IModuleMetadata>(); } _getLazyModules = getLazyModules; _fileSystem = fileSystem; _assemblyUtility = assemblyUtility; }
public AssemblyResolver( IFileSystem fileSystem, IPackageAssemblyResolver packageAssemblyResolver, IAssemblyUtility assemblyUtility, Common.Logging.ILog logger) :this(fileSystem,packageAssemblyResolver,assemblyUtility,new CommonLoggingLogProvider(logger)) { }
public AppDomainAssemblyResolver( Common.Logging.ILog logger, IFileSystem fileSystem, IAssemblyResolver resolver, IAssemblyUtility assemblyUtility, IDictionary<string, AssemblyInfo> assemblyInfoMap = null, Func<object, ResolveEventArgs, Assembly> resolveHandler = null) : this(new CommonLoggingLogProvider(logger), fileSystem, resolver, assemblyUtility, assemblyInfoMap, resolveHandler) { }
public AssemblyResolver( IFileSystem fileSystem, IPackageAssemblyResolver packageAssemblyResolver, IAssemblyUtility assemblyUtility, ILog logger) { _fileSystem = fileSystem; _packageAssemblyResolver = packageAssemblyResolver; _logger = logger; _assemblyUtility = assemblyUtility; }
/// <summary> /// Initializes a new instance of <see cref="FileSystemAssemblyProvider"/> /// </summary> /// <param name="fileSystem"></param> /// <param name="assemblyUtility"></param> public FileSystemAssemblyProvider(IFileSystem fileSystem, IAssemblyUtility assemblyUtility) { var codeBase = typeof(FileSystemAssemblyProvider).Assembly.GetName().CodeBase; var uri = new Uri(codeBase); var assemblyFileInfo = new FileInfo(uri.LocalPath); AvailableAssemblies = new ObservableCollection<AssemblyInfo>( fileSystem.GetFilesFrom(assemblyFileInfo.Directory.ToString(), "*.dll") .Concat(fileSystem.GetFilesFrom(assemblyFileInfo.Directory.ToString(), "*.exe")) .Select(fi => fi.FullName) .Select(AssemblyInfoFromFileInfo) .Where(assemblyUtility.IsAssembly)); }
public AssemblyResolver( IFileSystem fileSystem, IPackageAssemblyResolver packageAssemblyResolver, IAssemblyUtility assemblyUtility, ILog logger) { Guard.AgainstNullArgument("fileSystem", fileSystem); Guard.AgainstNullArgumentProperty("fileSystem", "PackagesFolder", fileSystem.PackagesFolder); Guard.AgainstNullArgumentProperty("fileSystem", "BinFolder", fileSystem.BinFolder); _fileSystem = fileSystem; _packageAssemblyResolver = packageAssemblyResolver; _logger = logger; _assemblyUtility = assemblyUtility; }
/// <summary> /// Initializes a new instance of <see cref="AssemblyProvider"/> /// </summary> /// <param name="assemblyProviders"><see cref="IEnumerable{ICanProvideAssemblies}">Providers</see> to provide assemblies</param> /// <param name="assemblyFilters"><see cref="IAssemblyFilters"/> to use for filtering assemblies through</param> /// <param name="assemblyUtility">An <see cref="IAssemblyUtility"/></param> /// <param name="assemblySpecifiers"><see cref="IAssemblySpecifiers"/> used for specifying what assemblies to include or not</param> /// <param name="contractToImplementorsMap"><see cref="IContractToImplementorsMap"/> for keeping track of the relationship between contracts and implementors</param> public AssemblyProvider( IEnumerable<ICanProvideAssemblies> assemblyProviders, IAssemblyFilters assemblyFilters, IAssemblyUtility assemblyUtility, IAssemblySpecifiers assemblySpecifiers, IContractToImplementorsMap contractToImplementorsMap) { _assemblyProviders = assemblyProviders; _assemblyFilters = assemblyFilters; _assemblyUtility = assemblyUtility; _assemblySpecifiers = assemblySpecifiers; _contractToImplementorsMap = contractToImplementorsMap; HookUpAssemblyAddedForProviders(); Populate(); }
/// <summary> /// Initializes a new instance of <see cref="AssemblyProvider"/> /// </summary> /// <param name="assemblyProviders"><see cref="IEnumerable{ICanProvideAssemblies}">Providers</see> to provide assemblies</param> /// <param name="assemblyFilters"><see cref="IAssemblyFilters"/> to use for filtering assemblies through</param> /// <param name="assemblyUtility">An <see cref="IAssemblyUtility"/></param> /// <param name="assemblySpecifiers"><see cref="IAssemblySpecifiers"/> used for specifying what assemblies to include or not</param> /// <param name="contractToImplementorsMap"><see cref="IContractToImplementorsMap"/> for keeping track of the relationship between contracts and implementors</param> public AssemblyProvider( IEnumerable <ICanProvideAssemblies> assemblyProviders, IAssemblyFilters assemblyFilters, IAssemblyUtility assemblyUtility, IAssemblySpecifiers assemblySpecifiers, IContractToImplementorsMap contractToImplementorsMap) { _assemblyProviders = assemblyProviders; _assemblyFilters = assemblyFilters; _assemblyUtility = assemblyUtility; _assemblySpecifiers = assemblySpecifiers; _contractToImplementorsMap = contractToImplementorsMap; HookUpAssemblyAddedForProviders(); Populate(); }
public PackageAssemblyResolver( IFileSystem fileSystem, IPackageContainer packageContainer, ILogProvider logProvider, IAssemblyUtility assemblyUtility) { Guard.AgainstNullArgument("fileSystem", fileSystem); Guard.AgainstNullArgumentProperty("fileSystem", "PackagesFolder", fileSystem.PackagesFolder); Guard.AgainstNullArgumentProperty("fileSystem", "PackagesFile", fileSystem.PackagesFile); Guard.AgainstNullArgument("packageContainer", packageContainer); Guard.AgainstNullArgument("logProvider", logProvider); Guard.AgainstNullArgument("assemblyUtility", assemblyUtility); _fileSystem = fileSystem; _packageContainer = packageContainer; _logger = logProvider.ForCurrentType(); _assemblyUtility = assemblyUtility; }
public void ShouldSubscribeToTheResolveEvent( ILog logger, IFileSystem fileSystem, IAssemblyResolver assemblyResolver, IAssemblyUtility assemblyUtility) { bool called = false; new AppDomainAssemblyResolver(logger, fileSystem, assemblyResolver, assemblyUtility, resolveHandler: (o, r) => { called = true; return(Assembly.GetExecutingAssembly()); } ); Assembly.Load("test"); called.ShouldBeTrue(); }
public void ShouldSubscribeToTheResolveEvent( ILog logger, IFileSystem fileSystem, IAssemblyResolver assemblyResolver, IAssemblyUtility assemblyUtility) { bool called = false; new AppDomainAssemblyResolver(logger, fileSystem, assemblyResolver, assemblyUtility, resolveHandler: (o, r) => { called = true; return Assembly.GetExecutingAssembly(); } ); Assembly.Load("test"); called.ShouldBeTrue(); }
public AppDomainAssemblyResolver( ILog logger, IFileSystem fileSystem, IAssemblyResolver resolver, IAssemblyUtility assemblyUtility, IDictionary<string, AssemblyInfo> assemblyInfoMap = null, Func<object, ResolveEventArgs, Assembly> resolveHandler = null) { _assemblyInfoMap = assemblyInfoMap ?? new Dictionary<string, AssemblyInfo>(); _assemblyUtility = assemblyUtility; _logger = logger; _fileSystem = fileSystem; _resolver = resolver; if (resolveHandler == null) { resolveHandler = AssemblyResolve; } AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(resolveHandler); }
public AppDomainAssemblyResolver(ILog logger, IFileSystem fileSystem, IAssemblyResolver resolver, IAssemblyUtility assemblyUtility, IDictionary <string, AssemblyInfo> assemblyInfoMap = null, Func <object, ResolveEventArgs, Assembly> resolveHandler = null) { _assemblyInfoMap = assemblyInfoMap; if (_assemblyInfoMap == null) { _assemblyInfoMap = new Dictionary <string, AssemblyInfo>(); } _assemblyUtility = assemblyUtility; _logger = logger; _fileSystem = fileSystem; _resolver = resolver; if (resolveHandler == null) { resolveHandler = AssemblyResolve; } AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(resolveHandler); }
// HACK: Filter out assemblies in the GAC by checking if full path is specified. private static bool ShouldLoadAssembly(IFileSystem fileSystem, IAssemblyUtility assemblyUtility, string assembly) { return(fileSystem.IsPathRooted(assembly) && assemblyUtility.IsManagedAssembly(assembly)); }
public ModuleLoader(IAssemblyResolver resolver, ILog logger, Action <Assembly, AggregateCatalog> addToCatalog, Func <CompositionContainer, IEnumerable <Lazy <IModule, IModuleMetadata> > > getLazyModules, IFileSystem fileSystem, IAssemblyUtility assemblyUtility) { _resolver = resolver; _logger = logger; if (addToCatalog == null) { addToCatalog = (assembly, catalog) => { try { var assemblyCatalog = new AssemblyCatalog(assembly); catalog.Catalogs.Add(assemblyCatalog); } catch (Exception exception) { logger.DebugFormat("Module Loader exception: {0}", exception.Message); } }; } _addToCatalog = addToCatalog; if (getLazyModules == null) { getLazyModules = (container) => { return(container.GetExports <IModule, IModuleMetadata>()); }; } _getLazyModules = getLazyModules; _fileSystem = fileSystem; _assemblyUtility = assemblyUtility; }
public ModuleLoader(IAssemblyResolver resolver, ILog logger, IFileSystem fileSystem, IAssemblyUtility assemblyUtility) : this(resolver, logger, null, null, fileSystem, assemblyUtility) { }
public ModuleLoader(IAssemblyResolver resolver, Common.Logging.ILog logger, IFileSystem fileSystem, IAssemblyUtility assemblyUtility) : this(resolver, new CommonLoggingLogProvider(logger), fileSystem, assemblyUtility) { }
// HACK: Filter out assemblies in the GAC by checking if full path is specified. private static bool ShouldLoadAssembly(IFileSystem fileSystem, IAssemblyUtility assemblyUtility, string assembly) { return fileSystem.IsPathRooted(assembly) && assemblyUtility.IsManagedAssembly(assembly); }
public ModuleLoader(IAssemblyResolver resolver, Common.Logging.ILog logger, Action <Assembly, AggregateCatalog> addToCatalog, Func <CompositionContainer, IEnumerable <Lazy <IModule, IModuleMetadata> > > getLazyModules, IFileSystem fileSystem, IAssemblyUtility assemblyUtility) : this(resolver, new CommonLoggingLogProvider(logger), addToCatalog, getLazyModules, fileSystem, assemblyUtility) { }
public ModuleLoader(IAssemblyResolver resolver, Common.Logging.ILog logger, Action<Assembly, AggregateCatalog> addToCatalog, Func<CompositionContainer, IEnumerable<Lazy<IModule, IModuleMetadata>>> getLazyModules, IFileSystem fileSystem, IAssemblyUtility assemblyUtility) : this(resolver, new CommonLoggingLogProvider(logger), addToCatalog, getLazyModules, fileSystem, assemblyUtility) { }
public PackageAssemblyResolver( IFileSystem fileSystem, IPackageContainer packageContainer, Common.Logging.ILog logger, IAssemblyUtility assemblyUtility) : this(fileSystem, packageContainer, new CommonLoggingLogProvider(logger), assemblyUtility) { }
internal AssemblyLoadWorker(IAssemblyUtility assemblyUtility) { this.assemblyUtility = assemblyUtility; }
public PackageAssemblyResolver( IFileSystem fileSystem, IPackageContainer packageContainer, ILogProvider logProvider, IAssemblyUtility assemblyUtility) { if (fileSystem == null) { throw new ArgumentNullException(nameof(fileSystem)); } if (packageContainer == null) { throw new ArgumentNullException(nameof(packageContainer)); } if (logProvider == null) { throw new ArgumentNullException(nameof(logProvider)); } if (assemblyUtility == null) { throw new ArgumentNullException(nameof(assemblyUtility)); } _fileSystem = fileSystem; _packageContainer = packageContainer; _logger = logProvider.ForCurrentType(); _assemblyUtility = assemblyUtility; }