Skip to content

Instantly share code, notes, and snippets.

@emonarafat
Created July 2, 2025 19:44
Show Gist options
  • Select an option

  • Save emonarafat/f12fba1f1c88950dbb8930dde26b647b to your computer and use it in GitHub Desktop.

Select an option

Save emonarafat/f12fba1f1c88950dbb8930dde26b647b to your computer and use it in GitHub Desktop.
πŸ”Œ Simple .NET plugin architecture pattern using IPlugin and extension methods for modular service registration.
// PluginHostExtensions.cs
public static class PluginHostExtensions
{
public static IServiceCollection AddPlugin<TPlugin>(this IServiceCollection services)
where TPlugin : class, IPlugin, new()
{
var plugin = new TPlugin();
plugin.ConfigureServices(services);
return services;
}
}
public interface IPlugin
{
void ConfigureServices(IServiceCollection services);
}
// Example Plugin
public class PaymentsFeature : IPlugin
{
public void ConfigureServices(IServiceCollection services)
{
services.AddScoped<IPaymentProcessor, StripePaymentProcessor>();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment