using System.Runtime.InteropServices;
using Avalonia.Input;
namespace StabilityMatrix.Avalonia.Extensions;
public static class DataObjectExtensions
{
///
/// Get Context from IDataObject, set by Xaml Behaviors
///
public static T? GetContext(this IDataObject dataObject)
{
try
{
if (dataObject.Get("Context") is T context)
{
return context;
}
}
catch (COMException)
{
return default;
}
return default;
}
}