Ejemplo n.º 1
0
 public ControlBuilder <TFlowDataType, TParentType, TParentDataType, TContextType> SetControlType(ControlType controlType, string uiTemplate = null)
 {
     Element.ControlType = controlType;
     if (string.IsNullOrEmpty(uiTemplate))
     {
         Element.UiTemplate = _controlMapper.GetDefault(controlType);
     }
     else
     {
         _controlMapper.CheckForTemplate(controlType, uiTemplate);
         Element.UiTemplate = uiTemplate;
     }
     return(this);
 }
Ejemplo n.º 2
0
        AddControl <TPropertyType>(Expression <Func <TDataType, TPropertyType> > property, ControlType controlType = ControlType.Text, string name = null)
        {
            var expression    = (MemberExpression)property.Body;
            var attrs         = expression.Member.GetCustomAttributes(false);
            var validators    = GenerateValidationModel.Generate(attrs, _validationMapper);
            var modelProperty = expression.Member.Name.FirstCharToLower();
            // name = name != null ? name : modelProperty;

            var builder = new ControlBuilder <TFlowDataType, CollectionBuilder <TFlowDataType, TParentType, TParentDataType, TDataType, TContextType>, TDataType, TContextType>(
                this, name, _controlMapper, controlType);

            builder.Element.ModelProperty = modelProperty;
            builder.Element.TaskPath      = $"{Element.TaskPath}.{modelProperty}";
            builder.Element.DataType      = property.ReturnType;
            builder.Element.UiTemplate    = _controlMapper.GetDefault(controlType);
            builder.Element.Tasks         = new List <TaskDefinition>();

            if (validators != null)
            {
                builder.Element.Validators = validators;
            }
            Element.Elements.Add(builder.Element);
            return(builder);
        }