developerinfoattribute.cs

来自「csharp-solution,C#高效编程源码」· CS 代码 · 共 48 行

CS
48
字号
namespace CustomAttribute
{
    using System;

    /// <summary>
    ///    This class is a custom attribute that allows
    ///    the name of the developer of a class to be stored
    ///    with the metadata of that class.
    /// </summary>
   
    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Enum | AttributeTargets.Struct, AllowMultiple=true)]
    public class DeveloperInfoAttribute: System.Attribute
    {
		private string developerName;
		private string dateCreated;

		// Constructor. Developer Name is the only mandatory parameter for this attribute
        public DeveloperInfoAttribute(string developerName)
        {
            this.developerName = developerName;
        }

		// Property to return the Developer Name
		public string Developer 
		{
			get
			{
				return developerName;
			}
		}

		// Property to get and set the Creation Date 
		// (an optional parameter for this attribute)
		public string Date
		{
			get
			{
				return dateCreated;
			}

			set
			{
				dateCreated = value;
		 	}
		}
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?