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

namespace QC.CompareTestTree;

[XmlType(AnonymousType = true)]
public class ThePlugInConfig
{
	private byte numPlugInField;

	private AllConfig[] allConfigField;

	private TestResultsConfig[] testResultsConfigField;

	public byte NumPlugIn
	{
		get
		{
			return numPlugInField;
		}
		set
		{
			numPlugInField = value;
		}
	}

	[XmlElement("AllConfig")]
	public AllConfig[] AllConfig
	{
		get
		{
			return allConfigField;
		}
		set
		{
			allConfigField = value;
		}
	}

	[XmlElement("TestResultsConfig")]
	public TestResultsConfig[] TestResultsConfig
	{
		get
		{
			return testResultsConfigField;
		}
		set
		{
			testResultsConfigField = value;
		}
	}

	public virtual void ComparePlugInConfig(ThePlugInConfig modPlugin, ThePlugInConfig basePlugin, string overrideAttrib, ref XmlDocument xmlDoc, ref XmlElement parentNode)
	{
		TestResultsConfig testResultsConfig = null;
		TestResultsConfig testResultsConfig2 = null;
		CommonFunctions.RootDoc = xmlDoc;
		CommonFunctions.ParentNode = parentNode;
		CommonFunctions.AddElement("NumPlugIn", modPlugin.NumPlugIn, basePlugin.NumPlugIn, overrideAttrib);
		if (basePlugin.TestResultsConfig == null || modPlugin.TestResultsConfig == null)
		{
			return;
		}
		for (int i = 0; i < basePlugin.TestResultsConfig.Length; i++)
		{
			int num = -1;
			testResultsConfig = (TestResultsConfig)basePlugin.TestResultsConfig.GetValue(i);
			for (int j = 0; j < modPlugin.TestResultsConfig.Length; j++)
			{
				testResultsConfig2 = (TestResultsConfig)modPlugin.TestResultsConfig.GetValue(j);
				if (testResultsConfig.PlugInName == testResultsConfig2.PlugInName)
				{
					num = j;
					break;
				}
			}
			if (num < 0)
			{
				testResultsConfig.CompareTestResultsConfig("TestResultsConfig", testResultsConfig, "Remove", ref xmlDoc, ref parentNode);
				continue;
			}
			testResultsConfig2 = (TestResultsConfig)modPlugin.TestResultsConfig.GetValue(num);
			testResultsConfig2.CompareTestResultsConfig("TestResultsConfig", testResultsConfig, overrideAttrib, ref xmlDoc, ref parentNode);
		}
		for (int i = 0; i < modPlugin.TestResultsConfig.Length; i++)
		{
			int num = -1;
			testResultsConfig2 = (TestResultsConfig)modPlugin.TestResultsConfig.GetValue(i);
			for (int j = 0; j < basePlugin.TestResultsConfig.Length; j++)
			{
				testResultsConfig = (TestResultsConfig)basePlugin.TestResultsConfig.GetValue(j);
				if (testResultsConfig2.PlugInName == testResultsConfig.PlugInName)
				{
					num = j;
					break;
				}
			}
			if (num < 0)
			{
				testResultsConfig2.CompareTestResultsConfig("TestResultsConfig", testResultsConfig2, "Add", ref xmlDoc, ref parentNode);
			}
		}
	}
}
