public override void Init(TagHelperContext context)
 {
     base.Init(context);
     if (FormGroupContext != null)
     {
         var formGroupContextClone = FormGroupContext.Clone();
         context.SetContextItem(formGroupContextClone);
         formGroupContextClone.ControlSize = BootstrapTagHelpers.Size.Default;
         if (FormGroupContext.FormContext != null)
         {
             formGroupContextClone.FormContext.ControlSize = BootstrapTagHelpers.Size.Default;
             context.SetContextItem(formGroupContextClone.FormContext);
         }
     }
     else if (FormContext != null)
     {
         var formTagHelperClone = FormContext.Clone();
         context.SetContextItem(formTagHelperClone);
         formTagHelperClone.ControlSize = BootstrapTagHelpers.Size.Default;
     }
     if (Size == null)
     {
         var size = FormGroupContext?.ControlSize ?? FormContext?.ControlSize;
         if (size != null)
         {
             Size = size == BootstrapTagHelpers.Size.Large ? SimpleSize.Large : SimpleSize.Small;
         }
     }
 }
 public override void Init(TagHelperContext context)
 {
     base.Init(context);
     if (FormContext != null)
     {
         context.SetContextItem(new FormTagHelper {
             LabelWidthLg  = FormContext.LabelWidthLg,
             LabelWidthMd  = FormContext.LabelWidthMd,
             LabelWidthSm  = FormContext.LabelWidthSm,
             LabelWidthXs  = FormContext.LabelWidthXs,
             FormGroupSize = FormContext.FormGroupSize,
             Horizontal    = false,
             Inline        = FormContext.Inline,
             ControlSize   = FormContext.ControlSize,
             LabelsSrOnly  = FormContext.LabelsSrOnly
         });
     }
     if (FormGroupContext != null)
     {
         context.SetContextItem(new FormGroupTagHelper {
             FormContext       = context.GetContextItem <FormTagHelper>(),
             Size              = FormGroupContext.Size,
             ControlSize       = FormGroupContext.ControlSize,
             HasFeedback       = FormGroupContext.HasFeedback,
             HasLabel          = FormGroupContext.HasLabel,
             LabelWidthLg      = FormGroupContext.LabelWidthLg,
             LabelWidthMd      = FormGroupContext.LabelWidthMd,
             LabelWidthXs      = FormGroupContext.LabelWidthXs,
             LabelWidthSm      = FormGroupContext.LabelWidthSm,
             ValidationContext = FormGroupContext.ValidationContext
         });
     }
 }
        public static void SetContext(object target, TagHelperContext context)
        {
            if (target == null)
            {
                throw new ArgumentNullException(nameof(target));
            }
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            var targetType = target.GetType();
            var attr       = targetType.GetTypeInfo().GetCustomAttribute <ContextClassAttribute>();

            if (attr != null)
            {
                if (string.IsNullOrEmpty(attr.Key))
                {
                    context.SetContextItem(attr.Type ?? targetType, target);
                }
                else
                {
                    context.SetContextItem(attr.Key, target);
                }
            }
        }
        private void SetContext(object target, TagHelperContext context)
        {
            var targetType = target.GetType();
            var attr       = targetType.GetTypeInfo().GetCustomAttribute <TagHelperContextAttribute>();

            if (attr != null)
            {
                if (string.IsNullOrEmpty(attr.Key))
                {
                    context.SetContextItem(attr.Type ?? targetType, target);
                }
                else
                {
                    context.SetContextItem(attr.Key, target);
                }
            }
        }
Esempio n. 5
0
 public override void Init(TagHelperContext context)
 {
     base.Init(context);
     context.SetContextItem(new FormTagHelper {
         ControlSize  = ControlSize ?? FormContext.ControlSize,
         Output       = FormContext.Output,
         Inline       = FormContext.Inline,
         Horizontal   = FormContext.Horizontal,
         LabelWidthXs = FormContext.LabelWidthXs,
         LabelWidthLg = LabelWidthLg ?? FormContext.LabelWidthLg,
         LabelWidthMd = LabelWidthMd ?? FormContext.LabelWidthMd,
         LabelWidthSm = LabelWidthSm ?? FormContext.LabelWidthSm,
         LabelsSrOnly = FormContext.LabelsSrOnly
     });
     Size = Size ?? FormContext.FormGroupSize;
 }