我有枚举
public enum RequisiteTypeEnum : long
{
LegalStatus = 1,
LegalName = 2,
Citizenship = 3,
PersonalIdentification = 4,
LegalAddress = 5,
PhysicalAddress = 6,
Phone = 7,
Email = 8,
BankName = 9,
BankAccountNumber = 10,
SigningPersonFullName = 11,
SigningPersonIdentification = 12,
SigningPersonStatus = 13,
SignatureUpload = 14,
CompanyStampUpload = 15,
CompanyLogoUpload = 16,
ForeignLanguageAdd = 17
}
是这种类型,我从base获得数据,每个base具有字符串值。名称几乎相同,使用相同的名称不会有问题。我用手将它们像一对一地映射。像
requiziteList.SelectedRequisitePairLists.AddRange(new List<SelectedRequisites> {
new SelectedRequisites(RequisiteTypeEnum.LegalAddress , chosenRequisite.LegalAddress),
new SelectedRequisites(RequisiteTypeEnum.BankAccountNumber , chosenRequisite.BankAccountNumber),
new SelectedRequisites(RequisiteTypeEnum.BankName , chosenRequisite.ServingBankName),
new SelectedRequisites(RequisiteTypeEnum.Citizenship , chosenRequisite.Citizenship),
new SelectedRequisites(RequisiteTypeEnum.CompanyLogoUpload , chosenRequisite.CompanyLogoUpload),
new SelectedRequisites(RequisiteTypeEnum.CompanyStampUpload , chosenRequisite.CompanyStampUpload),
new SelectedRequisites(RequisiteTypeEnum.Email , chosenRequisite.Email),
new SelectedRequisites(RequisiteTypeEnum.LegalStatus , EnumExtentions.TranslateEnum(chosenRequisite.Legal)),
new SelectedRequisites(RequisiteTypeEnum.LegalName , string.Format("{0} {1}",chosenRequisite.FirstName,chosenRequisite.LastName)),
new SelectedRequisites(RequisiteTypeEnum.PersonalIdentification , chosenRequisite.IdentificationNumber),
new SelectedRequisites(RequisiteTypeEnum.Phone , chosenRequisite.PhoneNumber),
new SelectedRequisites(RequisiteTypeEnum.PhysicalAddress , chosenRequisite.ActualAddress),
new SelectedRequisites(RequisiteTypeEnum.SignatureUpload , chosenRequisite.SignatureUpload),
new SelectedRequisites(RequisiteTypeEnum.SigningPersonIdentification , chosenRequisite.SignaturerIdentificationNumber),
new SelectedRequisites(RequisiteTypeEnum.SigningPersonFullName ,string.Format("{0} {1}",chosenRequisite.SignaturerFirstName,chosenRequisite.SignaturerLastName)),
new SelectedRequisites(RequisiteTypeEnum.SigningPersonStatus ,chosenRequisite.SignaturerStatus)
}
但是我想使其更简单。有什么解决方案来映射它们吗?