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

namespace QC.CompareTestTree;

[XmlType(AnonymousType = true)]
public class ThisPCTarget
{
	private string nameField;

	private TestContainers[] testContainersField;

	private bool expandedField;

	public string Name
	{
		get
		{
			return nameField;
		}
		set
		{
			nameField = value;
		}
	}

	[XmlElement("TestContainers")]
	public TestContainers[] TestContainers
	{
		get
		{
			return testContainersField;
		}
		set
		{
			testContainersField = value;
		}
	}

	public bool Expanded
	{
		get
		{
			return expandedField;
		}
		set
		{
			expandedField = value;
		}
	}

	public void CompareQTMThisPCTarget(string xmlTagName, ThisPCTarget basePCTarget, string overrideAttrib, ref XmlDocument xmlDoc, ref XmlElement parentNode)
	{
		XmlElement parentNode2 = xmlDoc.CreateElement(xmlTagName);
		if (overrideAttrib != null)
		{
			parentNode2.SetAttribute("delta", overrideAttrib);
		}
		CommonFunctions.RootDoc = xmlDoc;
		CommonFunctions.ParentNode = parentNode2;
		CommonFunctions.AddElement("Name", Name, basePCTarget.Name, overrideAttrib);
		CommonFunctions.AddElement("Expanded", Expanded, basePCTarget.Expanded, overrideAttrib);
		if (basePCTarget.TestContainers != null)
		{
			for (int i = 0; i < basePCTarget.TestContainers.Length; i++)
			{
				TestContainers testContainers = (TestContainers)basePCTarget.TestContainers.GetValue(i);
				int num = -1;
				TestContainers testContainers2;
				if (TestContainers != null)
				{
					for (int j = 0; j < TestContainers.Length; j++)
					{
						testContainers2 = (TestContainers)TestContainers.GetValue(j);
						if (testContainers.Name == testContainers2.Name)
						{
							num = j;
							break;
						}
					}
				}
				if (num < 0)
				{
					testContainers.CompareTestContainers("TestContainers", testContainers, "Remove", ref xmlDoc, ref parentNode2);
					continue;
				}
				testContainers2 = (TestContainers)TestContainers.GetValue(num);
				testContainers2.CompareTestContainers("TestContainers", testContainers, overrideAttrib, ref xmlDoc, ref parentNode2);
			}
		}
		if (TestContainers != null)
		{
			for (int i = 0; i < TestContainers.Length; i++)
			{
				TestContainers testContainers2 = (TestContainers)TestContainers.GetValue(i);
				int num = -1;
				if (basePCTarget.TestContainers != null)
				{
					for (int j = 0; j < basePCTarget.TestContainers.Length; j++)
					{
						TestContainers testContainers = (TestContainers)basePCTarget.TestContainers.GetValue(j);
						if (testContainers2.Name == testContainers.Name)
						{
							num = j;
							break;
						}
					}
				}
				if (num < 0)
				{
					testContainers2.CompareTestContainers("TestContainers", testContainers2, "Add", ref xmlDoc, ref parentNode2);
				}
			}
		}
		parentNode.AppendChild(parentNode2);
	}
}
