using System;
using System.ComponentModel;
using System.Text;
using System.Xml.Serialization;

namespace QC.QSPRTreeSchemaLibrary;

[Serializable]
[XmlInclude(typeof(ScenarioCondition))]
[XmlInclude(typeof(TestPostCondition))]
[XmlInclude(typeof(TestPreCondition))]
public class BaseCondition
{
	public const int ANY_PARAM_INDEX = -2;

	public const int ALL_PARAM_INDEX = -1;

	public const int NO_PARAM_INDEX = -3;

	protected ConditionType testConditionType = ConditionType.None;

	protected string baseConditionName = "";

	protected string parameterName = "";

	private string globalVariableName = "";

	private string globalVariableValue = "";

	private ConditionSign globalVariableSign;

	protected ConditionSign parameterSign;

	protected string parameterValue = "";

	protected TestResult result;

	protected int parameterIndex = -3;

	protected string gvToCompareName = "";

	protected CompareType compareToType;

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

	[DefaultValue("")]
	public string GlobalVariableName
	{
		get
		{
			return globalVariableName;
		}
		set
		{
			globalVariableName = value;
		}
	}

	[DefaultValue("")]
	public string GlobalVariableValue
	{
		get
		{
			return globalVariableValue.Trim();
		}
		set
		{
			globalVariableValue = value;
		}
	}

	public ConditionSign GlobalVariableSign
	{
		get
		{
			return globalVariableSign;
		}
		set
		{
			globalVariableSign = value;
		}
	}

	public ConditionType TestConditionType
	{
		get
		{
			return testConditionType;
		}
		set
		{
			testConditionType = value;
		}
	}

	[DefaultValue("")]
	public string ParameterName
	{
		get
		{
			return parameterName;
		}
		set
		{
			parameterName = value;
		}
	}

	public ConditionSign ParameterSign
	{
		get
		{
			return parameterSign;
		}
		set
		{
			parameterSign = value;
		}
	}

	public string ParameterValue
	{
		get
		{
			return parameterValue.Trim();
		}
		set
		{
			parameterValue = value;
		}
	}

	[DefaultValue("")]
	public string GVToCompareName
	{
		get
		{
			return gvToCompareName.Trim();
		}
		set
		{
			gvToCompareName = value;
		}
	}

	public CompareType CompareToType
	{
		get
		{
			return compareToType;
		}
		set
		{
			compareToType = value;
		}
	}

	public virtual string ConditionString
	{
		get
		{
			new StringBuilder();
			return testConditionType switch
			{
				ConditionType.GlobalVariables => "Global Variable Condition", 
				ConditionType.TestParameters => "Test Parameters Condition", 
				ConditionType.TestResult => "Test Result Condition", 
				_ => "", 
			};
		}
	}

	public TestResult Result
	{
		get
		{
			return result;
		}
		set
		{
			result = value;
		}
	}

	public virtual bool IsValid
	{
		get
		{
			bool flag = false;
			try
			{
				switch (testConditionType)
				{
				case ConditionType.TestParameters:
					flag = parameterName.Trim().Length != 0 && ((CompareToType != CompareType.GlobalVariable || !(GVToCompareName == "")) ? true : false);
					break;
				case ConditionType.TestResult:
					flag = true;
					break;
				case ConditionType.GlobalVariables:
					flag = globalVariableName.Trim().Length != 0 && (CompareToType == CompareType.Constant || CompareToType == CompareType.GlobalVariable) && ((CompareToType != CompareType.GlobalVariable || !(GVToCompareName == "")) ? true : false);
					break;
				}
			}
			catch
			{
			}
			return flag;
		}
	}

	public int ParameterIndex
	{
		get
		{
			return parameterIndex;
		}
		set
		{
			parameterIndex = value;
		}
	}
}
