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

namespace QC.CompareTestTree;

[XmlType(AnonymousType = true)]
public class TestResultsConfig
{
	private string plugInNameField;

	private string[] stringField;

	private string[] plugInConfigNamesField;

	public string PlugInName
	{
		get
		{
			return plugInNameField;
		}
		set
		{
			plugInNameField = value;
		}
	}

	[XmlElement("string")]
	public string[] @string
	{
		get
		{
			return stringField;
		}
		set
		{
			stringField = value;
		}
	}

	[XmlElement("PlugInConfigNames")]
	public string[] PlugInConfigNames
	{
		get
		{
			return plugInConfigNamesField;
		}
		set
		{
			plugInConfigNamesField = value;
		}
	}

	public virtual void CompareTestResultsConfig(string xmlTagName, TestResultsConfig baseTestResultsConfig, string overrideAttrib, ref XmlDocument xmlDoc, ref XmlElement parentNode)
	{
		XmlElement xmlElement = xmlDoc.CreateElement(xmlTagName);
		if (overrideAttrib != null)
		{
			xmlElement.SetAttribute("delta", overrideAttrib);
		}
		CommonFunctions.RootDoc = xmlDoc;
		CommonFunctions.ParentNode = xmlElement;
		CommonFunctions.AddElement("PlugInName", PlugInName, baseTestResultsConfig.PlugInName, overrideAttrib);
		if (baseTestResultsConfig.@string != null)
		{
			for (int i = 0; i < baseTestResultsConfig.@string.Length; i++)
			{
				int num = -1;
				if (@string != null)
				{
					for (int j = 0; j < @string.Length; j++)
					{
						if (baseTestResultsConfig.@string.GetValue(i).ToString() == @string.GetValue(j).ToString())
						{
							num = j;
							break;
						}
					}
				}
				if (num < 0)
				{
					CommonFunctions.AddElement("string", baseTestResultsConfig.@string.GetValue(i).ToString(), baseTestResultsConfig.@string.GetValue(i).ToString(), "Remove");
				}
				else
				{
					CommonFunctions.AddElement("string", @string.GetValue(num).ToString(), baseTestResultsConfig.@string.GetValue(i).ToString(), overrideAttrib);
				}
			}
		}
		if (@string != null)
		{
			for (int i = 0; i < @string.Length; i++)
			{
				int num = -1;
				if (baseTestResultsConfig.@string != null)
				{
					for (int j = 0; j < baseTestResultsConfig.@string.Length; j++)
					{
						if (@string.GetValue(i).ToString() == baseTestResultsConfig.@string.GetValue(j).ToString())
						{
							num = j;
							break;
						}
					}
				}
				if (num < 0)
				{
					CommonFunctions.AddElement("string", @string.GetValue(i).ToString(), @string.GetValue(i).ToString(), "Add");
				}
			}
		}
		if (baseTestResultsConfig.PlugInConfigNames != null)
		{
			for (int i = 0; i < baseTestResultsConfig.PlugInConfigNames.Length; i++)
			{
				int num = -1;
				if (PlugInConfigNames != null)
				{
					for (int j = 0; j < PlugInConfigNames.Length; j++)
					{
						if (baseTestResultsConfig.PlugInConfigNames.GetValue(i).ToString() == PlugInConfigNames.GetValue(j).ToString())
						{
							num = j;
						}
					}
				}
				if (num < 0)
				{
					CommonFunctions.AddElement("PlugInConfigNames", baseTestResultsConfig.PlugInConfigNames.GetValue(i).ToString(), baseTestResultsConfig.PlugInConfigNames.GetValue(i).ToString(), "Remove");
				}
				else
				{
					CommonFunctions.AddElement("PlugInConfigNames", PlugInConfigNames.GetValue(num).ToString(), baseTestResultsConfig.PlugInConfigNames.GetValue(i).ToString(), null);
				}
			}
		}
		if (PlugInConfigNames != null)
		{
			for (int i = 0; i < PlugInConfigNames.Length; i++)
			{
				int num = -1;
				if (baseTestResultsConfig.PlugInConfigNames != null)
				{
					for (int j = 0; j < baseTestResultsConfig.PlugInConfigNames.Length; j++)
					{
						if (PlugInConfigNames.GetValue(i).ToString() == baseTestResultsConfig.PlugInConfigNames.GetValue(j).ToString())
						{
							num = j;
						}
					}
				}
				if (num < 0)
				{
					CommonFunctions.AddElement("PlugInConfigNames", PlugInConfigNames.GetValue(i).ToString(), PlugInConfigNames.GetValue(i).ToString(), "Add");
				}
			}
		}
		parentNode.AppendChild(xmlElement);
	}
}
