/// <summary>
        ///   Initializes this Localize Tag Helpers, setting the html localizer and creating a stack list
        ///   for child tag helpers to add parameters to.
        /// </summary>
        /// <inheritdoc />
        public override void Init(TagHelperContext context)
        {
            localizer = localizerFactory.ResolveLocalizer(ViewContext, applicationName, Type, Name);

            if (!SupportsParameters)
            {
                return;
            }

            Stack <List <object> > currentStack;

            if (!context.Items.ContainsKey(typeof(GenericLocalizeTagHelper)))
            {
                currentStack = new Stack <List <object> >();
                context.Items.Add(typeof(GenericLocalizeTagHelper), currentStack);
            }
            else
            {
                currentStack = (Stack <List <object> >)context.Items[typeof(GenericLocalizeTagHelper)];
            }

            currentStack.Push(new List <object>());
        }
예제 #2
0
        /// <summary>
        /// Initializes this Localize Tag Helpers, setting the html localizer and creating a stack list
        /// for child tag helpers to add parameters to.
        /// </summary>
        /// <inheritdoc/>
        public override void Init(TagHelperContext context)
        {
            var key = CACHED_LOCALIZER_KEY + ViewContext.ExecutingFilePath;

            if (Localizer is null)
            {
                if (ViewContext.ViewData.ContainsKey(key))
                {
                    Localizer = ViewContext.ViewData[key] as IHtmlLocalizer;
                }
                else
                {
                    Localizer = localizerFactory.ResolveLocalizer(ViewContext, applicationName, Type, Name);
                    ViewContext.ViewData[key] = Localizer;
                }
            }

            if (!SupportsParameters)
            {
                return;
            }

            Stack <List <object> > currentStack;

            if (!context.Items.ContainsKey(typeof(GenericLocalizeTagHelper)))
            {
                currentStack = new Stack <List <object> >();
                context.Items.Add(typeof(GenericLocalizeTagHelper), currentStack);
            }
            else
            {
                currentStack = (Stack <List <object> >)context.Items[typeof(GenericLocalizeTagHelper)];
            }

            currentStack.Push(new List <object>());
        }
예제 #3
0
 /// <summary>
 ///   Initializes the html localizer to use when localizing attributes.
 /// </summary>
 /// <inheritdoc />
 public override void Init(TagHelperContext context)
 {
     localizer = localizerFactory.ResolveLocalizer(ViewContext, applicationName);
 }