Skip to content

Commit b522487

Browse files
committed
Rename TValue type params to TElement
1 parent a3be770 commit b522487

File tree

4 files changed

+26
-26
lines changed

4 files changed

+26
-26
lines changed

CommunityToolkit.Mvvm/Collections/ObservableGroupedCollection{TKey,TValue}.cs renamed to CommunityToolkit.Mvvm/Collections/ObservableGroupedCollection{TKey,TElement}.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ namespace CommunityToolkit.Mvvm.Collections;
1313
/// <summary>
1414
/// An observable list of observable groups.
1515
/// </summary>
16-
/// <typeparam name="TKey">The type of the group key.</typeparam>
17-
/// <typeparam name="TValue">The type of the items in the collection.</typeparam>
18-
public sealed class ObservableGroupedCollection<TKey, TValue> : ObservableCollection<ObservableGroup<TKey, TValue>>
16+
/// <typeparam name="TKey">The type of the group keys.</typeparam>
17+
/// <typeparam name="TElement">The type of elements in the collection.</typeparam>
18+
public sealed class ObservableGroupedCollection<TKey, TElement> : ObservableCollection<ObservableGroup<TKey, TElement>>
1919
where TKey : notnull
2020
{
2121
/// <summary>
@@ -29,8 +29,8 @@ public ObservableGroupedCollection()
2929
/// Initializes a new instance of the <see cref="ObservableGroupedCollection{TKey, TValue}"/> class.
3030
/// </summary>
3131
/// <param name="collection">The initial data to add in the grouped collection.</param>
32-
public ObservableGroupedCollection(IEnumerable<IGrouping<TKey, TValue>> collection)
33-
: base(collection.Select(static c => new ObservableGroup<TKey, TValue>(c)))
32+
public ObservableGroupedCollection(IEnumerable<IGrouping<TKey, TElement>> collection)
33+
: base(collection.Select(static c => new ObservableGroup<TKey, TElement>(c)))
3434
{
3535
}
3636

@@ -40,9 +40,9 @@ public ObservableGroupedCollection(IEnumerable<IGrouping<TKey, TValue>> collecti
4040
/// <param name="list">The resulting <see cref="List{T}"/>, if one was in use.</param>
4141
/// <returns>Whether or not a <see cref="List{T}"/> instance has been found.</returns>
4242
[MethodImpl(MethodImplOptions.AggressiveInlining)]
43-
internal bool TryGetList([NotNullWhen(true)] out List<ObservableGroup<TKey, TValue>>? list)
43+
internal bool TryGetList([NotNullWhen(true)] out List<ObservableGroup<TKey, TElement>>? list)
4444
{
45-
list = Items as List<ObservableGroup<TKey, TValue>>;
45+
list = Items as List<ObservableGroup<TKey, TElement>>;
4646

4747
return list is not null;
4848
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ namespace CommunityToolkit.Mvvm.Collections;
1515
/// It associates a <see cref="Key"/> to an <see cref="ObservableCollection{T}"/>.
1616
/// </summary>
1717
/// <typeparam name="TKey">The type of the group key.</typeparam>
18-
/// <typeparam name="TValue">The type of the items in the collection.</typeparam>
18+
/// <typeparam name="TElement">The type of elements in the group.</typeparam>
1919
[DebuggerDisplay("Key = {Key}, Count = {Count}")]
20-
public class ObservableGroup<TKey, TValue> : ObservableCollection<TValue>, IReadOnlyObservableGroup<TKey, TValue>
20+
public class ObservableGroup<TKey, TElement> : ObservableCollection<TElement>, IReadOnlyObservableGroup<TKey, TElement>
2121
where TKey : notnull
2222
{
2323
/// <summary>
@@ -33,7 +33,7 @@ public ObservableGroup(TKey key)
3333
/// Initializes a new instance of the <see cref="ObservableGroup{TKey, TValue}"/> class.
3434
/// </summary>
3535
/// <param name="grouping">The grouping to fill the group.</param>
36-
public ObservableGroup(IGrouping<TKey, TValue> grouping)
36+
public ObservableGroup(IGrouping<TKey, TElement> grouping)
3737
: base(grouping)
3838
{
3939
this.key = grouping.Key;
@@ -44,7 +44,7 @@ public ObservableGroup(IGrouping<TKey, TValue> grouping)
4444
/// </summary>
4545
/// <param name="key">The key for the group.</param>
4646
/// <param name="collection">The initial collection of data to add to the group.</param>
47-
public ObservableGroup(TKey key, IEnumerable<TValue> collection)
47+
public ObservableGroup(TKey key, IEnumerable<TElement> collection)
4848
: base(collection)
4949
{
5050
this.key = key;

CommunityToolkit.Mvvm/Collections/ReadOnlyObservableGroupedCollection{TKey,TValue}.cs renamed to CommunityToolkit.Mvvm/Collections/ReadOnlyObservableGroupedCollection{TKey,TElement}.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@ namespace CommunityToolkit.Mvvm.Collections;
1313
/// <summary>
1414
/// A read-only list of groups.
1515
/// </summary>
16-
/// <typeparam name="TKey">The type of the group key.</typeparam>
17-
/// <typeparam name = "TValue" > The type of the items in the collection.</typeparam>
18-
public sealed class ReadOnlyObservableGroupedCollection<TKey, TValue> : ReadOnlyObservableCollection<ReadOnlyObservableGroup<TKey, TValue>>
16+
/// <typeparam name="TKey">The type of the group keys.</typeparam>
17+
/// <typeparam name="TElement">The type of elements in the collection.</typeparam>
18+
public sealed class ReadOnlyObservableGroupedCollection<TKey, TElement> : ReadOnlyObservableCollection<ReadOnlyObservableGroup<TKey, TElement>>
1919
where TKey : notnull
2020
{
2121
/// <summary>
2222
/// Initializes a new instance of the <see cref="ReadOnlyObservableGroupedCollection{TKey, TValue}"/> class.
2323
/// </summary>
2424
/// <param name="collection">The source collection to wrap.</param>
25-
public ReadOnlyObservableGroupedCollection(ObservableCollection<ObservableGroup<TKey, TValue>> collection)
26-
: base(new ObservableCollection<ReadOnlyObservableGroup<TKey, TValue>>(collection.Select(static g => new ReadOnlyObservableGroup<TKey, TValue>(g))))
25+
public ReadOnlyObservableGroupedCollection(ObservableCollection<ObservableGroup<TKey, TElement>> collection)
26+
: base(new ObservableCollection<ReadOnlyObservableGroup<TKey, TElement>>(collection.Select(static g => new ReadOnlyObservableGroup<TKey, TElement>(g))))
2727
{
2828
collection.CollectionChanged += OnSourceCollectionChanged;
2929
}
@@ -32,7 +32,7 @@ public ReadOnlyObservableGroupedCollection(ObservableCollection<ObservableGroup<
3232
/// Initializes a new instance of the <see cref="ReadOnlyObservableGroupedCollection{TKey, TValue}"/> class.
3333
/// </summary>
3434
/// <param name="collection">The source collection to wrap.</param>
35-
public ReadOnlyObservableGroupedCollection(ObservableCollection<ReadOnlyObservableGroup<TKey, TValue>> collection)
35+
public ReadOnlyObservableGroupedCollection(ObservableCollection<ReadOnlyObservableGroup<TKey, TElement>> collection)
3636
: base(collection)
3737
{
3838
}
@@ -59,17 +59,17 @@ static void ThrowNotSupportedExceptionForRangeOperation()
5959
}
6060

6161
// The inner Items list is ObservableCollection<ReadOnlyObservableGroup<TKey, TValue>>, so doing a direct cast here will always succeed
62-
ObservableCollection<ReadOnlyObservableGroup<TKey, TValue>> items = (ObservableCollection<ReadOnlyObservableGroup<TKey, TValue>>)Items;
62+
ObservableCollection<ReadOnlyObservableGroup<TKey, TElement>> items = (ObservableCollection<ReadOnlyObservableGroup<TKey, TElement>>)Items;
6363

6464
switch (e.Action)
6565
{
6666
// Insert a single item for an "Add" operation, fail if multiple items are added
6767
case NotifyCollectionChangedAction.Add:
6868
if (e.NewItems!.Count == 1)
6969
{
70-
ObservableGroup<TKey, TValue> newItem = (ObservableGroup<TKey, TValue>)e.NewItems![0]!;
70+
ObservableGroup<TKey, TElement> newItem = (ObservableGroup<TKey, TElement>)e.NewItems![0]!;
7171

72-
items.Insert(e.NewStartingIndex, new ReadOnlyObservableGroup<TKey, TValue>(newItem));
72+
items.Insert(e.NewStartingIndex, new ReadOnlyObservableGroup<TKey, TElement>(newItem));
7373
}
7474
else if (e.NewItems!.Count > 1)
7575
{
@@ -95,9 +95,9 @@ static void ThrowNotSupportedExceptionForRangeOperation()
9595
case NotifyCollectionChangedAction.Replace:
9696
if (e.OldItems!.Count == 1 && e.NewItems!.Count == 1)
9797
{
98-
ObservableGroup<TKey, TValue> replacedItem = (ObservableGroup<TKey, TValue>)e.NewItems![0]!;
98+
ObservableGroup<TKey, TElement> replacedItem = (ObservableGroup<TKey, TElement>)e.NewItems![0]!;
9999

100-
items[e.OldStartingIndex] = new ReadOnlyObservableGroup<TKey, TValue>(replacedItem);
100+
items[e.OldStartingIndex] = new ReadOnlyObservableGroup<TKey, TElement>(replacedItem);
101101
}
102102
else if (e.OldItems!.Count > 1 || e.NewItems!.Count > 1)
103103
{

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ namespace CommunityToolkit.Mvvm.Collections;
1010
/// A read-only observable group. It associates a <see cref="Key"/> to a <see cref="ReadOnlyObservableCollection{T}"/>.
1111
/// </summary>
1212
/// <typeparam name="TKey">The type of the group key.</typeparam>
13-
/// <typeparam name="TValue">The type of the items in the collection.</typeparam>
14-
public sealed class ReadOnlyObservableGroup<TKey, TValue> : ReadOnlyObservableCollection<TValue>, IReadOnlyObservableGroup<TKey, TValue>
13+
/// <typeparam name="TElement">The type of elements in the group.</typeparam>
14+
public sealed class ReadOnlyObservableGroup<TKey, TElement> : ReadOnlyObservableCollection<TElement>, IReadOnlyObservableGroup<TKey, TElement>
1515
where TKey : notnull
1616
{
1717
/// <summary>
1818
/// Initializes a new instance of the <see cref="ReadOnlyObservableGroup{TKey, TValue}"/> class.
1919
/// </summary>
2020
/// <param name="key">The key of the group.</param>
2121
/// <param name="collection">The collection of items to add in the group.</param>
22-
public ReadOnlyObservableGroup(TKey key, ObservableCollection<TValue> collection)
22+
public ReadOnlyObservableGroup(TKey key, ObservableCollection<TElement> collection)
2323
: base(collection)
2424
{
2525
Key = key;
@@ -29,7 +29,7 @@ public ReadOnlyObservableGroup(TKey key, ObservableCollection<TValue> collection
2929
/// Initializes a new instance of the <see cref="ReadOnlyObservableGroup{TKey, TValue}"/> class.
3030
/// </summary>
3131
/// <param name="group">The <see cref="ObservableGroup{TKey, TValue}"/> to wrap.</param>
32-
public ReadOnlyObservableGroup(ObservableGroup<TKey, TValue> group)
32+
public ReadOnlyObservableGroup(ObservableGroup<TKey, TElement> group)
3333
: base(group)
3434
{
3535
Key = group.Key;

0 commit comments

Comments
 (0)