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. 基于url的权限管理

    基于url权限管理流程 完成权限管理的数据模型创建. 1.     系统登陆 系统 登陆相当 于用户身份认证,用户成功,要在session中记录用户的身份信息. 操作流程: 用户进行登陆页面 输入用户 ...

  2. storm的acker机制理解

    转载请注明原创地址http://www.cnblogs.com/dongxiao-yang/p/6142356.html Storm 的拓扑有一些特殊的称为"acker"的任务,这 ...

  3. jQuery之前端国际化jQuery.i18n.properties

    jQuery.i18n.properties是一款轻量级的jQuery国际化插件,能实现Web前端的国际化. 国际化英文单词为:Internationalization,又称i18n,"i& ...

  4. CocoaPods不更新spec仓库进行install/update

    最近使用CocoaPods来添加第三方类库,无论是执行pod install还是pod update都卡在了Analyzing dependencies不动 原因在于当执行以上两个命令的时候会升级Co ...

  5. Java Development Kit(JDK) 8 新特性(简述)

    一.接口的默认方法 Java 8允许我们给接口添加一个非抽象的方法实现,只需要使用 default关键字即可,这个特征又叫做扩展方法. 示例如下: interface Formula { calcul ...

  6. ffmpeg的logo, delogo滤镜参数设置

    FFmpeg的添加logo,去logo滤镜的组合共有三种方式: 1. 只有添加logo滤镜 $ ./ffmpeg -i INPUT.FLV  \ -vf movie=/opt/logo.png[log ...

  7. 笔记本开了WIFI之后只能上QQ,上不了网页的解决方法

    前几天拉了宽带之后,开了WIFI,发现WIFI能上网,但是电脑就上不了网页. 把本地连接的DNS指定一下,(电信)指定为202.102.192.68

  8. [Webpack 2] Chunking common modules from multiple apps with the Webpack CommonsChunkPlugin

    If you have a multi-page application (as opposed to a single page app), you’re likely sharing module ...

  9. IE8下网页中的视频会遮挡住顶层DIV的解决办法

    在IE8浏览器下,发现网页中的视频会遮挡住本来固定在最顶层的DIV.即便使用z-index也无法解决.但是其他浏览器是正常的. 解决的办法很简单,就是在调用flash视频播放器的时候,加上一个参数“o ...

  10. webrtc学习———记录二:canvas学习

    参考资料: http://bucephalus.org/text/CanvasHandbook/CanvasHandbook.html#getcontext2d https://developer.m ...