Ejemplo n.º 1
0
        /// <summary>
        /// Processes a property through the pipeline modules.
        /// </summary>
        /// <param name="objectType">Type of the object.</param>
        /// <param name="originObjectType">Type of the origin object.</param>
        /// <param name="propertyInfo">The property information.</param>
        /// <param name="formElements">The form elements.</param>
        /// <param name="sourcePropertyPath">The source property path to use as start.</param>
        /// <param name="cultureInfo">The culture information.</param>
        /// <returns>
        /// The form element.
        /// </returns>
        private JArray ProcessProperty(Type objectType, Type originObjectType, PropertyInfo propertyInfo, JArray formElements, string sourcePropertyPath, CultureInfo cultureInfo)
        {
            // Create the context for this property
            FormBuilderContext context = new FormBuilderContext();

            context.DtoType                  = objectType;
            context.OriginDtoType            = originObjectType;
            context.Property                 = propertyInfo;
            context.CompleteForm             = formElements;
            context.CurrentFormElementParent = formElements;
            context.FormBuilder              = this;
            context.TargetCulture            = cultureInfo;

            // Set up the full property path to this property
            context.FullPropertyPath = string.IsNullOrEmpty(sourcePropertyPath)
                                           ? propertyInfo.Name
                                           : sourcePropertyPath + "." + propertyInfo.Name;

            // Run the property through each pipeline module
            foreach (IFormBuilderModule builderModule in this._pipelineModules)
            {
                builderModule.Process(context);

                if (context.FinishProcessing)
                {
                    // Stop the pipeline to run the next module
                    break;
                }
            }

            return(context.CompleteForm);
        }
        /// <summary>
        /// Processes a property through the pipeline modules.
        /// </summary>
        /// <param name="objectType">Type of the object.</param>
        /// <param name="originObjectType">Type of the origin object.</param>
        /// <param name="propertyInfo">The property information.</param>
        /// <param name="formElements">The form elements.</param>
        /// <param name="sourcePropertyPath">The source property path to use as start.</param>
        /// <param name="cultureInfo">The culture information.</param>
        /// <returns>
        /// The form element.
        /// </returns>
        private JArray ProcessProperty(Type objectType, Type originObjectType, PropertyInfo propertyInfo, JArray formElements, string sourcePropertyPath, CultureInfo cultureInfo)
        {
            // Create the context for this property
            FormBuilderContext context = new FormBuilderContext();
            context.DtoType = objectType;
            context.OriginDtoType = originObjectType;
            context.Property = propertyInfo;
            context.CompleteForm = formElements;
            context.CurrentFormElementParent = formElements;
            context.FormBuilder = this;
            context.TargetCulture = cultureInfo;

            // Set up the full property path to this property
            context.FullPropertyPath = string.IsNullOrEmpty(sourcePropertyPath)
                                           ? propertyInfo.Name
                                           : sourcePropertyPath + "." + propertyInfo.Name;

            // Run the property through each pipeline module
            foreach (IFormBuilderModule builderModule in this._pipelineModules)
            {
                builderModule.Process(context);

                if (context.FinishProcessing)
                {
                    // Stop the pipeline to run the next module
                    break;
                }
            }

            return context.CompleteForm;
        }