using System;
using System.Collections;
using System.Collections.Generic;
using QC.QTMInterface;

namespace QC.QTMDotNetKernelInterface;

[Obsolete("This static class/method is obsolete, use QSPREnvironment instance to access this instead.")]
public class GlobalVariable : MarshalByRefObject
{
	[Obsolete("This static class/method is obsolete, use QSPREnvironment instance to access this instead.")]
	public static Hashtable gVariables = new Hashtable();

	[Obsolete("This static class/method is obsolete, use QSPREnvironment instance to access this instead.")]
	public static Hashtable gVariablesForSn = new Hashtable();

	[Obsolete("This static class/method is obsolete, use QSPREnvironment instance to access this instead.")]
	public static Hashtable gVariableObject = new Hashtable();

	private static bool eventsSetup = false;

	[Obsolete("This static class/method is obsolete, use QSPREnvironment instance to access this instead.")]
	public static Hashtable GVariables
	{
		get
		{
			return StaticMapper.GetGlobalVariableObject().GVariables;
		}
		set
		{
			StaticMapper.GetGlobalVariableObject().GVariables = value;
			OnGVChange(new GlobalVariableEventArgs());
		}
	}

	[Obsolete("This static class/method is obsolete, use QSPREnvironment instance to access this instead.")]
	public static ArrayList SortedGVNames => StaticMapper.GetGlobalVariableObject().SortedGVNames;

	[Obsolete("This static class/method is obsolete, use QSPREnvironment instance to access this instead.")]
	public static event GlobalVariablesChangedDelegate OnGlobalVariableChange;

	[Obsolete("This static class/method is obsolete, use QSPREnvironment instance to access this instead.")]
	public static event TesterConfigChangedDelegate OnTesterConfigChange;

	[Obsolete("This static class/method is obsolete, use QSPREnvironment instance to access this instead.")]
	public void valueSetup(Hashtable GVariables, Hashtable GVariablesForSn, Hashtable GVariableObject)
	{
		StaticMapper.GetGlobalVariableObject().GVariables = GVariables;
		StaticMapper.GetGlobalVariableObject().gVariablesForSn = GVariablesForSn;
		StaticMapper.GetGlobalVariableObject().gVariableObject = GVariableObject;
	}

	public static Hashtable GetGVariablesById(string id)
	{
		return StaticMapper.GetGlobalVariableObject(id).GVariables;
	}

	[Obsolete("This static class/method is obsolete, use QSPREnvironment instance to access this instead.")]
	public static void Clear()
	{
		StaticMapper.GetGlobalVariableObject().Clear();
	}

	[Obsolete("This static class/method is obsolete, use QSPREnvironment instance to access this instead.")]
	public static bool SetGlobalVariableObject(string gvName, object gvValue)
	{
		StaticMapper.GetGlobalVariableObject().SetGlobalVariableObject(gvName, gvValue);
		return true;
	}

	[Obsolete("This static class/method is obsolete, use QSPREnvironment instance to access this instead.")]
	public static bool GetGlobalVariableObject(string gvName, out object gvValue)
	{
		return StaticMapper.GetGlobalVariableObject().GetGlobalVariableObject(gvName, out gvValue);
	}

	[Obsolete("This static class/method is obsolete, use QSPREnvironment instance to access this instead.")]
	public static bool SetTesterConfigValue(string name, string value, bool addToSessionData)
	{
		return StaticMapper.GetGlobalVariableObject().SetTesterConfigValue(name, value, addToSessionData);
	}

	[Obsolete("This static class/method is obsolete, use QSPREnvironment instance to access this instead.")]
	public static bool SetTesterConfigValue(TesterConfigurationInfo configValue)
	{
		return StaticMapper.GetGlobalVariableObject().SetTesterConfigValue(configValue);
	}

	[Obsolete("This static class/method is obsolete, use QSPREnvironment instance to access this instead.")]
	public static bool SetTesterConfigValues(List<TesterConfigurationInfo> configValues)
	{
		return StaticMapper.GetGlobalVariableObject().SetTesterConfigValues(configValues);
	}

	[Obsolete("This static class/method is obsolete, use QSPREnvironment instance to access this instead.")]
	public static bool SetGlobalVariable(string gvName, string gvValue)
	{
		return StaticMapper.GetGlobalVariableObject().SetGlobalVariable(gvName, gvValue);
	}

	[Obsolete("This static class/method is obsolete, use QSPREnvironment instance to access this instead.")]
	public static bool SetGlobalVariable(string gvName, string gvValue, string id)
	{
		return StaticMapper.GetGlobalVariableObject(id).SetGlobalVariable(gvName, gvValue);
	}

	[Obsolete("This static class/method is obsolete, use QSPREnvironment instance to access this instead.")]
	public static bool GetGlobalVariable(string gvName, out string gvValue)
	{
		return StaticMapper.GetGlobalVariableObject().GetGlobalVariable(gvName, out gvValue);
	}

	[Obsolete("This static class/method is obsolete, use QSPREnvironment instance to access this instead.")]
	public static bool GetGlobalVariable(string gvName, out string gvValue, string id)
	{
		return StaticMapper.GetGlobalVariableObject(id).GetGlobalVariable(gvName, out gvValue);
	}

	[Obsolete("This static class/method is obsolete, use QSPREnvironment instance to access this instead.")]
	public static bool GetGlobalVariableForSN(string SN, string gvName, out string gvValue)
	{
		return StaticMapper.GetGlobalVariableObject().GetGlobalVariableForSN(SN, gvName, out gvValue);
	}

	[Obsolete("This static class/method is obsolete, use QSPREnvironment instance to access this instead.")]
	public static bool GetGlobalVariableForSN(string SN, string gvName, out string gvValue, string id)
	{
		return StaticMapper.GetGlobalVariableObject(id).GetGlobalVariableForSN(SN, gvName, out gvValue);
	}

	[Obsolete("This static class/method is obsolete, use QSPREnvironment instance to access this instead.")]
	public static bool Contains(string gvName)
	{
		return StaticMapper.GetGlobalVariableObject().Contains(gvName);
	}

	[Obsolete("This static class/method is obsolete, use QSPREnvironment instance to access this instead.")]
	public static bool Contains(string gvName, string id)
	{
		return StaticMapper.GetGlobalVariableObject(id).Contains(gvName);
	}

	private static void OnGVChange(GlobalVariableEventArgs e)
	{
		StaticMapper.GetGlobalVariableObject().OnGVChange(e);
	}

	private static void OnConfigChange(TesterConfigEventArgs e)
	{
		StaticMapper.GetGlobalVariableObject().OnConfigChange(e);
	}

	private static bool ParseSerialNumber(string strSerialNumber, out Hashtable hashUUT_SN)
	{
		return ParseSerialNumber(strSerialNumber, out hashUUT_SN);
	}

	[Obsolete("This static class/method is obsolete, use QSPREnvironment instance to access this instead.")]
	public static void ResetErrorCode()
	{
		StaticMapper.GetGlobalVariableObject().ResetErrorCode();
	}

	[Obsolete("This static class/method is obsolete, use QSPREnvironment instance to access this instead.")]
	public static bool SetErrorCode(string errorCode)
	{
		return StaticMapper.GetGlobalVariableObject().SetErrorCode(errorCode);
	}

	private static bool IsSubErrorSet(string errorCode)
	{
		return StaticMapper.GetGlobalVariableObject().IsSubErrorSet(errorCode);
	}

	private static bool IsSubErrorStrSet(string errorString)
	{
		return StaticMapper.GetGlobalVariableObject().IsSubErrorStrSet(errorString);
	}

	[Obsolete("This static class/method is obsolete, use QSPREnvironment instance to access this instead.")]
	public static string GetErrorCode()
	{
		return StaticMapper.GetGlobalVariableObject().GetErrorCode();
	}

	[Obsolete("This static class/method is obsolete, use QSPREnvironment instance to access this instead.")]
	public static bool RegisterTechnology(char Tech)
	{
		return StaticMapper.GetGlobalVariableObject().RegisterTechnology(Tech);
	}

	[Obsolete("This static class/method is obsolete, use QSPREnvironment instance to access this instead.")]
	public static string GetTechnologies()
	{
		return StaticMapper.GetGlobalVariableObject().GetTechnologies();
	}

	[Obsolete("This static class/method is obsolete, use QSPREnvironment instance to access this instead.")]
	public static bool SetDutIndex(uint IndexValue)
	{
		return StaticMapper.GetGlobalVariableObject().SetDutIndex(IndexValue);
	}

	[Obsolete("This static class/method is obsolete, use QSPREnvironment instance to access this instead.")]
	public static void ResetTechnologies()
	{
		StaticMapper.GetGlobalVariableObject().ResetTechnologies();
	}

	[Obsolete("This static class/method is obsolete, use QSPREnvironment instance to access this instead.")]
	public static void ResetDutIndex()
	{
		StaticMapper.GetGlobalVariableObject().ResetDutIndex();
	}

	internal static void SetupGvEvents()
	{
		if (!eventsSetup)
		{
			eventsSetup = true;
			StaticMapper.GetGlobalVariableObject().OnGlobalVariableChange += ENV_GlobalVariable_OnGlobalVariableChange;
			StaticMapper.GetGlobalVariableObject().OnTesterConfigChange += ENV_GlobalVariable_OnTesterConfigChange;
		}
	}

	private static void ENV_GlobalVariable_OnGlobalVariableChange(object sender, GlobalVariableEventArgs e)
	{
		if (GlobalVariable.OnGlobalVariableChange != null)
		{
			GlobalVariable.OnGlobalVariableChange(null, e);
		}
	}

	private static void ENV_GlobalVariable_OnTesterConfigChange(object sender, TesterConfigEventArgs e)
	{
		if (GlobalVariable.OnTesterConfigChange != null)
		{
			GlobalVariable.OnTesterConfigChange(null, e);
		}
	}
}
