diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/slskd/Common/Extensions.cs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/slskd/Common/Extensions.cs b/src/slskd/Common/Extensions.cs index 90f0b659..ebf16fce 100644 --- a/src/slskd/Common/Extensions.cs +++ b/src/slskd/Common/Extensions.cs @@ -18,6 +18,7 @@ namespace slskd { using System; + using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; @@ -308,6 +309,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> |
