zoukankan      html  css  js  c++  java
  • Attribute类的使用

    为每个变量设置设置属性 "Description"

    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>
            /// 主瓣搜索终点
            /// </summary>
            [Description("PT_MBStopDeg")]
            public double MainbeamSearchStopDeg { get; set; }//   
    
            /// <summary>
            /// 上旁瓣搜索起点,相对于主瓣方向,deg
            /// </summary>
            [Description("PT_UBOffsDeg")]
            public double UBStartOffsetFromMainBeamDeg { get; set; }
            /// <summary>
            /// 上旁瓣搜索终点偏移量,相对于主瓣方向,def
            /// </summary>
            [Description("PT_SitaStepDeg")]
            public double UBEndOffsetFromMainBeamDeg { get; set; }//
    
            [Description("PT_UBOffsDeg")]
            public bool UBCorrectToEdge { get; set; }
            
           
           
        }

    通过反射读取 Description

     #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
  • 相关阅读:
    19年下半年读书清单一览
    2019-2020:时间戳
    全链路压测资料汇总——业内大厂解决方案
    个人公众号开通啦
    windows 10环境下安装Tensorflow-gpu
    如何判断安卓模拟器的型号(品牌)
    socket.io的websocket示例
    Node + Selenium使用小结
    基于SOUI开发一个简单的小工具
    国际化之Android设备支持的语种
  • 原文地址:https://www.cnblogs.com/ccjungle/p/11108640.html
Copyright © 2011-2022 走看看