Class PlainTextElementBuilder
- Namespace
- Kook
- Assembly
- Kook.Net.Core.dll
An element builder to build a PlainTextElement.
public class PlainTextElementBuilder : IElementBuilder, IEquatable<PlainTextElementBuilder>, IEquatable<IElementBuilder>
- Inheritance
-
PlainTextElementBuilder
- Implements
- Inherited Members
Constructors
PlainTextElementBuilder()
Initializes a new instance of the PlainTextElementBuilder class.
public PlainTextElementBuilder()
PlainTextElementBuilder(string?, bool)
Initializes a new instance of the PlainTextElementBuilder class.
public PlainTextElementBuilder(string? content, bool emoji = true)
Parameters
content
stringThe content of the PlainTextElement.
emoji
boolA boolean value that indicates whether the shortcuts should be translated into emojis.
Fields
MaxPlainTextLength
Gets the maximum plain text length allowed by Kook.
public const int MaxPlainTextLength = 2000
Field Value
- int
An int that represents the maximum plain text length allowed by Kook.
Properties
Content
Gets or sets the content of a PlainTextElement.
public string? Content { get; set; }
Property Value
- string
The content of the PlainTextElement.
Emoji
Gets whether the shortcuts should be translated into emojis.
public bool Emoji { get; set; }
Property Value
- bool
A boolean value that indicates whether the shortcuts should be translated into emojis.
true
if the shortcuts should be translated into emojis;false
if the text should be displayed as is.
Type
Gets the type of the element that this builder builds.
public ElementType Type { get; }
Property Value
- ElementType
An ElementType that represents the type of element that this builder builds.
Methods
Build()
Builds the PlainTextElementBuilder into a PlainTextElement.
public PlainTextElement Build()
Returns
- PlainTextElement
A PlainTextElement represents the built element object.
Exceptions
- ArgumentNullException
The Content is null.
- ArgumentException
The length of the Content is greater than MaxPlainTextLength.
Equals(PlainTextElementBuilder?)
Determines whether the specified PlainTextElementBuilder is equal to the current PlainTextElementBuilder.
public bool Equals(PlainTextElementBuilder? plainTextElementBuilder)
Parameters
plainTextElementBuilder
PlainTextElementBuilderThe PlainTextElementBuilder to compare with the current PlainTextElementBuilder.
Returns
- bool
true
if the specified PlainTextElementBuilder is equal to the current PlainTextElementBuilder; otherwise,false
.
Equals(object?)
Determines whether the specified object is equal to the current PlainTextElementBuilder.
public override bool Equals(object? obj)
Parameters
obj
objectThe object to compare with the current PlainTextElementBuilder.
Returns
GetHashCode()
Serves as the default hash function.
public override int GetHashCode()
Returns
- int
A hash code for the current object.
WithContent(string)
Sets the content of a PlainTextElement.
public PlainTextElementBuilder WithContent(string content)
Parameters
content
stringThe text to be set as the content.
Returns
- PlainTextElementBuilder
The current builder.
WithEmoji(bool)
Sets whether the shortcuts should be translated into emojis.
public PlainTextElementBuilder WithEmoji(bool emoji)
Parameters
emoji
boolA boolean value that indicates whether the shortcuts should be translated into emojis.
true
if the shortcuts should be translated into emojis;false
if the text should be displayed as is.
Returns
- PlainTextElementBuilder
The current builder.
Operators
operator ==(PlainTextElementBuilder?, PlainTextElementBuilder?)
Determines whether the specified PlainTextElementBuilder is equal to the current PlainTextElementBuilder.
public static bool operator ==(PlainTextElementBuilder? left, PlainTextElementBuilder? right)
Parameters
left
PlainTextElementBuilderright
PlainTextElementBuilder
Returns
- bool
true
if the specified PlainTextElementBuilder is equal to the current PlainTextElementBuilder; otherwise,false
.
implicit operator PlainTextElementBuilder(string)
Initialized a new instance of the PlainTextElementBuilder class with the specified content.
public static implicit operator PlainTextElementBuilder(string content)
Parameters
content
stringThe content of the PlainTextElement.
Returns
- PlainTextElementBuilder
A PlainTextElementBuilder object that is initialized with the specified content.
operator !=(PlainTextElementBuilder?, PlainTextElementBuilder?)
Determines whether the specified PlainTextElementBuilder is not equal to the current PlainTextElementBuilder.
public static bool operator !=(PlainTextElementBuilder? left, PlainTextElementBuilder? right)
Parameters
left
PlainTextElementBuilderright
PlainTextElementBuilder
Returns
- bool
true
if the specified PlainTextElementBuilder is not equal to the current PlainTextElementBuilder; otherwise,false
.