using System.Collections.Generic;
using QC.QTMDotNetKernelInterface;
using QC.QTMTargetHelper;

namespace QC.QTMToolKit.DLLTools;

internal class DLLOperations
{
	public enum QTMTestTypes
	{
		Empty,
		CTSTest,
		HiveTest,
		ScriptTest,
		LabVIEWTest,
		DotNetTest,
		DotNetTestEx
	}

	private string targetName;

	private string dllName;

	private string dllType;

	[QTMParameter(ParameterIOType.Input, DefaultValue = "This PC", TestList = "DisconnectTarget,ConnectTarget,AddTarget,LoadDLL,UnloadDLL,SetConnectionTimeout,SetTestResultsTimeout,DownloadFile", Description = "Name of the target", UnitOfMeasure = " ", Constraints = " ", DisplayHint = DisplayHints.NORMAL, NumberOfElements = 1)]
	public string TargetName
	{
		get
		{
			return targetName;
		}
		set
		{
			targetName = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, DefaultValue = " ", TestList = "LoadDLL,UnloadDLL", Description = "Name of the DLL", UnitOfMeasure = " ", Constraints = " ", DisplayHint = DisplayHints.FILE, NumberOfElements = 1)]
	public string DLLName
	{
		get
		{
			return dllName;
		}
		set
		{
			dllName = value;
		}
	}

	[QTMParameter(ParameterIOType.Input, DefaultValue = " ", TestList = "LoadDLL,UnloadDLL", Description = "Type of the DLL (CTS,.NET etc)", DisplayHint = DisplayHints.CONSTRAINTS, Constraints = "CTS; DotNET; DotNETEx; QSPR; LabView; Script")]
	public string DLLType
	{
		get
		{
			return dllType;
		}
		set
		{
			dllType = value;
		}
	}

	[QTMTest]
	public bool LoadDLL()
	{
		List<string> list = new List<string>();
		list.Add(TargetName.Trim());
		list.Add(DLLName.Trim());
		list.Add(DLLType);
		TargetMessageEventsArg targetMessageEventsArg = new TargetMessageEventsArg(TargetMessages.LoadDLL, list);
		bool flag = TargetHelper.OnTargetMessage(this, targetMessageEventsArg);
		if (!flag)
		{
			DebugMessage.Write("Temp", "Unable to Load" + DLLName + ". ERROR: " + targetMessageEventsArg.Result.ToString());
		}
		return flag;
	}

	[QTMTest]
	public bool UnloadDLL()
	{
		List<string> list = new List<string>();
		list.Add(TargetName);
		list.Add(DLLName);
		TargetMessageEventsArg targetMessageEventsArg = new TargetMessageEventsArg(TargetMessages.UnloadDLL, list);
		bool flag = TargetHelper.OnTargetMessage(this, targetMessageEventsArg);
		if (!flag)
		{
			DebugMessage.Write("Temp", "Unable to Unload" + DLLName + ". ERROR: " + targetMessageEventsArg.Result.ToString());
		}
		return flag;
	}
}
