• Attributes(1):反射Attribute并输出


    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

    {

    }

    }

  • 相关阅读:
    vue mock数据设置
    vue 的全局拦截器
    vue-resource基础介绍
    快速排序
    Node 中的 stream (流)
    v8垃圾回收和js垃圾回收机制
    Node内存限制与垃圾回收
    ReactNative http网络通讯
    luogu1829 [国家集训队]Crash的数字表格
    luogu2870 [USACO07DEC]最佳牛线,黄金Best Cow Line, Gold
  • 原文地址:https://www.cnblogs.com/pengshaomin/p/3305713.html
Copyright © 2020-2023  润新知