コード例 #1
0
        public void ChangeType(ModelItemTypeEnum newType)
        {
            this.ObjectType = newType;

            this.uxContent.Content = null;

            FieldInformationAttribute fieldValues = (FieldInformationAttribute)this.PropertyInfo.GetCustomAttribute(typeof(FieldInformationAttribute));

            this.CreateContent(this.parent, fieldValues);
        }
コード例 #2
0
        public override ValidationResult Validate(object value, System.Globalization.CultureInfo cultureInfo)
        {
            StringBuilder resultMessage = new StringBuilder();

            resultMessage.Append("Either ");

            List <bool> itemHaveValues = new List <bool>();

            foreach (ModelViewItem item in this.GroupItems)
            {
                resultMessage.Append($"{item.Caption} or ");

                ModelItemTypeEnum itemType = item.ObjectType;

                object itemValue = item.GetValue();

                switch (itemType)
                {
                case ModelItemTypeEnum.DatePicker:

                    if (itemValue == null && this.IsRequired)
                    {
                        itemHaveValues.Add(false);
                    }
                    else
                    {
                        itemHaveValues.Add(true);
                    }

                    break;

                case ModelItemTypeEnum.CheckBox:
                case ModelItemTypeEnum.ComboBox:
                case ModelItemTypeEnum.EnumBox:
                case ModelItemTypeEnum.SecureString:
                case ModelItemTypeEnum.TextBox:
                default:

                    string content = itemValue as String;

                    if (content.IsNullEmptyOrWhiteSpace() && this.IsRequired)
                    {
                        itemHaveValues.Add(false);
                    }
                    else
                    {
                        itemHaveValues.Add(true);
                    }

                    break;
                }
            }

            resultMessage.Remove(resultMessage.Length - 3, 3);

            resultMessage.Append("is required.");

            if (!itemHaveValues.Any(a => a))
            {
                return(new ValidationResult(false, resultMessage.ToString()));
            }

            return(ValidationResult.ValidResult);
        }
コード例 #3
0
        public ItemTypeAttribute(ModelItemTypeEnum modelType, bool isComboboxEdit = true)
        {
            this.modelRenderType = modelType;

            this.isComboboxEditable = isComboboxEdit;
        }