Example #1
0
        public void CloseFieldset(RadiosFieldsetContext fieldsetContext)
        {
            if (!_fieldsetIsOpen)
            {
                throw new InvalidOperationException("Fieldset has not been opened.");
            }

            _fieldsetIsOpen = false;
            Fieldset        = fieldsetContext;
        }
        public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
        {
            var radiosContext = context.GetContextItem <RadiosContext>();

            radiosContext.OpenFieldset();

            var fieldsetContext = new RadiosFieldsetContext(output.Attributes.ToAttributeDictionary());

            using (context.SetScopedContextItem(fieldsetContext))
            {
                await output.GetChildContentAsync();
            }

            fieldsetContext.ThrowIfNotComplete();
            radiosContext.CloseFieldset(fieldsetContext);

            output.SuppressOutput();
        }
Example #3
0
        public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
        {
            var radiosContext = (RadiosContext)context.Items[typeof(RadiosContext)];

            var fieldsetContext = new RadiosFieldsetContext();

            using (context.SetScopedContextItem(typeof(RadiosFieldsetContext), fieldsetContext))
            {
                await output.GetChildContentAsync();
            }

            radiosContext.SetFieldset(new RadiosFieldset()
            {
                Attributes          = output.Attributes.ToAttributesDictionary(),
                LegendIsPageHeading = fieldsetContext.Legend?.isPageHeading,
                LegendContent       = fieldsetContext.Legend?.content,
                LegendAttributes    = fieldsetContext.Legend?.attributes
            });

            output.SuppressOutput();
        }