private void EnforceUniqueFields(SortSpec <TSortField> spec, int replaceIndex = -1) { for (int i = 0; i < Count; i++) { if (i != replaceIndex && this[i].Field.Equals(spec.Field)) { throw new InvalidOperationException($"Cannot insert a sort specification for field {typeof(TSortField)}.{spec.Field} because one already exists."); } } }
protected override void SetItem(int index, SortSpec <TSortField> spec) { EnforceUniqueFields(spec, index); base.SetItem(index, spec); }