-
Notifications
You must be signed in to change notification settings - Fork 129
Expand file tree
/
Copy pathDictionaryExtension.cs
More file actions
34 lines (31 loc) · 1000 Bytes
/
DictionaryExtension.cs
File metadata and controls
34 lines (31 loc) · 1000 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
namespace Microsoft.SCIM
{
using System.Collections.Generic;
using System.Linq;
internal static class DictionaryExtension
{
public static void Trim(this IDictionary<string, object> dictionary)
{
IReadOnlyCollection<string> keys = dictionary.Keys.ToArray();
foreach (string key in keys)
{
object value = dictionary[key];
if (null == value)
{
dictionary.Remove(key);
}
IDictionary<string, object> dictionaryValue = value as IDictionary<string, object>;
if (dictionaryValue != null)
{
dictionaryValue.Trim();
if (dictionaryValue.Count <= 0)
{
dictionary.Remove(key);
}
}
}
}
}
}