Skip to content

Commit 83aa5e5

Browse files
committed
Added Dictionary extension.
1 parent 969e328 commit 83aa5e5

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

ReClass.NET.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@
250250
<DependentUpon>MemoryViewControl.cs</DependentUpon>
251251
</Compile>
252252
<Compile Include="UI\CustomToolStripProfessionalRenderer.cs" />
253+
<Compile Include="Util\Extension.Dictionary.cs" />
253254
<Compile Include="Util\GrowingList.cs" />
254255
<Compile Include="Forms\PluginForm.cs">
255256
<SubType>Form</SubType>

Util/Extension.Dictionary.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Diagnostics.Contracts;
4+
using System.Linq;
5+
6+
namespace ReClassNET.Util
7+
{
8+
public static class DictionaryExtension
9+
{
10+
public static void RemoveWhere<TKey, TValue>(this IDictionary<TKey, TValue> source, Func<KeyValuePair<TKey, TValue>, bool> selector)
11+
{
12+
Contract.Requires(source != null);
13+
Contract.Requires(selector != null);
14+
15+
foreach (var kv in source.Where(selector).ToList())
16+
{
17+
source.Remove(kv.Key);
18+
}
19+
}
20+
}
21+
}

Util/Extension.Linq.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace ReClassNET.Util
44
{
5-
static class LinqExtension
5+
public static class LinqExtension
66
{
77
public static string Join(this IEnumerable<string> source)
88
{

0 commit comments

Comments
 (0)