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..................");
                    }
                }
  • 相关阅读:
    Centos7.2安装MariaDB数据库,并进行基础配置
    Web安全之环境搭建
    PHP构建一句话木马
    Spark2.1.0安装
    Spark2.1.0编译
    cdh-5.10.0搭建安装
    八、频繁模式挖掘Frequent Pattern Mining
    七、特征提取和转换
    六、降维
    五、聚类
  • 原文地址:https://www.cnblogs.com/liuwentian/p/3213716.html
Copyright © 2011-2022 走看看