using XamlX.Ast;
namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions;
internal static class XamlAstNewClrObjectHelper
{
///
/// Tries to resolve the underlying value of a ,
/// unwrapping any nested instances.
///
public static TXamlAstValueNode? UnwrapValue(this XamlValueWithManipulationNode node)
where TXamlAstValueNode : class, IXamlAstValueNode
{
var current = node.Value;
while (current is XamlValueWithManipulationNode valueWithManipulation)
{
current = valueWithManipulation.Value;
if (current is TXamlAstValueNode typedValue)
{
return typedValue;
}
}
return current as TXamlAstValueNode;
}
}