private List<PreValueItem> BuildPreValues(DataTypeDefinition dataTypeDefinition) { bool allEmpty = true; var prevalues = PreValues.GetPreValues(dataTypeDefinition.DataType.DataTypeDefinitionId); if (prevalues != null && prevalues.Count > 0) { var preValueItems = new List<PreValueItem>(); foreach (DictionaryEntry item in prevalues) { var preValue = item.Value as PreValue; if (preValue != null) { var preValueItem = new PreValueItem() { Id = preValue.Id, SortOrder = preValue.SortOrder, Value = preValue.Value }; preValueItems.Add(preValueItem); if (!string.IsNullOrEmpty(preValueItem.Value)) allEmpty = false; } } if (allEmpty) return null; return preValueItems; } return null; }
private List<PreValueItem> BuildPreValues(DataTypeDefinition dataTypeDefinition) { try { bool allEmpty = true; var prevalues = PreValues.GetPreValues(dataTypeDefinition.DataType.DataTypeDefinitionId); if (prevalues != null && prevalues.Count > 0) { var preValueItems = new List<PreValueItem>(); foreach (DictionaryEntry item in prevalues) { var preValue = item.Value as PreValue; if (preValue != null) { var preValueItem = new PreValueItem() { Id = preValue.Id, SortOrder = preValue.SortOrder, Value = preValue.Value }; preValueItems.Add(preValueItem); if (!string.IsNullOrEmpty(preValueItem.Value)) allEmpty = false; } } if (allEmpty) return null; return preValueItems; } return null; } catch (Exception ex) { throw new DataTypeException(string.Format("Data type {0} '{1}' prevalues could not be loaded.", dataTypeDefinition.Id.ToString(), dataTypeDefinition.Text), ex); } }