// Copyright Epic Games, Inc. All Rights Reserved.
using System;
using System.Reflection;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
namespace HordeServer.Plugins
{
///
/// Interface for manipulating a plugin
///
public interface IPlugin
{
///
/// Name of the plugin
///
PluginName Name { get; }
///
/// Metadata for the plugin
///
IPluginMetadata Metadata { get; }
///
/// Load this plugin
///
ILoadedPlugin Load();
}
///
/// Plugin which has been loaded
///
public interface ILoadedPlugin : IPlugin
{
///
/// Assembly containing the plugin's implementation
///
Assembly Assembly { get; }
///
/// Type used for the server config.
///
Type ServerConfigType { get; }
///
/// Type used for the global config.
///
Type GlobalConfigType { get; }
///
/// Configure services for the plugin
///
/// Static configuration data
/// Information about the server
/// Service collection instance
void ConfigureServices(IConfiguration configuration, IServerInfo serverInfo, IServiceCollection serviceCollection);
}
///
/// Extension methods for plugins
///
public static class PluginExtensions
{
///
/// Adds a plugin's services to a service collection
///
public static void AddPlugin(this IServiceCollection serviceCollection, IServerInfo serverInfo, ILoadedPlugin plugin, IConfiguration configuration)
=> plugin.ConfigureServices(configuration, serverInfo, serviceCollection);
}
}