using System;
using System.ComponentModel;
using System.Globalization;

namespace QC.QTMSecurity;

internal class QGroupsCollectionConverter : ExpandableObjectConverter
{
	public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destType)
	{
		if (destType == typeof(string) && value is QGroupsCollection)
		{
			QGroupsCollection qGroupsCollection = (QGroupsCollection)value;
			string text = string.Empty;
			for (int i = 0; i < qGroupsCollection.Count; i++)
			{
				if (text.Length > 0)
				{
					text += ", ";
				}
				text += qGroupsCollection[i];
			}
			return text;
		}
		return base.ConvertTo(context, culture, value, destType);
	}

	public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
	{
		if (destinationType == typeof(string))
		{
			return true;
		}
		return false;
	}
}
