mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-17 05:54:26 +01:00
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)
28 lines
784 B
C#
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; }
|
|
}
|
|
}
|