This repository has been archived on 2023-02-02. You can view files and clone it, but cannot push or open issues or pull requests.
mfgames-nitride-cil/src/MfGames.Nitride/NitrideModule.cs
D. Moonfire 9e93eb6ce6 refactor!: fixed missed namespaces
- reformatted code and cleaned up references
2023-01-14 18:19:42 -06:00

75 lines
2 KiB
C#

using System.Collections.Generic;
using System.CommandLine;
using Autofac;
using MfGames.Nitride.Commands;
using MfGames.Nitride.Pipelines;
namespace MfGames.Nitride;
public class NitrideModule : Module
{
public string? ApplicationName { get; set; }
/// <summary>
/// Gets or sets the description of the website.
/// </summary>
public string? Description { get; set; }
/// <inheritdoc />
protected override void Load(ContainerBuilder builder)
{
// Pipelines
builder.RegisterType<PipelineRunner>()
.AsSelf();
builder.RegisterType<PipelineManager>()
.AsSelf()
.SingleInstance();
// Operations
builder.RegisterValidators(this);
builder.RegisterOperators(this);
// Commands
builder.RegisterType<BuildCommand>()
.AsSelf()
.As<Command>()
.SingleInstance();
// MfGames.ToolBuilder requires the RootCommand to be registered. This is because
// of various things, mostly coordinating between different systems.
builder.Register(
c =>
{
// Create the new root command.
var root = new RootCommand();
if (!string.IsNullOrWhiteSpace(this.ApplicationName))
{
root.Name = this.ApplicationName;
}
if (!string.IsNullOrWhiteSpace(this.Description))
{
root.Description = this.Description;
}
;
// Add in the commands.
IEnumerable<Command> commands =
c.Resolve<IEnumerable<Command>>();
foreach (Command command in commands)
{
root.AddCommand(command);
}
return root;
})
.AsSelf();
}
}