コード例 #1
0
        private IEnumerable <SelectListItem> GetSelectList(TModel model)
        {
            var propertyName  = (string)FieldGenerator.Metadata.AdditionalValues[ExistsInAttribute.PropertyKey];
            var nameProperty  = (string)FieldGenerator.Metadata.AdditionalValues[ExistsInAttribute.NameKey];
            var valueProperty = (string)FieldGenerator.Metadata.AdditionalValues[ExistsInAttribute.ValueKey];

            ExistsInAttribute.ValidateListConfiguration(model, propertyName, valueProperty, nameProperty, FieldGenerator.GetFieldId());

            var listProperty = typeof(TModel).GetProperty(propertyName);
            var listValue    = (IEnumerable)listProperty.GetValue(model, null);

            return(GetSelectListUsingPropertyReflection(
                       listValue,
                       nameProperty,
                       valueProperty
                       ));
        }