using System;
using System.Collections;
using System.Runtime.Serialization;
using System.Xml;
using System.Xml.Serialization;

namespace QC.CompareTestTree;

public class LoopCondition : ISerializable
{
	internal const int MAX_NO_LIST_ENTRY = 4000;

	public const string NOT_2D_ARRAY = "";

	private const int NOT_ARRAY_PARAMETER = -2;

	private const int LOOP_ON_ALL_INDEX = -1;

	public const string LOOP_DETAILS_SEP = "@#$%";

	public const int FILE_TYPE_INDEX = 0;

	public const int FILE_NAME_INDEX = 1;

	public const int COLUMN_NAME_INDEX = 2;

	private string name;

	private string testName;

	private string paramName;

	private LoopOnTypes loopOnType = LoopOnTypes.INPUTPARAM;

	private ArrayList ListOfValues = new ArrayList();

	private string strOrigValue;

	private LoopTypes loopType;

	private string DontRunCond;

	private string testIndex;

	private int arrayIndex = -2;

	private string array2DIndex = "";

	private DataType dataType = DataType.String;

	private long scenarioID = -1L;

	private string loopDetails = "";

	private bool ignoreIntermediateResults;

	private string loopValuesFinalAsString;

	public string LoopDetails
	{
		get
		{
			return loopDetails;
		}
		set
		{
			loopDetails = value;
		}
	}

	public string LoopName
	{
		get
		{
			return name;
		}
		set
		{
			name = value;
		}
	}

	public string TestName
	{
		get
		{
			return testName;
		}
		set
		{
			testName = value;
		}
	}

	public string ParamName
	{
		get
		{
			return paramName;
		}
		set
		{
			paramName = value;
		}
	}

	public DataType DataType
	{
		get
		{
			return dataType;
		}
		set
		{
			dataType = value;
		}
	}

	public LoopTypes LoopType
	{
		get
		{
			return loopType;
		}
		set
		{
			loopType = value;
			if (strOrigValue != null)
			{
				OriginalValue = strOrigValue;
			}
		}
	}

	public LoopOnTypes LoopOnType
	{
		get
		{
			return loopOnType;
		}
		set
		{
			loopOnType = value;
		}
	}

	[XmlIgnore]
	public ArrayList LoopValues
	{
		get
		{
			return ListOfValues;
		}
		set
		{
			ListOfValues = value;
		}
	}

	public string LoopValuesAsString
	{
		get
		{
			string text = "";
			if (LoopValues.Count > 0)
			{
				for (int i = 0; i < LoopValues.Count - 1; i++)
				{
					text = string.Concat(text, LoopValues[i], ",");
				}
				text += LoopValues[LoopValues.Count - 1];
			}
			return text;
		}
		set
		{
			try
			{
				string[] array = value.Split(',');
				LoopValues.Clear();
				string[] array2 = array;
				foreach (string value2 in array2)
				{
					LoopValues.Add(value2);
				}
			}
			catch (Exception ex)
			{
				throw new Exception(ex.Message);
			}
		}
	}

	public int ArrayIndex
	{
		get
		{
			return arrayIndex;
		}
		set
		{
			arrayIndex = value;
		}
	}

	public string Array2DIndex
	{
		get
		{
			return array2DIndex;
		}
		set
		{
			array2DIndex = value;
		}
	}

	public long ScenarioID
	{
		get
		{
			return (int)scenarioID;
		}
		set
		{
			scenarioID = (int)value;
		}
	}

	public string DontRunCondition
	{
		get
		{
			return DontRunCond;
		}
		set
		{
			DontRunCond = value;
		}
	}

	public string TestIndex
	{
		get
		{
			return testIndex;
		}
		set
		{
			testIndex = value;
		}
	}

	public bool IgnoreIntermediateResults
	{
		get
		{
			return ignoreIntermediateResults;
		}
		set
		{
			ignoreIntermediateResults = value;
		}
	}

	public string OriginalValue
	{
		get
		{
			return strOrigValue;
		}
		set
		{
			strOrigValue = value;
		}
	}

	public string LoopValuesFinalAsString
	{
		get
		{
			return loopValuesFinalAsString;
		}
		set
		{
			loopValuesFinalAsString = value;
		}
	}

	public virtual void CompareLoopConditions(string XmlTagName, LoopCondition baseLoopConditions, 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("LoopName", LoopName, baseLoopConditions.LoopName, overrideAttrib);
		CommonFunctions.AddElement("TestName", TestName, baseLoopConditions.TestName, overrideAttrib);
		CommonFunctions.AddElement("ParamName", paramName, baseLoopConditions.paramName, overrideAttrib);
		CommonFunctions.AddElement("DataType", DataType.ToString(), baseLoopConditions.DataType.ToString(), overrideAttrib);
		CommonFunctions.AddElement("LoopType", LoopType.ToString(), baseLoopConditions.LoopType.ToString(), overrideAttrib);
		CommonFunctions.AddElement("LoopOnType", LoopOnType.ToString(), baseLoopConditions.LoopOnType.ToString(), overrideAttrib);
		CommonFunctions.AddElement("LoopValuesAsString", LoopValuesAsString, baseLoopConditions.LoopValuesAsString, overrideAttrib);
		CommonFunctions.AddElement("LoopValuesFinalAsString", LoopValuesFinalAsString, baseLoopConditions.LoopValuesFinalAsString, overrideAttrib);
		CommonFunctions.AddElement("ArrayIndex", ArrayIndex, baseLoopConditions.ArrayIndex, overrideAttrib);
		CommonFunctions.AddElement("ScenarioID", ScenarioID, baseLoopConditions.ScenarioID, overrideAttrib);
		CommonFunctions.AddElement("TestIndex", TestIndex, baseLoopConditions.TestIndex, overrideAttrib);
		CommonFunctions.AddElement("IgnoreIntermediateResults", IgnoreIntermediateResults, baseLoopConditions.IgnoreIntermediateResults, overrideAttrib);
		CommonFunctions.AddElement("OriginalValue", OriginalValue, baseLoopConditions.OriginalValue, overrideAttrib);
		parentNode.AppendChild(xmlElement);
	}

	public void GetObjectData(SerializationInfo info, StreamingContext context)
	{
	}
}
