Files
sbox-public/engine/Sandbox.Engine/Systems/UI/Razor/RenderTreeBuilderExtensions.cs
s&box team 71f266059a Open source release
This commit imports the C# engine code and game files, excluding C++ source code.

[Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
2025-11-24 09:05:18 +00:00

54 lines
1.4 KiB
C#

using Microsoft.AspNetCore.Components.Rendering;
using Sandbox.UI;
namespace Microsoft.AspNetCore.Components;
public static class RazorExtensions
{
extension( RenderTreeBuilder self )
{
public void AddAttribute( int sequence, string attrName, Action<PanelEvent> value )
{
if ( self is not PanelRenderTreeBuilder ptb ) return;
ptb.AddPanelEventAttribute( sequence, attrName, value );
}
public void AddAttribute( int sequence, string attrName, Func<Task> value )
{
if ( self is not PanelRenderTreeBuilder ptb ) return;
ptb.AddAttributeAction( sequence, attrName, value );
}
public void AddAttribute( int sequence, string attrName, Action value )
{
if ( self is not PanelRenderTreeBuilder ptb ) return;
ptb.AddAttributeAction( sequence, attrName, value );
}
public void AddAttribute( int sequence, string attrName, object value )
{
if ( self is not PanelRenderTreeBuilder ptb ) return;
ptb.AddAttributeObject( sequence, attrName, value );
}
public void AddAttribute( int sequence, string attrName, string value )
{
if ( self is not PanelRenderTreeBuilder ptb ) return;
ptb.AddAttributeString( sequence, attrName, value );
}
public void AddAttribute<T>( int sequence, object value, Action<T> setter )
{
if ( self is not PanelRenderTreeBuilder ptb ) return;
ptb.AddAttributeWithSetter<T>( sequence, value, setter );
}
}
}