protected void ProcessDropDownAttribute(FieldTemplateMetadata metadataForProperty, object container, Type containerType) { var dropdownAttribute = metadataForProperty.Attributes.OfType<DropDownListAttribute>(); if (!dropdownAttribute.Any()) { return; } var sourceProperty = dropdownAttribute.First().SourceProperty; var sourceList = (IEnumerable<SelectListItem>)containerType.InvokeMember(sourceProperty, BindingFlags.GetProperty, null, container, null); if (sourceList != null) { var selectedItem = sourceList.FirstOrDefault(i => i.Value == metadataForProperty.Model.ToString()); if (selectedItem != null) { selectedItem.Selected = true; } } dropdownAttribute.First().List = sourceList; }
protected void ProcessDropDownAttribute(FieldTemplateMetadata metadataForProperty, object container, Type containerType) { var dropdownAttribute = metadataForProperty.Attributes.OfType <DropDownListAttribute>(); if (!dropdownAttribute.Any()) { return; } var sourceProperty = dropdownAttribute.First().SourceProperty; var sourceList = (IEnumerable <SelectListItem>)containerType.InvokeMember(sourceProperty, BindingFlags.GetProperty, null, container, null); if (sourceList != null) { var selectedItem = sourceList.FirstOrDefault(i => i.Value == metadataForProperty.Model.ToString()); if (selectedItem != null) { selectedItem.Selected = true; } } dropdownAttribute.First().List = sourceList; }
protected int GetOrder(FieldTemplateMetadata metadataForProperty) { var orderAttribute = metadataForProperty.Attributes.OfType<OrderAttribute>(); return orderAttribute.Any() ? orderAttribute.First().Order : _StartOrder++; }
protected int GetOrder(FieldTemplateMetadata metadataForProperty) { var orderAttribute = metadataForProperty.Attributes.OfType <OrderAttribute>(); return(orderAttribute.Any() ? orderAttribute.First().Order : startOrder++); }