public object Get(IModelFieldType fieldType)
        {
            if (_select.IsMultiple)
                return fieldType.GetValueFromStrings(_select.AllSelectedOptions.Select(o => o.GetAttribute("value")));

            return fieldType.GetValueFromString(_select.SelectedOption.GetAttribute("value"));
        }
Пример #2
0
        public object Get(IModelFieldType fieldType)
        {
            if (_select.IsMultiple)
            {
                return(fieldType.GetValueFromStrings(_select.SelectedOptions.Select(o => o.GetAttribute("value"))));
            }

            return(fieldType.GetValueFromString(_select.SelectedOptions.Single().GetAttribute("value")));
        }
Пример #3
0
        public object Get(IModelFieldType fieldType)
        {
            var values = _elements
                         .Select(e => FieldFactory.Create(new[] { e }).Get(new ModelFieldType(fieldType.BaseType, fieldType.Format)))
                         .Where(e => e != null)
                         .ToArray();

            if (fieldType.IsFlagsEnum)
            {
                if (values.Length == 1)
                {
                    return(values.First());
                }
                return(fieldType.GetValueFromStrings(values.Select(v => v.ToString())));
            }

            if (fieldType.IsEnumerable)
            {
                return(fieldType.Cast(values));
            }

            return(values.FirstOrDefault() ?? fieldType.DefaultValue);
        }