Code/Extensions/PropertyDescriptionExtensions.cs
using System;

namespace BetterUI.Extensions;

/// <summary>
/// Extensions for property descriptions.
/// </summary>
internal static class PropertyDescriptionExtensions
{
	/// <summary>
	/// Checks if a property is a cascading property with the given name and type.
	/// </summary>
	/// <param name="prop">The property to check.</param>
	/// <param name="name">The name of the cascading property.</param>
	/// <param name="type">The type of the cascading property.</param>
	/// <returns>True if the property is a cascading property with the given name and type. False otherwise.</returns>
	public static bool IsCascadingProperty( this PropertyDescription prop, string name, Type type )
	{
		var attr = prop.GetCustomAttribute<CascadingPropertyAttribute>();
		if ( attr is null ) return false;
		
		return (attr.Name == name && type == prop.PropertyType) || type == prop.PropertyType;
	}
}