Code/SboxSuperuser/Engine/Modules/ModuleRegistration.cs

A small facade passed to modules during registration. Wraps a CommandRegistrationScope so modules can only stage commands, permissions, services, menu windows and documentation, per the header comment. Every method forwards directly to the scope.

namespace SboxSuperuser.Engine.Modules;

// Modules receive only staging operations; they cannot commit or replace another scope.
internal sealed class ModuleRegistration : IModuleRegistration
{
	private readonly CommandRegistrationScope _scope;
	internal ModuleRegistration( CommandRegistrationScope scope ) => _scope = scope;
	public string ModuleId => _scope.ModuleId;
	public void RegisterCommand( CommandDescriptor descriptor, CommandHandler handler ) => _scope.RegisterCommand( descriptor, handler );
	public void RegisterPermission( PermissionDescriptor descriptor ) => _scope.RegisterPermission( descriptor );
	public void RegisterService<T>( T service ) where T : class => _scope.RegisterService( service );
	public void DiscoverCommands() => _scope.DiscoverCommands();
	public void Track( IDisposable subscription ) => _scope.Track( subscription );
	public void AddDocumentation( string title, string markdown ) => _scope.AddDocumentation( title, markdown );
	public void AddDocumentationFile( string title, string path ) => _scope.AddDocumentationFile( title, path );
	public void AddMenuWindow( string title, Action<AdminMenuWindow> build, string menu = null ) => _scope.AddMenuWindow( title, build, menu );
}