diff options
| author | JP Dillingham <jp@dillingham.me> | 2022-09-11 18:13:24 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-09-11 18:13:24 -0500 |
| commit | e7b57da3dad5dacb6dbbc59c1464950eb170b0b4 (patch) | |
| tree | 951f5f3531e3d69c99c9fd202d4467b4ff1d46ad /src/slskd/Common/CommonExtensions.cs | |
| parent | 3d657ed87cfdab4089c72d9e6532d9b2cc83aa4e (diff) | |
| parent | a596dfe252ef53e41b91ec6773aec93307c41f1e (diff) | |
| download | slskd-e7b57da3dad5dacb6dbbc59c1464950eb170b0b4.tar.gz | |
Merge pull request #641 from slskd/in-memory
Refactor share options, add option to allow users to select between on-disk and in-memory share caching
Diffstat (limited to 'src/slskd/Common/CommonExtensions.cs')
| -rw-r--r-- | src/slskd/Common/CommonExtensions.cs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/slskd/Common/CommonExtensions.cs b/src/slskd/Common/CommonExtensions.cs index 6f39d17f..9b6a3c6c 100644 --- a/src/slskd/Common/CommonExtensions.cs +++ b/src/slskd/Common/CommonExtensions.cs @@ -360,6 +360,17 @@ namespace slskd } /// <summary> + /// Casts the string to <typeparamref name="T"/>. + /// </summary> + /// <typeparam name="T">The Enum type to which to cast.</typeparam> + /// <param name="str">The string to cast.</param> + /// <returns>The cast enum</returns> + public static T ToEnum<T>(this string str) + { + return (T)Enum.Parse(typeof(T), str, ignoreCase: true); + } + + /// <summary> /// Deserializes this string from json to an object of type <typeparamref name="T"/>. /// </summary> /// <typeparam name="T">The type to which to deserialize the string.</typeparam> |
