private void LoadAdditionalAssemblies() { #if !NETSTANDARD_TODO var logger = LogManager.GetLogger("AssemblyLoader.Client", LoggerType.Runtime); var directories = new Dictionary <string, SearchOption> { { Path.GetDirectoryName(typeof(OutsideRuntimeClient).GetTypeInfo().Assembly.Location), SearchOption.AllDirectories } }; var excludeCriteria = new AssemblyLoaderPathNameCriterion[] { AssemblyLoaderCriteria.ExcludeResourceAssemblies, AssemblyLoaderCriteria.ExcludeSystemBinaries() }; var loadProvidersCriteria = new AssemblyLoaderReflectionCriterion[] { AssemblyLoaderCriteria.LoadTypesAssignableFrom(typeof(IProvider)) }; this.assemblyProcessor.Initialize(); AssemblyLoader.LoadAssemblies(directories, excludeCriteria, loadProvidersCriteria, logger); #endif }
private static void LoadAdditionalAssemblies() { var logger = TraceLogger.GetLogger("AssemblyLoader.Client", TraceLogger.LoggerType.Runtime); var directories = new Dictionary <string, SearchOption> { { Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), SearchOption.AllDirectories } }; var excludeCriteria = new AssemblyLoaderPathNameCriterion[] { AssemblyLoaderCriteria.ExcludeResourceAssemblies, AssemblyLoaderCriteria.ExcludeSystemBinaries() }; var loadProvidersCriteria = new AssemblyLoaderReflectionCriterion[] { AssemblyLoaderCriteria.LoadTypesAssignableFrom(typeof(IProvider)) }; AssemblyLoader.LoadAssemblies(directories, excludeCriteria, loadProvidersCriteria, logger); }
private AssemblyLoader NewAssemblyLoader(List <string> exclusionList) { var directories = new Dictionary <string, SearchOption> { { Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), SearchOption.AllDirectories } }; // // We need to add current directory in case if xUnit is running an isolated copy of this test dll. // var currentDirectory = Path.GetDirectoryName(Environment.CurrentDirectory); if (!directories.ContainsKey(currentDirectory)) { directories.Add(currentDirectory, SearchOption.AllDirectories); } var excludeCriteria = new AssemblyLoaderPathNameCriterion[] { AssemblyLoaderCriteria.ExcludeResourceAssemblies, AssemblyLoaderCriteria.ExcludeFileNames(exclusionList) }; var loadProvidersCriteria = new AssemblyLoaderReflectionCriterion[] { AssemblyLoaderCriteria.LoadTypesAssignableFrom(typeof(IProvider)) }; return(AssemblyLoader.NewAssemblyLoader(directories, excludeCriteria, loadProvidersCriteria, logger)); }
private void LoadAdditionalAssemblies() { var logger = new LoggerWrapper("Orleans.AssemblyLoader.Client", this.loggerFactory); var directories = new Dictionary <string, SearchOption> { { Path.GetDirectoryName(typeof(OutsideRuntimeClient).GetTypeInfo().Assembly.Location), SearchOption.AllDirectories } }; var excludeCriteria = new AssemblyLoaderPathNameCriterion[] { AssemblyLoaderCriteria.ExcludeResourceAssemblies, AssemblyLoaderCriteria.ExcludeSystemBinaries() }; var loadProvidersCriteria = new AssemblyLoaderReflectionCriterion[] { AssemblyLoaderCriteria.LoadTypesAssignableFrom(typeof(IProvider)) }; this.assemblyProcessor.Initialize(); AssemblyLoader.LoadAssemblies(directories, excludeCriteria, loadProvidersCriteria, logger); }
/// <summary> /// Adds assemblies from the current <see cref="AppDomain.BaseDirectory"/> to the builder. /// </summary> /// <param name="manager">The builder.</param> /// <returns>The builder with the additionally added assemblies.</returns> public static IApplicationPartManagerWithAssemblies AddFromApplicationBaseDirectory(this IApplicationPartManager manager) { var appDomainBase = AppDomain.CurrentDomain.BaseDirectory; if (string.IsNullOrWhiteSpace(appDomainBase) || !Directory.Exists(appDomainBase)) { return(new ApplicationPartManagerWithAssemblies(manager, Enumerable.Empty <Assembly>())); } var dirs = new Dictionary <string, SearchOption> { [appDomainBase] = SearchOption.TopDirectoryOnly }; AssemblyLoaderPathNameCriterion[] excludeCriteria = { AssemblyLoaderCriteria.ExcludeResourceAssemblies }; AssemblyLoaderReflectionCriterion[] loadCriteria = { AssemblyLoaderReflectionCriterion.NewCriterion(ReferencesOrleansOrAbstractionsAssemblyPredicate) }; var loadedAssemblies = AssemblyLoader.LoadAssemblies(dirs, excludeCriteria, loadCriteria, NullLogger.Instance); foreach (var assembly in loadedAssemblies) { manager.AddApplicationPart(new AssemblyPart(assembly)); } return(new ApplicationPartManagerWithAssemblies(manager, loadedAssemblies)); // Returns true if the provided assembly references the Orleans core or abstractions assembly. bool ReferencesOrleansOrAbstractionsAssemblyPredicate(Assembly assembly, out IEnumerable <string> complaints) { var referencesOrleans = assembly.GetReferencedAssemblies().Any(ReferencesOrleansOrAbstractions); complaints = referencesOrleans ? null : NoReferenceComplaint; return(referencesOrleans); bool ReferencesOrleansOrAbstractions(AssemblyName reference) { return(string.Equals(reference.Name, CoreAssemblyName, StringComparison.OrdinalIgnoreCase) || string.Equals(reference.Name, AbstractionsAssemblyName, StringComparison.OrdinalIgnoreCase)); } } }
/// <summary> /// Attempts to load and add assemblies from the specified directories as application parts. /// </summary> /// <param name="applicationPartManager">The application part manager.</param> /// <param name="directories">The directories to search.</param> private static void AddApplicationPartsFromProbingPath(this ApplicationPartManager applicationPartManager, params string[] directories) { if (directories == null) { throw new ArgumentNullException(nameof(directories)); } var dirs = new Dictionary <string, SearchOption>(); foreach (var dir in directories) { dirs[dir] = SearchOption.TopDirectoryOnly; } AssemblyLoaderPathNameCriterion[] excludeCriteria = { AssemblyLoaderCriteria.ExcludeResourceAssemblies }; AssemblyLoaderReflectionCriterion[] loadCriteria = { AssemblyLoaderReflectionCriterion.NewCriterion(ReferencesOrleansOrAbstractionsAssemblyPredicate) }; var loadedAssemblies = AssemblyLoader.LoadAssemblies(dirs, excludeCriteria, loadCriteria, new LoggerWrapper(nameof(ApplicationPartManagerExtensions), NullLoggerFactory.Instance)); foreach (var assembly in loadedAssemblies) { applicationPartManager.AddApplicationPart(assembly); } // Returns true if the provided assembly references the Orleans core or abstractions assembly. bool ReferencesOrleansOrAbstractionsAssemblyPredicate(Assembly assembly, out IEnumerable <string> complaints) { var referencesOrleans = assembly.GetReferencedAssemblies().Any(ReferencesOrleansOrAbstractions); complaints = referencesOrleans ? null : NoReferenceComplaint; return(referencesOrleans); bool ReferencesOrleansOrAbstractions(AssemblyName reference) { return(string.Equals(reference.Name, CoreAssemblyName, StringComparison.OrdinalIgnoreCase) || string.Equals(reference.Name, AbstractionsAssemblyName, StringComparison.OrdinalIgnoreCase)); } } }
private AssemblyLoader NewAssemblyLoader(List <string> exclusionList) { var directories = new Dictionary <string, SearchOption> { { Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), SearchOption.AllDirectories } }; var excludeCriteria = new AssemblyLoaderPathNameCriterion[] { AssemblyLoaderCriteria.ExcludeResourceAssemblies, AssemblyLoaderCriteria.ExcludeFileNames(exclusionList) }; var loadProvidersCriteria = new AssemblyLoaderReflectionCriterion[] { AssemblyLoaderCriteria.LoadTypesAssignableFrom(typeof(IProvider)) }; return(AssemblyLoader.NewAssemblyLoader(directories, excludeCriteria, loadProvidersCriteria, logger)); }