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; }
///
/// Gets or sets the description of the website.
///
public string? Description { get; set; }
///
protected override void Load(ContainerBuilder builder)
{
// Pipelines
builder.RegisterType()
.AsSelf();
builder.RegisterType()
.AsSelf()
.SingleInstance();
// Operations
builder.RegisterValidators(this);
builder.RegisterOperators(this);
// Commands
builder.RegisterType()
.AsSelf()
.As()
.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 commands =
c.Resolve>();
foreach (Command command in commands)
{
root.AddCommand(command);
}
return root;
})
.AsSelf();
}
}