PdfPig/src/UglyToad.PdfPig.Tokens/CommentToken.cs
InusualZ be7716eeea Make IToken implement IEquatable<IToken>
This would allow us to deduplicate tokens, by comparing their content
2020-03-15 16:05:23 +01:00

41 lines
1.1 KiB
C#

namespace UglyToad.PdfPig.Tokens
{
/// <summary>
/// A comment from a PDF document. Any occurrence of the percent sign character (%) outside a string or stream
/// introduces a comment. The comment consists of all characters between the percent sign and the end of the line.
/// </summary>
public class CommentToken : IDataToken<string>
{
/// <summary>
/// The text of the comment (excluding the initial percent '%' sign).
/// </summary>
public string Data { get; }
/// <summary>
/// Create a new <see cref="CommentToken"/>.
/// </summary>
/// <param name="data">The text of the comment.</param>
public CommentToken(string data)
{
Data = data ?? string.Empty;
}
/// <inheritdoc />
public override string ToString()
{
return Data;
}
/// <inheritdoc />
public bool Equals(IToken obj)
{
if (!(obj is CommentToken other))
{
return false;
}
return other.Data == Data;
}
}
}