using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Xml.Schema;
using System.Xml.Serialization;
using QC.CTDS.DM.DataStructures.FormatDescriptorStructure;
using QC.CTDS.DM.SharedLibrary;

namespace QC.CTDS.DM.DataStructures.LimitDescriptorDataStructure;

[Serializable]
public class OutputGroupLimitDescriptor : DiscriminatorElement
{
	private ObservableCollection<OutputGroupLimitDescriptorResult> result = new ObservableCollection<OutputGroupLimitDescriptorResult>();

	[XmlElement("Result", Form = XmlSchemaForm.Unqualified)]
	public ObservableCollection<OutputGroupLimitDescriptorResult> Result
	{
		get
		{
			return result;
		}
		set
		{
			if (result != value)
			{
				result = value;
			}
		}
	}

	internal void ApplyFileGrouping(IEnumerable<string> groupNames)
	{
		List<OutputGroupLimitDescriptorResult> list = new List<OutputGroupLimitDescriptorResult>();
		foreach (OutputGroupLimitDescriptorResult item in Result.Where((OutputGroupLimitDescriptorResult res) => !Constants.AllTestsString.Contains(res.testID)))
		{
			foreach (string groupName in groupNames)
			{
				OutputGroupLimitDescriptorResult outputGroupLimitDescriptorResult = new OutputGroupLimitDescriptorResult(item);
				outputGroupLimitDescriptorResult.testID = outputGroupLimitDescriptorResult.testID + "_" + groupName;
				list.Add(outputGroupLimitDescriptorResult);
			}
		}
		Result.RemoveAll((OutputGroupLimitDescriptorResult res) => !Constants.AllTestsString.Contains(res.testID));
		list.ForEach(delegate(OutputGroupLimitDescriptorResult resultSet)
		{
			Result.Add(resultSet);
		});
	}
}
