Files
btcpayserver/BTCPayServer/Components/UiExtensionPoint/UIExtensionPoint.cs
Nicolas Dorier 52a73d4dd3 Refactor: Add UIExtensionsRegistry
The component UIExtensionPoint was injecting IEnumerable<IUIExtension>
and then filtering on those.
As the number of IUIExtension grows, this operation grows at O(n).

Now we use UIExtensionsRegistry instead which use lookups. O(1)
2025-11-12 11:52:08 +09:00

28 lines
784 B
C#

using System;
using System.Collections.Generic;
using System.Linq;
using BTCPayServer.Abstractions.Contracts;
using BTCPayServer.Services;
using Microsoft.AspNetCore.Mvc;
namespace BTCPayServer.Components.UIExtensionPoint
{
public class UiExtensionPoint(UIExtensionsRegistry uiExtensions) : ViewComponent
{
public IViewComponentResult Invoke(string location, object model)
{
return View(new UiExtensionPointViewModel()
{
Partials = uiExtensions.ExtensionsByLocation[location].Select(c => c.Partial).ToArray(),
Model = model
});
}
}
public class UiExtensionPointViewModel
{
public string[] Partials { get; set; }
public object Model { get; set; }
}
}