<commit_before>﻿using System;
using System.Collections.Generic;

namespace DragonSpark.Application.Runtime
{
	public class SelectedCollection<T> : List<T>
	{
		public SelectedCollection(IEnumerable<T> list) : base(list) {}

		public virtual T? Selected { get; set; }
	}

	public class SelectedCollection<T, TValue> : SelectedCollection<T>
	{
		readonly Func<T, TValue>           _select;
		readonly IEqualityComparer<TValue> _equality;

		public SelectedCollection(IEnumerable<T> list, Func<T, TValue> select)
			: this(list, select, EqualityComparer<TValue>.Default) {}

		public SelectedCollection(IEnumerable<T> list, Func<T, TValue> select, IEqualityComparer<TValue> equality)
			: base(list)
		{
			_select   = @select;
			_equality = equality;
		}

		public TValue? Value
		{
			get => Selected != null ? _select(Selected) : default;
			set
			{
				if (value is not null)
				{
					foreach (var listing in this)
					{
						if (_equality.Equals(_select(listing), value))
						{
							Selected = listing;
						}
					}
				}
				else
				{
					Selected = default;
				}
			}
		}
	}
}<commit_msg>Binding adjustments<commit_after>﻿using DragonSpark.Model.Selection.Conditions;
using System;
using System.Collections.Generic;

namespace DragonSpark.Application.Runtime
{
	public class SelectedCollection<T> : List<T>
	{
		public SelectedCollection(IEnumerable<T> list) : base(list) {}

		public virtual T? Selected { get; set; }
	}

	public class SelectedCollection<T, TValue> : SelectedCollection<T>, ICondition<TValue>
	{
		readonly Func<T, TValue>           _select;
		readonly IEqualityComparer<TValue> _equality;

		public SelectedCollection(IEnumerable<T> list, Func<T, TValue> select)
			: this(list, select, EqualityComparer<TValue>.Default) {}

		public SelectedCollection(IEnumerable<T> list, Func<T, TValue> select, IEqualityComparer<TValue> equality)
			: base(list)
		{
			_select   = @select;
			_equality = equality;
		}

		public TValue? Value
		{
			get => Selected is not null ? _select(Selected) : default;
			set
			{
				if (value is not null)
				{
					foreach (var listing in this)
					{
						if (_equality.Equals(_select(listing), value))
						{
							Selected = listing;
							return;
						}
					}
				}

				Selected = default;
			}
		}

		public bool Get(TValue parameter)
		{
			foreach (var listing in this)
			{
				if (_equality.Equals(_select(listing), parameter))
				{
					return true;
				}
			}
			return false;
		}
	}
}
{'fraction_non_alphanumeric': 0.11075181891673404, 'fraction_numerical': 0.0, 'mean_word_length': 3.230769230769231, 'pattern_counts': {'":': 0, '<': 30, '<?xml version=': 0, '>': 32, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '131415', 'n_tokens_mistral': 1015, 'n_tokens_neox': 794, 'n_words': 184}