private void BindSizeRepeater(int pictureID) { List <String> urls = PictureManager.GetPictureUrls(pictureID); repeaterPictureSizes.DataSource = urls; repeaterPictureSizes.DataBind(); }
protected virtual void GetPictureUrls <T>(T model) where T : class { if (model == null) { return; } var type = typeof(T); var specialProperties = type.GetRuntimeProperties() .Where(pi => pi.PropertyType == typeof(string) && pi.GetCustomAttributes <PictureUrlAttribute>(true).Any()) .ToList(); if (!specialProperties.HasData()) { return; } foreach (var specialProperty in specialProperties) { var pInfo = typeof(T).GetProperty(specialProperty.Name) .GetCustomAttribute <PictureUrlAttribute>(); var idProperty = pInfo.From.IsNotNullOrEmpty() ? typeof(T).GetProperty(pInfo.From) : null; int size = pInfo.Size; if (idProperty != null) { var idPropertyValue = idProperty.GetValue(model); if (idPropertyValue != null) { if (idProperty.PropertyType == typeof(int)) { specialProperty.SetValue(model, PictureManager.GetPictureUrl((int)idPropertyValue, size)); } else { specialProperty.SetValue(model, PictureManager.GetPictureUrls((string)idPropertyValue, size)); } } } } }