/// <summary> /// Gets the settings. /// </summary> /// <typeparam name="T">The settings type</typeparam> /// <returns>An instance of <typeparamref name="T"/> </returns> /// <exception cref="T:System.Threading.LockRecursionException">The current thread cannot acquire the write lock when it holds the read lock.-or-The <see cref="P:System.Threading.ReaderWriterLockSlim.RecursionPolicy" /> property is <see cref="F:System.Threading.LockRecursionPolicy.NoRecursion" />, and the current thread has attempted to acquire the read lock when it already holds the read lock. -or-The <see cref="P:System.Threading.ReaderWriterLockSlim.RecursionPolicy" /> property is <see cref="F:System.Threading.LockRecursionPolicy.NoRecursion" />, and the current thread has attempted to acquire the read lock when it already holds the write lock. -or-The recursion number would exceed the capacity of the counter. This limit is so large that applications should never encounter this exception.</exception> /// <exception cref="T:System.ObjectDisposedException">The <see cref="T:System.Threading.ReaderWriterLockSlim" /> object has been disposed.</exception> /// <exception cref="T:System.Threading.SynchronizationLockException">The current thread has not entered the lock in read mode.</exception> public T GetSettings <T>() { readerWriterLock.EnterReadLock(); try { if (GlobalSettings.ContainsKey(typeof(T))) { return((T)GlobalSettings[typeof(T)]); } } catch (KeyNotFoundException keyNotFoundException) { log.Error($"[Settings] {keyNotFoundException.Message}", exception: keyNotFoundException); } catch (ArgumentNullException argumentNullException) { log.Error($"[Settings] {argumentNullException.Message}", exception: argumentNullException); } finally { readerWriterLock.ExitReadLock(); } return(default);