using System.Runtime.Serialization;

namespace BS.Shared.DataContracts
{
	[DataContract]
	public class BeWoMobilBrowserInfoDC : IDataContract
	{
		[DataMember]
		public long? BeWoMobilBrowserInfoOid { get; set; }

		[DataMember]
		public string Type { get; set; }

		[DataMember]
		public string Name { get; set; }

		[DataMember]
		public string BrowserVersion { get; set; }

		[DataMember]
		public string Platform { get; set; }

		[DataMember]
		public string Tenant { get; set; }

		public override bool Equals(object obj)
		{
			if (obj is BeWoMobilBrowserInfoDC)
			{
				var y = (BeWoMobilBrowserInfoDC) obj;

				if (BeWoMobilBrowserInfoOid == null && y.BeWoMobilBrowserInfoOid == null)
					return GetHashCode() == y.GetHashCode();

				if (BeWoMobilBrowserInfoOid != null && y.BeWoMobilBrowserInfoOid != null)
					return BeWoMobilBrowserInfoOid == y.BeWoMobilBrowserInfoOid;

				if (Type == y.Type &&
				    Name == y.Name &&
				    BrowserVersion == y.BrowserVersion &&
				    Platform == y.Platform &&
				    Tenant == y.Tenant)
					return true;
			}

			return false;
		}

		public override int GetHashCode()
		{
			return BeWoMobilBrowserInfoOid.HasValue
				? GetType().Name.GetHashCode() ^ BeWoMobilBrowserInfoOid.GetHashCode()
				: base.GetHashCode();
		}
	}
}
