validationruleargs.cs

来自「改程序能够查询课程表」· CS 代码 · 共 85 行

CS
85
字号
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization;

namespace Common.Utility.Validation
{
   /// <summary>
   /// Object that provides additional information about an validation rule.
   /// </summary>
   public class ValidationRuleArgs
   {
    	private string _propertyName;
      	private string _description;
		private object _tag;
		private string _friendlyName;

		/// <summary>
		/// Gets or sets the tag.
		/// </summary>
		/// <value>The tag.</value>
		[XmlIgnore]
		public object Tag
		{
			get { return _tag; }
			set { _tag = value; }
		}
		
		/// <summary>
		/// The name of the property to be validated.
		/// </summary>
		public string PropertyName
		{
			get { return _propertyName; }
		}
	
		/// <summary>
		/// Detailed description of why the rule was invalidated.  This should be set from the method handling the rule.
		/// </summary>
		public string Description
		{
			get { return _description; }
			set { _description = value; }
		}

		/// <summary>
		/// Friendly name to use in the validation error text.
		/// </summary>
		public string FriendlyName
		{
			get { return _friendlyName; }
			set { _friendlyName = value; }
		}
		
		/// <summary>
		/// Creates an instance of the object
		/// </summary>
		/// <param name="propertyName">The name of the property to be validated.</param>
		public ValidationRuleArgs(string propertyName)
		{
			_propertyName = propertyName;
			_friendlyName = propertyName;
		}

		/// <summary>
		/// Creates an instance of the object
		/// </summary>
		/// <param name="propertyName">The name of the property to be validated.</param>
		/// <param name="friendlyName">Friendly name to use in the validation error text.</param>
		public ValidationRuleArgs(string propertyName, string friendlyName)
		{
			_propertyName = propertyName;
			_friendlyName = friendlyName;
		}
		
		/// <summary>
		/// Return a string representation of the object.
		/// </summary>
		public override string ToString()
		{
			return _propertyName;
		}
   }
}

⌨️ 快捷键说明

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