IEnumerable<Assembly> GetAssembliesInDirectory(string path, params string[] assembliesToSkip) { var assemblyScanner = new AssemblyScanner(path); assemblyScanner.MustReferenceAtLeastOneAssembly.Add(typeof(IHandleMessages<>).Assembly); if (assembliesToSkip != null) { assemblyScanner.AssembliesToSkip = assembliesToSkip.ToList(); } return assemblyScanner .GetScannableAssemblies() .Assemblies; }
static IEnumerable<Type> GetTypesToUse(EndpointConfiguration endpointConfiguration) { var assemblies = new AssemblyScanner().GetScannableAssemblies(); var types = assemblies.Assemblies //exclude all test types by default .Where(a => a != Assembly.GetExecutingAssembly()) .SelectMany(a => a.GetTypes()); types = types.Union(GetNestedTypeRecursive(endpointConfiguration.BuilderType.DeclaringType, endpointConfiguration.BuilderType)); types = types.Union(endpointConfiguration.TypesToInclude); return types.Where(t => !endpointConfiguration.TypesToExclude.Contains(t)).ToList(); }
public static IEnumerable<Type> GetTypesScopedByTestClass(this EndpointCustomizationConfiguration endpointConfiguration) { var assemblies = new AssemblyScanner().GetScannableAssemblies(); var types = assemblies.Assemblies //exclude all test types by default .Where(a => { var references = a.GetReferencedAssemblies(); return references.All(an => an.Name != "nunit.framework"); }) .SelectMany(a => a.GetTypes()); types = types.Union(GetNestedTypeRecursive(endpointConfiguration.BuilderType.DeclaringType, endpointConfiguration.BuilderType)); types = types.Union(endpointConfiguration.TypesToInclude); return types.Where(t => !endpointConfiguration.TypesToExclude.Contains(t)).ToList(); }
static IEnumerable<Type> ScanAssembliesForEndpoints() { if (scannedAssemblies == null) { var assemblyScanner = new AssemblyScanner { ThrowExceptions = false }; assemblyScanner.MustReferenceAtLeastOneAssembly.Add(typeof(IHandleMessages<>).Assembly); assemblyScanner.MustReferenceAtLeastOneAssembly.Add(typeof(IConfigureThisEndpoint).Assembly); assemblyScanner.MustReferenceAtLeastOneAssembly.Add(typeof(NServiceBusRoleEntrypoint).Assembly); scannedAssemblies = assemblyScanner.GetScannableAssemblies().Assemblies; } return scannedAssemblies.SelectMany( assembly => assembly.GetTypes().Where( t => typeof(IConfigureThisEndpoint).IsAssignableFrom(t) && t != typeof(IConfigureThisEndpoint) && !t.IsAbstract)); }
public void TestFixtureSetup() { AssemblyScanner = new AssemblyScanner(); }
public void when_no_endpoint_type_found_via_configuration_or_assembly_scanning_it_should_blow_up() { AssemblyScanner = new AssemblyScanner { IncludeExesInScan = false, AssembliesToSkip = new List<string> { Assembly.GetExecutingAssembly().GetName().Name } }; EndpointTypeDeterminer = new EndpointTypeDeterminer(AssemblyScanner, () => null); RetrievedEndpointType = EndpointTypeDeterminer.GetEndpointConfigurationType().Type; }
private static Type[] FindAllSagaDataTypes() { var scanner = new AssemblyScanner { ThrowExceptions = false }; return scanner.GetScannableAssemblies() .Assemblies.Concat(AppDomain.CurrentDomain.GetAssemblies()) .Where(asm => asm.IsDynamic == false) .Distinct() .SelectMany(a => a.GetTypes()) .Where(t => typeof(IContainSagaData).IsAssignableFrom(t)) .Where(t => t != typeof(IContainSagaData) && t != typeof(ContainSagaData)) .ToArray(); }
static IEnumerable<Type> GetTypesScopedByTestClass(EndpointConfiguration endpointConfiguration) { var assemblies = new AssemblyScanner().GetScannableAssemblies(); var types = assemblies.Assemblies //exclude all test types by default .Where(a => a != Assembly.GetExecutingAssembly()) .Where(a => !a.GetName().Name.StartsWith("ServiceControl.Plugin")) .SelectMany(a => a.GetTypes()); types = types.Union(GetNestedTypeRecursive(endpointConfiguration.BuilderType.DeclaringType, endpointConfiguration.BuilderType)); types = types.Union(endpointConfiguration.TypesToInclude); return types; }
private static IEnumerable<Type> ScanAssembliesForEndpoints() { var assemblyScanner = new AssemblyScanner(); assemblyScanner.MustReferenceAtLeastOneAssembly.Add(typeof(IHandleMessages<>).Assembly); assemblyScanner.MustReferenceAtLeastOneAssembly.Add(typeof(IConfigureThisEndpoint).Assembly); assemblyScanner.MustReferenceAtLeastOneAssembly.Add(typeof(Program).Assembly); foreach (var assembly in assemblyScanner.GetScannableAssemblies().Assemblies) foreach (Type type in assembly.GetTypes().Where( t => typeof(IConfigureThisEndpoint).IsAssignableFrom(t) && t != typeof(IConfigureThisEndpoint) && !t.IsAbstract)) { yield return type; } }