protected virtual Options GetOptionPairs(ElementRequest req, CheckBoxListAttribute attrib) { var optionsProperty = req.Accessor.DeclaringType.GetProperties().FirstOrDefault(p => p.Name == attrib.OptionsFrom); if (optionsProperty == null) { throw new Exception(string.Format("Could not find options source property '{0}' on type '{1}'", attrib.OptionsFrom, req.Accessor.DeclaringType.Name)); } return optionsProperty.GetGetMethod().Invoke(req.Model, null) as Options; }
protected virtual Options GetOptionPairs(ElementRequest request, CheckBoxListAttribute attribute) { var optionsProperty = request.Accessor.DeclaringType.GetProperties() .FirstOrDefault(p => p.Name == attribute.OptionsFrom); if (optionsProperty == null) { var message = string.Format("Could not find options source property '{0}' on type '{1}'", attribute.OptionsFrom, request.Accessor.DeclaringType.Name); throw new Exception(message); } return(optionsProperty.GetGetMethod().Invoke(request.Model, null) as Options); }