Example #1
0
        /// <summary>
        /// Processes the specified context.
        /// </summary>
        /// <param name="context">The context to process.</param>
        public override void Process(FormBuilderContext context)
        {
            if (context.Property.GetCustomAttribute <FormDisplayAttribute>() != null)
            {
                FormDisplayAttribute formDisplayAttribute = context.Property.GetCustomAttribute <FormDisplayAttribute>();

                // Build a new hierarchy object for the element
                JObject hierachyObject = new JObject();
                JArray  hierarcyItems  = new JArray();

                hierachyObject["type"]  = new JValue("section");
                hierachyObject["items"] = hierarcyItems;

                if (context.CurrentFormElement != null)
                {
                    // Move the current element into the form hierarcy
                    hierarcyItems.Add(context.CurrentFormElement);
                    context.CurrentFormElementParent.Remove(context.CurrentFormElement);
                    context.CurrentFormElementParent.Add(hierachyObject);
                }

                // Set the new parent element to the current hierarchy
                context.CurrentFormElementParent = hierarcyItems;

                string cssClasses = ConvertDisplayWidthToCssClass(formDisplayAttribute.DisplayWidth);

                if (!string.IsNullOrEmpty(cssClasses))
                {
                    hierachyObject["htmlClass"] = new JValue(cssClasses);
                }
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="AutoInputMetadata"/> class using the specified parameters.
 /// </summary>
 /// <param name="model">The model associated with an instance of an <see cref="IAutoInputComponent"/> component.</param>
 /// <param name="attr">An object that encapsulates display-related metadata.</param>
 ///
 public AutoInputMetadata(object model, FormDisplayAttribute attr)
 {
     Attribute     = attr ?? throw new ArgumentNullException(nameof(attr));
     PropertyInfo  = attr.GetProperty() ?? throw new ArgumentNullException(nameof(PropertyInfo));
     _propertyName = PropertyInfo.Name;
     Refresh(model ?? throw new ArgumentNullException(nameof(model)));
     ExtractOptionsFromRange();
 }