btcpayserver/BTCPayServer/Components/UIExtensionPoint/UIExtensionPoint.cs
Andrew Camilleri 5979fe5eef
BTCPay Extensions Part 2 (#2001)
* BTCPay Extensions Part 2

This PR cleans up the extension system a bit in that:
 * It renames the test extension to a more uniform name
 * Allows yo uto have system extensions, which are extensions but bundled by default with the release (and cannot be removed)
 * Adds a tool to help you generate an extension package from a csproj
 * Refactors the UI extension points to a view component
 * Moves some more interfaces to the Abstractions csproj

* Rename to plugins
2020-10-21 14:02:20 +02:00

23 lines
709 B
C#

using System;
using System.Collections.Generic;
using System.Linq;
using BTCPayServer.Contracts;
using Microsoft.AspNetCore.Mvc;
namespace BTCPayServer.Components.UIExtensionPoint
{
public class UiExtensionPoint : ViewComponent
{
private readonly IEnumerable<IUIExtension> _uiExtensions;
public UiExtensionPoint(IEnumerable<IUIExtension> uiExtensions)
{
_uiExtensions = uiExtensions;
}
public IViewComponentResult Invoke(string location)
{
return View(_uiExtensions.Where(extension => extension.Location.Equals(location, StringComparison.InvariantCultureIgnoreCase)).Select(extension => extension.Partial));
}
}
}