Setting property "Description" for each variable
public class PatternOption { /// <summary> /// 方向图步长 /// </summary> [Description("PT_SitaStepDeg")] public double StepDeg { get; set; }// /// <summary> /// 垂直面的切角(phi角) /// </summary> [Description("PT_VeritalCutPlaneDeg")] public double VeritalCutPlaneDeg { get; set; } /// <summary> /// 垂直面的切角(sita角) /// </summary> [Description("PT_HorizontalCutPlaneDeg")] public double HorizontalCutPlaneDeg { get; set; } /// <summary> /// 主瓣搜索起点 /// </summary> [Description("PT_MBStartDeg")] public double MainbeamSearchStartDeg { get; set; }// /// <summary> ///Search main lobe end /// </ Summary> [the Description ( " PT_MBStopDeg " )] public Double MainbeamSearchStopDeg { GET ; SET ;} // /// <Summary> /// upper side lobe search start point, with respect to the main lobe direction , deg /// </ Summary> [the Description ( " PT_UBOffsDeg " )] public Double UBStartOffsetFromMainBeamDeg { GET ; SET ;} /// <Summary> /// main lobe direction sidelobe search end offset with respect to, DEF /// </summary> [Description("PT_SitaStepDeg")] public double UBEndOffsetFromMainBeamDeg { get; set; }// [Description("PT_UBOffsDeg")] public bool UBCorrectToEdge { get; set; } }
Description is read by reflection
#region 读取属性描述的例程, PatternOption patternOption = new PatternOption(); Type type = patternOption.GetType(); FieldInfo[] fieldInfos = type.GetFields(); foreach (FieldInfo item in fieldInfos) { DescriptionAttribute[] attributes = (DescriptionAttribute[])item.GetCustomAttributes(typeof(DescriptionAttribute), false); } #endregion