using System;

using System.Reflection;

using System.Text;

 

namespace Attribute01

{

class
Program

{

static
void Main(string[] args)

{

Type type = typeof(Test);

foreach (CodeReviewAttribute att in

type.GetCustomAttributes(typeof(CodeReviewAttribute), false))

{

Console.WriteLine("Reviewer: {0}", att.Reviewer);

Console.WriteLine("Date:{0}", att.Date);

Console.WriteLine("Comment: {0}", att.Comment);

}

 

Console.ReadLine();

}

}

//目标定位于class

[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]

public
class
CodeReviewAttribute : System.Attribute

{

private
string reviewer;

private
string date;

private
string comment;

 

public CodeReviewAttribute(string reviewer, string date)

{

this.reviewer = reviewer;

this.date = date;

}

 

public
string Comment

{

get { return (comment); }

set { this.comment = value; }

 

}

 

public
string Date

{

get { return
this.date; }

set { this.date = value; }

}

 

public
string Reviewer

{

get { return
this.reviewer; }

set { this.reviewer = value; }

}

}

 

 

[CodeReview("PSM", "2013-09-07", Comment="BUG Fixed 3055")]

[CodeReview("GJH", "2013-09-08", Comment = "BUG Fixed 2088")]

class
Test

{

}

}

Attributes(1):反射Attribute并输出的更多相关文章

  1. C# 特性Attributes 和反射

    一,Attributes 类新建一个子类,DetailAttributes 二, 在类的属性声明上面加Attributes public class testAttributes { [Detail( ...

  2. C# Asp.net中的AOP框架 Microsoft.CCI, Mono.Cecil, Typemock Open-AOP API, PostSharp -摘自网络 (可以利用反射 Attribute 进行面向切面编程 可以用在记录整个方法的Log方面)

    Both Microsoft.CCI and Mono.Cecil are low-level, and don't validate produced assemblies. It takes lo ...

  3. 指定HTML标签属性 |Specifying HTML Attributes| 在视图中生成输出URL |高级路由特性 | 精通ASP-NET-MVC-5-弗瑞曼

    结果呢: <a class="myCSSClass" href="/" id="myAnchorID">This is an o ...

  4. [C#] C# 知识回顾 - 特性 Attribute

    C# 知识回顾 - 特性 Attribute [博主]反骨仔 [原文地址]http://www.cnblogs.com/liqingwen/p/5911289.html 目录 特性简介 使用特性 特性 ...

  5. 十七、C# 反射、特性和动态编程

    反射.特性和动态编程   1.访问元数据 2.成员调用 3.泛型上的反射 4.自定义特性 5.特性构造器 6.具名参数 7.预定义特性 8.动态编程   特性(attribute)是在一个程序集中插入 ...

  6. C#秘密武器之反射——基础篇

    先来一段有用的反射代码 namespace Calculator { public interface Iwel { String Print(); } } namespace Calculator ...

  7. C# 知识特性 Attribute

    C#知识--获取特性 Attribute 特性提供功能强大的方法,用以将元数据或声明信息与代码(程序集.类型.方法.属性等)相关联.特性与程序实体关联后,可在运行时使用"反射"查询 ...

  8. 采用dom4j和反射模拟Spring框架的依赖注入功能

    Spring的依赖注入是指将对象的创建权交给Spring框架,将对象所依赖的属性注入进来的行为.在学习了dom4j后,其实也可以利用dom4j和反射做一个小Demo模拟Spring框架的这种功能.下面 ...

  9. [C#反射]C#中的反射解析及使用.

    1.对C#反射机制的理解2.概念理解后,必须找到方法去完成,给出管理的主要语法3.最终给出实用的例子,反射出来dll中的方法 参考: C#反射,MSDN编程指南 反射是一个程序集发现及运行的过程,通过 ...

随机推荐

  1. JAVA命名、注释规范

    一.命名规范 1. 项目名全部小写 2. 包名全部小写(除非部分是缩写) 3. 类名首字母大写,如果类名由多个单词组成,每个单词的首字母都要大写. 如:public class MyFirstClas ...

  2. pgsql自动安装shell脚本整理

    前面不断在vm虚拟机上测试pgsql,发觉安装还是有些麻烦的. 所以就收集了一些 1,http://www.davidghedini.com/pg/entry/postgresql_9_5_scrip ...

  3. CSS+JS下拉菜单和纯CSS下拉菜单

    下拉菜单 (思路:先把二级定位到屏幕外,鼠标悬停重新定位回来:另一个就是ul浮动,li也浮动) 下拉菜单的一般思路就是把子导航嵌套在无序列表中,把列表定位到屏幕之外,当鼠标悬停在其父列表项上时,重新定 ...

  4. Nginx介绍 分类: Nginx 服务器搭建 2015-07-13 10:50 19人阅读 评论(0) 收藏

    海量请求,高性能服务器. 对比Apache, Apache:稳定,开源,跨平台,重量级,不支持高度并发的web服务器. 由此,出现了Lighttpd与Nignx:轻量级,高性能. 发音:engine ...

  5. JAVA中toString方法的作用(转)

    因为它是Object里面已经有了的方法,而所有类都是继承Object,所以“所有对象都有这个方法”. 它通常只是为了方便输出,比如System.out.println(xx),括号里面的“xx”如果不 ...

  6. LabVIEW设计模式系列——各种各样的状态机

  7. Java基础知识强化之网络编程笔记07:TCP之服务器给客户端一个反馈案例

    1. 首先我们搭建服务器端的代码,如下: package cn.itcast_07; import java.io.IOException; import java.io.InputStream; i ...

  8. Linux网络相关命令小结

    # ifconfig # ifup/ifdown # route -n # ip link show //显示本机所有接口信息 # traceroute # netstat //查看本机网络连接与后门 ...

  9. JSON 学习总结 <一>:什么是JSON

    JSON的相关资料和博客很多,JSON无处不用,最近项目中一直要用到JSON,今天没有加班,就写下,算是对自己的总结,对JSON又一次深入的认识. 废话不多了,直接进入今天的主题: 如题:今天就介绍下 ...

  10. css标准导航代码

    <!-- 例子解析: --> --> <!-- list-style-type:none - 移除列表前小标志.一个导航栏并不需要列表标记 --> <!-- 移除浏 ...