feat: added NitrideBuilder.UseModule() methods to simplify adding modules

This commit is contained in:
Dylan R. E. Moonfire 2022-07-18 16:07:34 -05:00
parent 6b4fb3f840
commit 516aeb254b

View file

@ -13,6 +13,8 @@ using Serilog;
using Zio; using Zio;
using Zio.FileSystems; using Zio.FileSystems;
using Module = Autofac.Module;
namespace Nitride; namespace Nitride;
/// <summary> /// <summary>
@ -99,6 +101,31 @@ public class NitrideBuilder
.RunAsync(); .RunAsync();
} }
/// <summary>
/// Initialize the builder with a given Autofac module.
/// </summary>
/// <typeparam name="TModule">The type of module to use.</typeparam>
/// <returns>The builder to chain operations.</returns>
public NitrideBuilder UseModule<TModule>()
where TModule : Module, new()
{
this.ConfigureContainer(x => x.RegisterModule<TModule>());
return this;
}
/// <summary>
/// Initialize the builder with a given Autofac module.
/// </summary>
/// <typeparam name="TModule">The type of module to use.</typeparam>
/// <returns>The builder to chain operations.</returns>
public NitrideBuilder UseModule(Module module)
{
this.ConfigureContainer(x => x.RegisterModule(module));
return this;
}
/// <summary> /// <summary>
/// Sets the description of the builder. /// Sets the description of the builder.
/// </summary> /// </summary>