Skip to content

Commit a3be770

Browse files
committed
Add IReadOnlyObservableGroup<out TKey, out TElement>
1 parent d08e1b7 commit a3be770

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using System.Collections.Generic;
6+
using System.Linq;
7+
8+
namespace CommunityToolkit.Mvvm.Collections;
9+
10+
/// <summary>
11+
/// An interface for a grouped collection of items.
12+
/// </summary>
13+
/// <typeparam name="TKey">The type of the group key.</typeparam>
14+
/// <typeparam name="TElement">The type of elements in the group.</typeparam>
15+
public interface IReadOnlyObservableGroup<out TKey, out TElement> : IReadOnlyObservableGroup<TKey>, IReadOnlyList<TElement>, IGrouping<TKey, TElement>
16+
where TKey : notnull
17+
{
18+
/// <summary>
19+
/// Gets the element at the specified index in the current collection.
20+
/// </summary>
21+
/// <param name="index">The zero-based index of the element to get.</param>
22+
/// <returns>The element at the specified index in the read-only list.</returns>
23+
/// <exception cref="System.ArgumentOutOfRangeException">Thrown if the index is out of range.</exception>
24+
new TElement this[int index] { get; }
25+
}

CommunityToolkit.Mvvm/Collections/ObservableGroup{TKey,TValue}.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace CommunityToolkit.Mvvm.Collections;
1717
/// <typeparam name="TKey">The type of the group key.</typeparam>
1818
/// <typeparam name="TValue">The type of the items in the collection.</typeparam>
1919
[DebuggerDisplay("Key = {Key}, Count = {Count}")]
20-
public class ObservableGroup<TKey, TValue> : ObservableCollection<TValue>, IGrouping<TKey, TValue>, IReadOnlyObservableGroup<TKey>
20+
public class ObservableGroup<TKey, TValue> : ObservableCollection<TValue>, IReadOnlyObservableGroup<TKey, TValue>
2121
where TKey : notnull
2222
{
2323
/// <summary>

CommunityToolkit.Mvvm/Collections/ReadOnlyObservableGroup{TKey,TValue}.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// See the LICENSE file in the project root for more information.
44

55
using System.Collections.ObjectModel;
6-
using System.Linq;
76

87
namespace CommunityToolkit.Mvvm.Collections;
98

@@ -12,7 +11,7 @@ namespace CommunityToolkit.Mvvm.Collections;
1211
/// </summary>
1312
/// <typeparam name="TKey">The type of the group key.</typeparam>
1413
/// <typeparam name="TValue">The type of the items in the collection.</typeparam>
15-
public sealed class ReadOnlyObservableGroup<TKey, TValue> : ReadOnlyObservableCollection<TValue>, IGrouping<TKey, TValue>, IReadOnlyObservableGroup<TKey>
14+
public sealed class ReadOnlyObservableGroup<TKey, TValue> : ReadOnlyObservableCollection<TValue>, IReadOnlyObservableGroup<TKey, TValue>
1615
where TKey : notnull
1716
{
1817
/// <summary>

0 commit comments

Comments
 (0)