-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
483 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,24 @@ | ||
namespace NuSocial.Core | ||
namespace NuSocial.Core; | ||
|
||
public static class ObservableCollectionExtensions | ||
{ | ||
public static class ObservableCollectionExtensions | ||
public static void RemoveLastN<T>(this ObservableCollection<T> collection, int n) | ||
{ | ||
public static void RemoveLastN<T>(this ObservableCollection<T> collection, int n) | ||
if (collection == null) | ||
{ | ||
if (collection == null) | ||
{ | ||
throw new ArgumentNullException(nameof(collection)); | ||
} | ||
throw new ArgumentNullException(nameof(collection)); | ||
} | ||
|
||
if (n < 0) | ||
{ | ||
throw new ArgumentOutOfRangeException(nameof(n), "n must be non-negative"); | ||
} | ||
if (n < 0) | ||
{ | ||
throw new ArgumentOutOfRangeException(nameof(n), "n must be non-negative"); | ||
} | ||
|
||
int removeCount = Math.Min(n, collection.Count); | ||
int removeCount = Math.Min(n, collection.Count); | ||
|
||
for (int i = 0; i < removeCount; i++) | ||
{ | ||
collection.RemoveAt(collection.Count - 1); | ||
} | ||
for (int i = 0; i < removeCount; i++) | ||
{ | ||
collection.RemoveAt(collection.Count - 1); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.