private static DataTypeEnum CreateField(DataType dataType, PropertyInfo property) { var dataTypeEnum = dataType.DataTypeEnums .EmptyIfNull() .SingleOrDefault(x => x.Value == property.Name); if (dataTypeEnum == null) { dataTypeEnum = new DataTypeEnum { DataTypeEnumDescriptions = new List<DataTypeEnumDescription>(), Value = property.Name }; dataType.AddDataTypeEnum(dataTypeEnum); } return dataTypeEnum; }
private static void AddMultilingualDescription(PropertyInfo property, DataTypeEnum dataTypeEnum, DataType dataType) { foreach (var description in property.GetCustomAttributes<LanguageAttribute>()) { var enumDescription = dataTypeEnum.DataTypeEnumDescriptions .EmptyIfNull() .SingleOrDefault(x => x.CultureCode == description.Language); if (enumDescription == null) { enumDescription = new DataTypeEnumDescription { CultureCode = description.Language }; dataTypeEnum.AddDescription(enumDescription); } enumDescription.DisplayName = description.DisplayName; enumDescription.Description = description.Description ?? string.Empty; } dataType.AddDataTypeEnum(dataTypeEnum); }