2022-06-05 18:44:51 +00:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.CommandLine;
|
|
|
|
|
2021-09-07 05:15:45 +00:00
|
|
|
using Autofac;
|
2022-06-05 18:44:51 +00:00
|
|
|
|
2022-09-06 05:53:22 +00:00
|
|
|
using MfGames.Nitride.Commands;
|
|
|
|
using MfGames.Nitride.Pipelines;
|
2021-09-07 05:15:45 +00:00
|
|
|
|
2022-09-06 05:53:22 +00:00
|
|
|
namespace MfGames.Nitride;
|
2022-06-05 18:44:51 +00:00
|
|
|
|
|
|
|
public class NitrideModule : Module
|
2021-09-07 05:15:45 +00:00
|
|
|
{
|
2022-06-05 18:44:51 +00:00
|
|
|
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)
|
2021-09-07 05:15:45 +00:00
|
|
|
{
|
2022-06-05 18:44:51 +00:00
|
|
|
// Pipelines
|
2022-07-09 04:52:10 +00:00
|
|
|
builder.RegisterType<PipelineRunner>()
|
|
|
|
.AsSelf();
|
|
|
|
|
|
|
|
builder.RegisterType<PipelineManager>()
|
|
|
|
.AsSelf()
|
|
|
|
.SingleInstance();
|
2022-06-05 18:44:51 +00:00
|
|
|
|
|
|
|
// Operations
|
|
|
|
builder.RegisterValidators(this);
|
|
|
|
builder.RegisterOperators(this);
|
|
|
|
|
|
|
|
// Commands
|
2022-07-09 04:52:10 +00:00
|
|
|
builder.RegisterType<BuildCommand>()
|
|
|
|
.AsSelf()
|
|
|
|
.As<Command>()
|
|
|
|
.SingleInstance();
|
2022-06-05 18:44:51 +00:00
|
|
|
|
|
|
|
// 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.
|
2023-01-15 00:19:42 +00:00
|
|
|
IEnumerable<Command> commands =
|
|
|
|
c.Resolve<IEnumerable<Command>>();
|
2022-06-05 18:44:51 +00:00
|
|
|
|
|
|
|
foreach (Command command in commands)
|
|
|
|
{
|
|
|
|
root.AddCommand(command);
|
|
|
|
}
|
|
|
|
|
|
|
|
return root;
|
|
|
|
})
|
|
|
|
.AsSelf();
|
2021-09-07 05:15:45 +00:00
|
|
|
}
|
|
|
|
}
|