using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;

namespace GridValidation
{
	/// <summary>
	/// Single indication description.
	/// </summary>
	[AtLeastOnePropertyNotEmpty(Properties = new[] { "Code", "Text" }, ErrorMessage = "Code and Text should not be empty together!")]
	[DataContract]
	public class Item : INotifyPropertyChanged
	{
		public event PropertyChangedEventHandler PropertyChanged;
		
		private string _Id;
		private string _Code;
		private string _Text;

		public string Id
		{
			get { return _Id; }
			set
			{
				if (Id != value)
				{
					_Id = value;
					RaisePropertyChanged("Id");
				}
			}
		}

		public string Code
		{
			get { return _Code; }
			set
			{
				if (_Code != value)
				{
					_Code = value;
					RaisePropertyChanged("Code");
				}
			}
		}

		public string Text
		{
			get { return _Text; }
			set
			{
				if (_Text != value)
				{
					_Text = value;
					RaisePropertyChanged("Text");
				}
			}
		}

		protected virtual void RaisePropertyChanged(string propertyName = null)
		{
			var handler = PropertyChanged;
			if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
		}
	}
}