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. Android——Cocosd2d-x手机游戏开发学习思路

    手机APP应用如雨后春笋般冒了出来,而在众多的APP应用中,游戏占据了半壁江山.它丰富着人们的业余生活,增进了人们之间的沟通交流.也有许多开发的朋友对游戏开发情有独钟,他们不止是享受着有很多的人们去下 ...

  2. 380. Insert Delete GetRandom O(1)

    经过昨天的消沉 今天我振作了 设计个数据结构,添加,删除,随机获取都是O(1). 怎么会有这么牛逼的数据结构,所以肯定相应的要耗费空间. 添加和获取耗时O(1)是Array的特性,或者说是Map/Ta ...

  3. ==和equals()的用法

    先看一段代码: public class TestEqual{ public static void main(String [ ] args){ //基本类型比较 int a = 100; int ...

  4. 仿写自己的一个加载语言包的L函数

    <?php /** * [L 加载语言的L的方法] * @param [string] $key [语言键的名称] * @return [string] $value [取到的语言值] */ f ...

  5. 3proxy代理软件文档说明

    官方英文原版说明:http://www.3proxy.ru/howtoe.asp 配置文件的简要说明:如果你的英文理解力好,可以试着研究一下他的手册. 以实例说明吧 nscache 65536域名解析 ...

  6. Python中的判断、循环 if...else,while

    if...else语句: a=3; b=3; if a == b :print(a,b)elif a <= b :print(str(a) + " is less than " ...

  7. java代理

    首先,java中为什么要提出代理的设计模式呢?代理模式的作用是:为其它对象提供一种代理以控制对这个对象的訪问.在某些情况下,一个客户不想或者不能直接引用还有一个对象,而代理对象能够在client和目标 ...

  8. resin 4.0数据源的配置

    在resin 的conf 文件下有resin.xml  我们在这里能够配置数据源以及配置项目 一.配置多个数据源,多个项目共享这些数据源.也就是这些数据源配置在<host>   </ ...

  9. 通过开发工具发布web应用到tomcat服务器中--对于小白,大神可以忽略不看,勿喷,谢谢

    需要的工具 MyEclipse和TomCat 本人用的是MyEclipse2014和TomCat7 TomCat结构图 第一步:在MyEclipse中配置TomCat 如图所示: 第二步:创建Web项 ...

  10. RHEL7单独安装图形X11

    RHEL7 默认是最小化安装(Minimal Install),没有图形界面,我们应该选择Server with GUI.若已错过此步骤,我们采用以下方式补充安装GUI界面. # yum group ...