Class SectionModuleBuilder
- Namespace
- Kook
- Assembly
- Kook.Net.Core.dll
Represents a section module builder for creating a SectionModule.
public class SectionModuleBuilder : IModuleBuilder, IEquatable<SectionModuleBuilder>, IEquatable<IModuleBuilder>
- Inheritance
-
SectionModuleBuilder
- Implements
- Inherited Members
Constructors
SectionModuleBuilder()
Initializes a new instance of the SectionModuleBuilder class.
public SectionModuleBuilder()
SectionModuleBuilder(IElementBuilder?, SectionAccessoryMode?, IElementBuilder?)
Initializes a new instance of the SectionModuleBuilder class.
public SectionModuleBuilder(IElementBuilder? text, SectionAccessoryMode? mode = null, IElementBuilder? accessory = null)
Parameters
text
IElementBuildermode
SectionAccessoryMode?accessory
IElementBuilder
Exceptions
- ArgumentException
The
text
is not any form of text element, including PlainTextElementBuilder, KMarkdownElementBuilder, and ParagraphStructBuilder; or theaccessory
is neither an ImageElementBuilder nor ButtonElementBuilder.
SectionModuleBuilder(string?, bool, SectionAccessoryMode?, IElementBuilder?)
Initializes a new instance of the SectionModuleBuilder class.
public SectionModuleBuilder(string? text, bool isKMarkdown = false, SectionAccessoryMode? mode = null, IElementBuilder? accessory = null)
Parameters
text
stringisKMarkdown
boolmode
SectionAccessoryMode?accessory
IElementBuilder
Exceptions
- ArgumentException
The
text
is not any form of text element, including PlainTextElementBuilder, KMarkdownElementBuilder, and ParagraphStructBuilder; or theaccessory
is neither an ImageElementBuilder nor ButtonElementBuilder.
Properties
Accessory
Gets or sets the accessory of the section.
public IElementBuilder? Accessory { get; set; }
Property Value
- IElementBuilder
An IElementBuilder representing the accessory of the section.
Exceptions
- ArgumentException
The
value
is neither an ImageElementBuilder nor ButtonElementBuilder.
Mode
public SectionAccessoryMode? Mode { get; set; }
Property Value
- SectionAccessoryMode?
A SectionAccessoryMode representing how the Accessory is positioned relative to the Text.
Text
Gets or sets the text of the section.
public IElementBuilder? Text { get; set; }
Property Value
- IElementBuilder
An IElementBuilder representing the text of the section.
Exceptions
- ArgumentException
The
value
is not any form of text element, including PlainTextElementBuilder, KMarkdownElementBuilder, and ParagraphStructBuilder.
Type
Specifies the module type of the IModule this builder creates.
public ModuleType Type { get; }
Property Value
- ModuleType
A ModuleType representing the module type of the IModule this builder creates.
Methods
Build()
Builds this builder into a SectionModule.
public SectionModule Build()
Returns
- SectionModule
A SectionModule representing the built section module object.
Exceptions
- ArgumentException
The Text is not any form of text element, including PlainTextElementBuilder, KMarkdownElementBuilder, and ParagraphStructBuilder.
- ArgumentException
The Accessory is neither an ImageElementBuilder nor ButtonElementBuilder.
- InvalidOperationException
The ButtonElement was not positioned to the left of the Text, which is not allowed.
Equals(SectionModuleBuilder?)
Determines whether the specified SectionModuleBuilder is equal to the current SectionModuleBuilder.
public bool Equals(SectionModuleBuilder? sectionModuleBuilder)
Parameters
sectionModuleBuilder
SectionModuleBuilderThe SectionModuleBuilder to compare with the current SectionModuleBuilder.
Returns
- bool
true
if the specified SectionModuleBuilder is equal to the current SectionModuleBuilder; otherwise,false
.
Equals(object?)
Determines whether the specified SectionModuleBuilder is equal to the current SectionModuleBuilder.
public override bool Equals(object? obj)
Parameters
obj
objectThe object to compare with the current SectionModuleBuilder.
Returns
- bool
true
if the specified SectionModuleBuilder is equal to the current SectionModuleBuilder; otherwise,false
.
Remarks
If the object passes is an SectionModuleBuilder, Equals(SectionModuleBuilder?) will be called to compare the 2 instances.
GetHashCode()
Serves as the default hash function.
public override int GetHashCode()
Returns
- int
A hash code for the current object.
WithAccessory(ButtonElementBuilder)
Sets the accessory of the section.
public SectionModuleBuilder WithAccessory(ButtonElementBuilder accessory)
Parameters
accessory
ButtonElementBuilderThe accessory to be set for the section.
Returns
- SectionModuleBuilder
The current builder.
WithAccessory(ImageElementBuilder)
Sets the accessory of the section.
public SectionModuleBuilder WithAccessory(ImageElementBuilder accessory)
Parameters
accessory
ImageElementBuilderThe accessory to be set for the section.
Returns
- SectionModuleBuilder
The current builder.
WithAccessory<T>(Action<T>?)
Sets the accessory of the section.
public SectionModuleBuilder WithAccessory<T>(Action<T>? action = null) where T : IElementBuilder, new()
Parameters
action
Action<T>The action to set the accessory of the section.
Returns
- SectionModuleBuilder
The current builder.
Type Parameters
T
WithMode(SectionAccessoryMode)
public SectionModuleBuilder WithMode(SectionAccessoryMode mode)
Parameters
mode
SectionAccessoryMode
Returns
- SectionModuleBuilder
The current builder.
WithText(KMarkdownElementBuilder)
Sets the text of the section.
public SectionModuleBuilder WithText(KMarkdownElementBuilder text)
Parameters
text
KMarkdownElementBuilderThe text to be set for the section.
Returns
- SectionModuleBuilder
The current builder.
WithText(ParagraphStructBuilder)
Sets the text of the section.
public SectionModuleBuilder WithText(ParagraphStructBuilder text)
Parameters
text
ParagraphStructBuilderThe text to be set for the section.
Returns
- SectionModuleBuilder
The current builder.
WithText(PlainTextElementBuilder)
Sets the text of the section.
public SectionModuleBuilder WithText(PlainTextElementBuilder text)
Parameters
text
PlainTextElementBuilderThe text to be set for the section.
Returns
- SectionModuleBuilder
The current builder.
WithText(string?, bool)
Sets the text of the section.
public SectionModuleBuilder WithText(string? text, bool isKMarkdown = false)
Parameters
text
stringThe text to be set for the section.
isKMarkdown
boolA bool indicating whether the text is in KMarkdown format; if
true
, the text will be set as a KMarkdownElement; iffalse
, the text will be set as a PlainTextElement.
Returns
- SectionModuleBuilder
The current builder.
WithText<T>(Action<T>?)
Sets the text of the section.
public SectionModuleBuilder WithText<T>(Action<T>? action = null) where T : IElementBuilder, new()
Parameters
action
Action<T>The action to set the text of the section.
Returns
- SectionModuleBuilder
The current builder.
Type Parameters
T
Operators
operator ==(SectionModuleBuilder?, SectionModuleBuilder?)
Determines whether the specified SectionModuleBuilder is equal to the current SectionModuleBuilder.
public static bool operator ==(SectionModuleBuilder? left, SectionModuleBuilder? right)
Parameters
left
SectionModuleBuilderright
SectionModuleBuilder
Returns
- bool
true
if the specified SectionModuleBuilder is equal to the current SectionModuleBuilder; otherwise,false
.
operator !=(SectionModuleBuilder?, SectionModuleBuilder?)
Determines whether the specified SectionModuleBuilder is not equal to the current SectionModuleBuilder.
public static bool operator !=(SectionModuleBuilder? left, SectionModuleBuilder? right)
Parameters
left
SectionModuleBuilderright
SectionModuleBuilder
Returns
- bool
true
if the specified SectionModuleBuilder is not equal to the current SectionModuleBuilder; otherwise,false
.