using System;
using System.Diagnostics;
using System.Xml.Serialization;

namespace QC.QSPRLogSchema;

[Serializable]
[XmlType(AnonymousType = true)]
public class DataItem : IEquatable<DataItem>
{
	[DebuggerBrowsable(DebuggerBrowsableState.Never)]
	private string nField;

	[DebuggerBrowsable(DebuggerBrowsableState.Never)]
	private string vField;

	[XmlAttribute("N")]
	public string Name
	{
		get
		{
			return nField;
		}
		set
		{
			nField = value;
		}
	}

	[XmlAttribute("V")]
	public string Value
	{
		get
		{
			return vField;
		}
		set
		{
			vField = value;
		}
	}

	public bool ShouldSerializeName()
	{
		return !string.IsNullOrEmpty(Name);
	}

	public bool ShouldSerializeValue()
	{
		return !string.IsNullOrEmpty(Value);
	}

	public DataItem()
	{
		nField = string.Empty;
		vField = string.Empty;
	}

	public DataItem(string n, string v)
	{
		if (!string.IsNullOrEmpty(n))
		{
			nField = n;
		}
		else
		{
			nField = string.Empty;
		}
		if (!string.IsNullOrEmpty(v))
		{
			vField = v;
		}
		else
		{
			vField = string.Empty;
		}
	}

	public bool Equals(DataItem other)
	{
		if (Name == other.Name)
		{
			return Value == other.Value;
		}
		return false;
	}
}
