示例#1
0
        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);
        }
示例#2
0
        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);
            }
        }
示例#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);
        }