diff options
Diffstat (limited to 'src/slskd/Common/Extensions.cs')
| -rw-r--r-- | src/slskd/Common/Extensions.cs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/slskd/Common/Extensions.cs b/src/slskd/Common/Extensions.cs index 90f0b659..8b1ead8c 100644 --- a/src/slskd/Common/Extensions.cs +++ b/src/slskd/Common/Extensions.cs @@ -18,12 +18,14 @@ namespace slskd { using System; + using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; using System.Net.Sockets; using System.Numerics; using System.Reflection; + using System.Security.Cryptography; using System.Text; using System.Text.Json; using System.Text.Json.Serialization; @@ -308,6 +310,23 @@ namespace slskd } /// <summary> + /// Determines whether the given object is a <see cref="Dictionary{TKey, TValue}"/>. + /// </summary> + /// <param name="obj">The object to check.</param> + /// <returns>A value indicating whether the given object is a dictionary.</returns> + public static bool IsDictionary(this object obj) + { + if (obj == null) + { + return false; + } + + return obj is IDictionary && + obj.GetType().IsGenericType && + obj.GetType().GetGenericTypeDefinition().IsAssignableFrom(typeof(Dictionary<,>)); + } + + /// <summary> /// Redacts this instance of Options, replacing properties marked with <see cref="SecretAttribute"/> with '*****'. /// </summary> /// <remarks> |
