internal ConfigurationOptionDescriptor(ConfigurationOptionAttribute configOption, IEnumerable <CustomMetadataAttribute> customMetadata, string keyName) { this.Default = configOption.Default; this.Type = configOption.Default.GetType(); this.Unset = configOption.Unset; this.DisplayName = configOption.DisplayName; this.Description = configOption.Description; this.PathType = configOption.PathType; this.Simple = configOption.Simple; this.Private = configOption.Private; this.Flag = configOption.Flag; this.Max = configOption.Max; this.Min = configOption.Min; this.CustomMetadata = customMetadata.ToDictionary(m => m.Key, m => m.Value); this.Increment = configOption.Increment; this.OptionName = configOption.OptionName; this.OptionKey = keyName; this.OptionType = ConfigurationOptionDescriptor.GetOptionType(this.Type, this.IsPath); this.IsSelection = this.OptionType == ConfigurationOptionType.Selection; this.SelectionOptions = this.IsSelection ? NonGenericEnums.GetMembers(this.Type) .Select(m => new SelectionOptionDescriptor(m)) .ToList() : Enumerable.Empty <ISelectionOptionDescriptor>(); }
private static IEnumerable <JProperty> SerializeEnumValues(Type selectionEnum) { return(from enumOption in NonGenericEnums.GetMembers(selectionEnum) where enumOption.Attributes.Has <SelectionOptionAttribute>() let attribute = enumOption.Attributes.Get <SelectionOptionAttribute>() select new JProperty(enumOption.Name, new JObject() { { nameof(attribute.DisplayName), attribute.DisplayName ?? enumOption.Name }, { nameof(attribute.Private), attribute.Private }, })); }
/// <summary> /// 获取枚举的显示名称 /// </summary> /// <typeparam name="TEnum">枚举</typeparam> /// <param name="type">枚举值</param> /// <returns></returns> public static List <EnumKeyValue> GetEnumList <TEnum>(this TEnum type) where TEnum : struct { List <EnumKeyValue> list = new List <EnumKeyValue>(); if (!(type is Enum)) { return(list); } var values = NonGenericEnums.GetMembers(type.GetType()); foreach (EnumMember value in values) { var dis = value.Attributes.Get(typeof(DisplayNameAttribute)) as DisplayNameAttribute; var des = value.Attributes.Get(typeof(DescriptionAttribute)) as DescriptionAttribute; EnumKeyValue keyValue = new EnumKeyValue(); keyValue.Value = value.ToInt32(); keyValue.DisplayName = dis == null ? "" : dis.DisplayName; keyValue.Description = des == null ? "" : des.Description; list.Add(keyValue); } return(list); }
static EntityGenerator() { var sharedEnumTypes = new[] { typeof(YOrN), typeof(YNOrNA), typeof(YesOrNo), typeof(YesNoOrNA), typeof(TrueOrFalse), typeof(AcceptOrReject), typeof(IncreasedOrDecreased), typeof(UtilitiesDescription), typeof(TermType), typeof(SignedByTyp), typeof(TotalClosingCostRemark), typeof(PartyType), typeof(AUS), typeof(AUSRecommendation), typeof(BankruptcyForeclosureStatus), typeof(LicenseAuthType), typeof(BorContingentLiabilitiesLiabilityDescription), typeof(BorrowerType), typeof(ClosingCostFundsType), typeof(FundsTypeDescription), typeof(ClosingCostSourceType), typeof(SourceTypeDescription), typeof(DocsLoanProgramType), typeof(ServicingType), typeof(CorrespondentOptionDesc), typeof(CreditChargeType), typeof(DenialReason), typeof(DisclosureMethod), typeof(DownPaymentSourceType), typeof(YNOrOther), typeof(Hud1EsPayToFeeType), typeof(RefundableType), typeof(RecSamePtyTypeDesc), typeof(FeddieBorrowerAlienStatus), typeof(FreddieDownPaymentType), typeof(FullPrepaymentPenaltyOptionType), typeof(ATRQMStatus), typeof(ImpoundType), typeof(ClosingCostImpoundType), typeof(ImpoundWaived), typeof(IncludeOriginationPointsCreditType), typeof(InformationTypesWeCollect), typeof(ProjectType), typeof(MonthOrYear), typeof(CanGoOrGoes), typeof(OrgTyp), typeof(IsOrIsNot), typeof(LimitSharing), typeof(ScsrsClaus), typeof(CanIncreaseOrIncreases), typeof(LoanAmountType), typeof(LoanDocumentationType), typeof(LoanPurposeType), typeof(LoanType), typeof(RefinancePurpose), typeof(PropertyType), typeof(LienType), typeof(DoesOrDoesNot), typeof(DoesOrDoesNot2), typeof(OpenBankruptcy), typeof(InterestRateImpactedStatus), typeof(FeePaidBy), typeof(Owner), typeof(PaidBy), typeof(PaidType), typeof(PenaltyTerm), typeof(OccupancyIntent), typeof(PrepaymentPenaltyBasedOn), typeof(PropertyUsageType), typeof(PTB), typeof(DaysInYear), typeof(TypeOfPurchaser), typeof(RiskClassification), typeof(RoundingMethod), typeof(SignatureType), typeof(FinalSignatureType), typeof(SofDBorrowerAddressType), typeof(TimesToCollect), typeof(TrstSamePtyTypDesc), typeof(ProfitManagementItemType), typeof(UCDPayoffType), typeof(UlddBorrowerType), typeof(VestingTrusteeOfType), typeof(WholePocPaidByType), typeof(AmortizationType), typeof(ApplicationTakenMethodType), typeof(OtherPropertyType), typeof(RiskAssessmentType), typeof(ActionTaken), typeof(IndexMargin), typeof(PropertyFormType) }; s_sharedEnums = new Dictionary <string, HashSet <string> >(); foreach (var sharedEnumType in sharedEnumTypes) { s_sharedEnums.Add(sharedEnumType.Name, new HashSet <string>(NonGenericEnums.GetMembers(sharedEnumType).Select(m => m.AsString(EnumFormat.EnumMemberValue, EnumFormat.Name)))); } }