public virtual void RegisterWidget(Regex zonePattern, WidgetInvoker widget) { Guard.NotNull(zonePattern, nameof(zonePattern)); Guard.NotNull(widget, nameof(widget)); if (_accessor.HttpContext?.Request?.Query?.ContainsKey("nowidgets") == true) { return; } if (_zoneExpressionWidgetsMap == null) { _zoneExpressionWidgetsMap = new Multimap <Regex, WidgetInvoker>(); } _zoneExpressionWidgetsMap.Add(zonePattern, widget); }
public virtual void RegisterWidget(string[] zones, WidgetInvoker widget) { Guard.NotNull(zones, nameof(zones)); Guard.NotNull(widget, nameof(widget)); if (_accessor.HttpContext?.Request?.Query?.ContainsKey("nowidgets") == true) { return; } if (_zoneWidgetsMap == null) { _zoneWidgetsMap = new Multimap <string, WidgetInvoker>(StringComparer.OrdinalIgnoreCase); } foreach (var zone in zones) { _zoneWidgetsMap.Add(zone, widget); } }
// TODO: (core) Implement IWidgetProviderExtensions.RegisterViewComponent() /// <summary> /// Registers a custom widget for a single widget zone. /// </summary> /// <param name="zone">The name of the widget zone to inject the HTML content to</param> /// <param name="widget">Widget to register</param> public static void RegisterWidget(this IWidgetProvider provider, string zone, WidgetInvoker widget) { Guard.NotEmpty(zone, nameof(zone)); provider.RegisterWidget(new[] { zone }, widget); }