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>(invokers => new HashSet <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, invokers => new HashSet <WidgetInvoker>());
            }

            foreach (var zone in zones)
            {
                _zoneWidgetsMap.Add(zone, widget);
            }
        }
Example #3
0
        // 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);
        }