zoukankan      html  css  js  c++  java
  • C# Attribute-特性

    Type t = typeof(TestAttribute);
    
                object[] attributes = t.GetCustomAttributes(false);
    
                foreach (var attr in attributes)
                {
                    if (attr.GetType() == typeof(LogInfoAttribute))
                    {
                        LogInfoAttribute att = (LogInfoAttribute)attr;
                        Console.WriteLine(String.Format("LogInfoType:{0},,OperatorName:{1},,OperatorDateTime:{2},,Mark:{3}", att.LogInfoType, att.OperatorName, att.OperatorDateTime, att.Mark));
                    }
                }
    
                Console.WriteLine("=================================");
    
                MemberInfo[] members = t.GetMethods();
                foreach (var member in members)
                {
                    if (member.IsDefined(typeof(LogInfoAttribute), false))
                    {
                        Console.WriteLine(member.Name + "Attribute start..................");
                        object[] attrs = member.GetCustomAttributes(false);
                        foreach (var attr in attrs)
                        {
                            if (attr.GetType() == typeof(LogInfoAttribute))
                            {
                                LogInfoAttribute att = (LogInfoAttribute)attr;
                                Console.WriteLine(String.Format("LogInfoType:{0},,OperatorName:{1},,OperatorDateTime:{2},,Mark:{3}", att.LogInfoType, att.OperatorName, att.OperatorDateTime, att.Mark));
                            }
                        }
                        Console.WriteLine(member.Name + "Attribute end..................");
                    }
                }
  • 相关阅读:
    OpenCV 使用FLANN进行特征点匹配
    OpenCV 特征描述
    OpenCV 特征点检测
    OpenCV 亚像素级的角点检测
    OpenCV Shi-Tomasi角点检测子
    OpenCV Harris 角点检测子
    OpenCV 模板匹配
    OpenCV 直方图计算
    OpenCV 直方图均衡化
    OpenCV 仿射变换
  • 原文地址:https://www.cnblogs.com/liuwentian/p/3213716.html
Copyright © 2011-2022 走看看