Initial work for AbstractUI options

This commit is contained in:
Yoshi Askharoun
2021-08-05 20:45:26 -05:00
parent ba28eb7ef7
commit 3e3228245d
63 changed files with 2392 additions and 68 deletions
@@ -0,0 +1,36 @@
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Windows;
namespace OwlCore.Wpf.Extensions
{
public static class ResourceDictionaryExtensions
{
/// <summary>
/// Gets the value associated with the specified key.
/// </summary>
/// <param name="key">
/// The key of the value to get.
/// </param>
/// <param name="value">
/// When this method returns, contains the value associated with the specified key,
/// if the key is found; otherwise, <c>null</c>. This parameter is passed uninitialized.
/// </param>
/// <returns>
/// <c>true</c> if the <see cref="ResourceDictionary"/> contains an element with the specified key; otherwise, <c>false</c>.
/// </returns>
public static bool TryGetValue(this ResourceDictionary dict, object key, [MaybeNullWhen(false)] out object value)
{
try
{
value = dict[key];
return true;
}
catch (KeyNotFoundException)
{
value = null;
return false;
}
}
}
}