/// <summary> /// 读取类配置 /// </summary> /// <param name="type"></param> /// <returns></returns> public ClassUpgradeConfig GetEnumConfig(Type type) { ClassUpgradeConfig config = new ClassUpgradeConfig { Name = type.Name, ConfigType = type, TypeName = type.GetTypeName(), BaseType = type.BaseType.GetTypeName(), IsDataAttribute = type.GetCustomAttribute(typeof(DataContractAttribute)) != null, IsJsonAttribute = type.GetCustomAttribute(typeof(JsonObjectAttribute)) != null }; GetInfo(config, type); foreach (var name in type.GetEnumNames()) { var field = new FieldUpgradeConfig { Name = name, }; var member = HelpXml.FirstOrDefault(p => p.Name == type.FullName + "." + name); if (member != null) { field.Description = member.Summary; field.Caption = member.DisplayName; field.Description = member.Remark ?? member.Summary; } config.Fields.Add(name, field); } return(config); }
private FieldUpgradeConfig GetConfig(Type type, FieldInfo field) { FieldUpgradeConfig config = new FieldUpgradeConfig { Name = field.Name, ConfigType = field.FieldType, TypeName = field.FieldType.GetTypeName(), IsDataAttribute = field.GetCustomAttribute(typeof(DataMemberAttribute)) != null, }; var json = field.GetCustomAttribute <JsonPropertyAttribute>(); if (json != null) { config.IsJsonAttribute = true; config.JsonName = !string.IsNullOrWhiteSpace(json.PropertyName) ? json.PropertyName : config.Name; } GetInfo(config, type, field); return(config); }