Files
sbox-public/engine/Sandbox.System/Html/Attribute.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

47 lines
1.0 KiB
C#

using System;
using System.Diagnostics;
using System.Web;
namespace Sandbox.Html
{
/// <summary>
/// Represents an HTML attribute.
/// </summary>
[DebuggerDisplay( "Name: {Name}, Value: {Value}" )]
internal class Attribute
{
internal string _name;
internal int _namelength;
internal int _namestartindex;
internal string _value;
internal int _valuelength;
internal int _valuestartindex;
private string _text;
internal Attribute( Document ownerdocument )
{
_text = ownerdocument.Text;
}
/// <summary>
/// Gets the qualified name of the attribute.
/// </summary>
public string Name => _name ?? (_name = _text.Substring( _namestartindex, _namelength ).ToLowerInvariant());
/// <summary>
/// Gets or sets the value of the attribute.
/// </summary>
public string Value => _value ??= GetValue();
private string GetValue()
{
if ( _valuestartindex <= 0 ) return string.Empty;
if ( _valuelength <= 0 ) return string.Empty;
return HttpUtility.HtmlDecode( _text.Substring( _valuestartindex, _valuelength ) );
}
}
}