Skip to content
This repository has been archived by the owner on Jan 24, 2021. It is now read-only.

Replaced use of ADATS with ITypeCatalog inside the bootstrapperbase #2222

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
31 changes: 14 additions & 17 deletions src/Nancy/Bootstrapper/NancyBootstrapperBase.cs
Expand Up @@ -133,8 +133,8 @@ protected virtual IEnumerable<ModuleRegistration> Modules
return
this.modules
??
(this.modules = AppDomainAssemblyTypeScanner
.TypesOf<INancyModule>(ScanMode.ExcludeNancy)
(this.modules = this.TypeCatalog
.GetTypesAssignableTo<INancyModule>(TypeResolveStrategies.ExcludeNancy)
.NotOfType<DiagnosticModule>()
.Select(t => new ModuleRegistration(t))
.ToArray());
Expand All @@ -148,7 +148,7 @@ protected virtual IEnumerable<Type> ViewEngines
{
get
{
return AppDomainAssemblyTypeScanner.TypesOf<IViewEngine>();
return this.TypeCatalog.GetTypesAssignableTo<IViewEngine>();
}
}

Expand All @@ -159,7 +159,7 @@ protected virtual IEnumerable<Type> ModelBinders
{
get
{
return AppDomainAssemblyTypeScanner.TypesOf<IModelBinder>();
return this.TypeCatalog.GetTypesAssignableTo<IModelBinder>();
}
}

Expand All @@ -170,7 +170,7 @@ protected virtual IEnumerable<Type> TypeConverters
{
get
{
return AppDomainAssemblyTypeScanner.TypesOf<ITypeConverter>(ScanMode.ExcludeNancy);
return this.TypeCatalog.GetTypesAssignableTo<ITypeConverter>(TypeResolveStrategies.ExcludeNancy);
}
}

Expand All @@ -179,47 +179,47 @@ protected virtual IEnumerable<Type> TypeConverters
/// </summary>
protected virtual IEnumerable<Type> BodyDeserializers
{
get { return AppDomainAssemblyTypeScanner.TypesOf<IBodyDeserializer>(ScanMode.ExcludeNancy); }
get { return this.TypeCatalog.GetTypesAssignableTo<IBodyDeserializer>(TypeResolveStrategies.ExcludeNancy); }
}

/// <summary>
/// Gets all application startup tasks
/// </summary>
protected virtual IEnumerable<Type> ApplicationStartupTasks
{
get { return AppDomainAssemblyTypeScanner.TypesOf<IApplicationStartup>(); }
get { return this.typeCatalog.GetTypesAssignableTo<IApplicationStartup>(); }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use TypeCatalog

}

/// <summary>
/// Gets all request startup tasks
/// </summary>
protected virtual IEnumerable<Type> RequestStartupTasks
{
get { return AppDomainAssemblyTypeScanner.TypesOf<IRequestStartup>(); }
get { return this.TypeCatalog.GetTypesAssignableTo<IRequestStartup>(); }
}

/// <summary>
/// Gets all registration tasks
/// </summary>
protected virtual IEnumerable<Type> RegistrationTasks
{
get { return AppDomainAssemblyTypeScanner.TypesOf<IRegistrations>(); }
get { return this.TypeCatalog.GetTypesAssignableTo<IRegistrations>(); }
}

/// <summary>
/// Gets the root path provider
/// </summary>
protected virtual IRootPathProvider RootPathProvider
{
get { return this.rootPathProvider ?? (this.rootPathProvider = GetRootPathProvider()); }
get { return this.rootPathProvider ?? (this.rootPathProvider = this.GetRootPathProvider()); }
}

/// <summary>
/// Gets the validator factories.
/// </summary>
protected virtual IEnumerable<Type> ModelValidatorFactories
{
get { return AppDomainAssemblyTypeScanner.TypesOf<IModelValidatorFactory>(); }
get { return this.TypeCatalog.GetTypesAssignableTo<IModelValidatorFactory>(); }
}

/// <summary>
Expand Down Expand Up @@ -259,9 +259,6 @@ public void Initialise()

this.ConfigureApplicationContainer(this.ApplicationContainer);

// We need to call this to fix an issue with assemblies that are referenced by DI not being loaded
AppDomainAssemblyTypeScanner.UpdateTypes();

var typeRegistrations = this.InternalConfiguration
.GetTypeRegistrations()
.Concat(this.GetAdditionalTypes());
Expand Down Expand Up @@ -695,10 +692,10 @@ protected virtual void RegisterRegistrationTasks(IEnumerable<IRegistrations> reg
}
}

private static IRootPathProvider GetRootPathProvider()
private IRootPathProvider GetRootPathProvider()
{
var providerTypes = AppDomainAssemblyTypeScanner
.TypesOf<IRootPathProvider>(ScanMode.ExcludeNancy)
var providerTypes = this.TypeCatalog
.GetTypesAssignableTo<IRootPathProvider>(TypeResolveStrategies.ExcludeNancy)
.ToArray();

if (providerTypes.Length > 1)
Expand Down