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

Commit

Permalink
Merge pull request #2217 from thecodejunkie/type-and-assembly-catalog…
Browse files Browse the repository at this point in the history
…-on-bootstrapper

Added type and assembly catalogs on the bootstrapper
  • Loading branch information
jchannon committed Feb 3, 2016
2 parents 0d42137 + 4bca4d9 commit 6cbd4b6
Showing 1 changed file with 32 additions and 10 deletions.
42 changes: 32 additions & 10 deletions src/Nancy/Bootstrapper/NancyBootstrapperBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ public abstract class NancyBootstrapperBase<TContainer> : INancyBootstrapper, IN
/// </summary>
protected Type[] RequestStartupTaskTypeCache { get; private set; }

private IAssemblyCatalog assemblyCatalog;
private ITypeCatalog typeCatalog;

/// <summary>
/// Initializes a new instance of the <see cref="NancyBootstrapperBase{TContainer}"/> class.
/// </summary>
Expand All @@ -79,6 +82,24 @@ protected NancyBootstrapperBase()
/// </summary>
protected TContainer ApplicationContainer { get; private set; }

/// <summary>
/// Gets the <see cref="IAssemblyCatalog"/> that should be used by the application.
/// </summary>
/// <value>An <see cref="IAssemblyCatalog"/> instance.</value>
protected virtual IAssemblyCatalog AssemblyCatalog
{
get { return this.assemblyCatalog ?? (this.assemblyCatalog = new AppDomainAssemblyCatalog()); }
}

/// <summary>
/// Gets the <see cref="ITypeCatalog"/> that should be used by the application.
/// </summary>
/// <value>An <see cref="ITypeCatalog"/> instance.</value>
protected virtual ITypeCatalog TypeCatalog
{
get { return this.typeCatalog ?? (this.typeCatalog = new DefaultTypeCatalog(this.AssemblyCatalog)); }
}

/// <summary>
/// Nancy internal configuration
/// </summary>
Expand Down Expand Up @@ -606,6 +627,8 @@ private IEnumerable<InstanceRegistration> GetAdditionalInstances()
new InstanceRegistration(typeof(CryptographyConfiguration), this.CryptographyConfiguration),
new InstanceRegistration(typeof(NancyInternalConfiguration), this.InternalConfiguration),
new InstanceRegistration(typeof(IRootPathProvider), this.RootPathProvider),
new InstanceRegistration(typeof(IAssemblyCatalog), this.AssemblyCatalog),
new InstanceRegistration(typeof(ITypeCatalog), this.TypeCatalog),
};
}

Expand All @@ -616,16 +639,15 @@ private IEnumerable<InstanceRegistration> GetAdditionalInstances()
/// <returns>Collection of CollectionTypeRegistration types</returns>
private IEnumerable<CollectionTypeRegistration> GetApplicationCollections()
{
return new[]
{
new CollectionTypeRegistration(typeof(IViewEngine), this.ViewEngines),
new CollectionTypeRegistration(typeof(IModelBinder), this.ModelBinders),
new CollectionTypeRegistration(typeof(ITypeConverter), this.TypeConverters),
new CollectionTypeRegistration(typeof(IBodyDeserializer), this.BodyDeserializers),
new CollectionTypeRegistration(typeof(IApplicationStartup), this.ApplicationStartupTasks),
new CollectionTypeRegistration(typeof(IRegistrations), this.RegistrationTasks),
new CollectionTypeRegistration(typeof(IModelValidatorFactory), this.ModelValidatorFactories)
};
return new[] {
new CollectionTypeRegistration(typeof(IViewEngine), this.ViewEngines),
new CollectionTypeRegistration(typeof(IModelBinder), this.ModelBinders),
new CollectionTypeRegistration(typeof(ITypeConverter), this.TypeConverters),
new CollectionTypeRegistration(typeof(IBodyDeserializer), this.BodyDeserializers),
new CollectionTypeRegistration(typeof(IApplicationStartup), this.ApplicationStartupTasks),
new CollectionTypeRegistration(typeof(IRegistrations), this.RegistrationTasks),
new CollectionTypeRegistration(typeof(IModelValidatorFactory), this.ModelValidatorFactories)
};
}

private INancyEngine SafeGetNancyEngineInstance()
Expand Down

0 comments on commit 6cbd4b6

Please sign in to comment.