Skip to content

Commit 257250d

Browse files
committed
Add IReadOnlyObservableGroup<out TKey>
1 parent e4a105f commit 257250d

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
namespace CommunityToolkit.Mvvm.Collections;
6+
7+
/// <summary>
8+
/// An interface for a grouped collection of items.
9+
/// </summary>
10+
/// <typeparam name="TKey">The type of the group key.</typeparam>
11+
public interface IReadOnlyObservableGroup<out TKey> : IReadOnlyObservableGroup
12+
where TKey : notnull
13+
{
14+
/// <summary>
15+
/// Gets the key for the current collection.
16+
/// </summary>
17+
new TKey Key { get; }
18+
}

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
20+
public class ObservableGroup<TKey, TValue> : ObservableCollection<TValue>, IGrouping<TKey, TValue>, IReadOnlyObservableGroup<TKey>
2121
where TKey : notnull
2222
{
2323
/// <summary>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace CommunityToolkit.Mvvm.Collections;
1313
/// </summary>
1414
/// <typeparam name="TKey">The type of the group key.</typeparam>
1515
/// <typeparam name="TValue">The type of the items in the collection.</typeparam>
16-
public sealed class ReadOnlyObservableGroup<TKey, TValue> : ReadOnlyObservableCollection<TValue>, IGrouping<TKey, TValue>, IReadOnlyObservableGroup
16+
public sealed class ReadOnlyObservableGroup<TKey, TValue> : ReadOnlyObservableCollection<TValue>, IGrouping<TKey, TValue>, IReadOnlyObservableGroup<TKey>
1717
where TKey : notnull
1818
{
1919
/// <summary>

0 commit comments

Comments
 (0)