Class ContextModuleBuilder
- Namespace
- Kook
- Assembly
- Kook.Net.Core.dll
Represents a context module builder for creating a ContextModule.
public class ContextModuleBuilder : IModuleBuilder, IEquatable<ContextModuleBuilder>, IEquatable<IModuleBuilder>
- Inheritance
-
ContextModuleBuilder
- Implements
- Inherited Members
Constructors
ContextModuleBuilder()
Initializes a new instance of the ContextModuleBuilder class.
public ContextModuleBuilder()
ContextModuleBuilder(IList<IElementBuilder>)
Initializes a new instance of the ContextModuleBuilder class.
public ContextModuleBuilder(IList<IElementBuilder> elements)
Parameters
elements
IList<IElementBuilder>
Fields
MaxElementCount
Returns the maximum number of elements allowed by Kook.
public const int MaxElementCount = 10
Field Value
Properties
Elements
Gets or sets the elements of the context module.
public IList<IElementBuilder> Elements { get; set; }
Property Value
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
AddElement(ImageElementBuilder)
Adds an image element to the context module.
public ContextModuleBuilder AddElement(ImageElementBuilder field)
Parameters
field
ImageElementBuilderThe image element to add.
Returns
- ContextModuleBuilder
The current builder.
Exceptions
- ArgumentException
The addition operation would cause the number of elements to exceed MaxElementCount.
AddElement(KMarkdownElementBuilder)
Adds a KMarkdown element to the context module.
public ContextModuleBuilder AddElement(KMarkdownElementBuilder field)
Parameters
field
KMarkdownElementBuilderThe KMarkdown element to add.
Returns
- ContextModuleBuilder
The current builder.
AddElement(PlainTextElementBuilder)
Adds a PlainText element to the context module.
public ContextModuleBuilder AddElement(PlainTextElementBuilder field)
Parameters
field
PlainTextElementBuilderThe PlainText element to add.
Returns
- ContextModuleBuilder
The current builder.
Exceptions
- ArgumentException
The addition operation would cause the number of elements to exceed MaxElementCount.
AddElement<T>(Action<T>?)
Adds an element to the context module.
public ContextModuleBuilder AddElement<T>(Action<T>? action = null) where T : IElementBuilder, new()
Parameters
action
Action<T>The action to add an element to the context module.
Returns
- ContextModuleBuilder
The current builder.
Type Parameters
T
Build()
Builds this builder into a ContextModule.
public ContextModule Build()
Returns
- ContextModule
A ContextModule representing the built context module object.
Exceptions
- ArgumentNullException
The Elements is null.
- ArgumentException
The Elements count is greater than MaxElementCount.
- ArgumentException
The Elements contain an element that is not a PlainTextElementBuilder, KMarkdownElementBuilder, or ImageElementBuilder.
Equals(ContextModuleBuilder?)
Determines whether the specified ContextModuleBuilder is equal to the current ContextModuleBuilder.
public bool Equals(ContextModuleBuilder? contextModuleBuilder)
Parameters
contextModuleBuilder
ContextModuleBuilderThe ContextModuleBuilder to compare with the current ContextModuleBuilder.
Returns
- bool
true
if the specified ContextModuleBuilder is equal to the current ContextModuleBuilder; otherwise,false
.
Equals(object?)
Determines whether the specified ContextModuleBuilder is equal to the current ContextModuleBuilder.
public override bool Equals(object? obj)
Parameters
obj
objectThe object to compare with the current ContextModuleBuilder.
Returns
- bool
true
if the specified ContextModuleBuilder is equal to the current ContextModuleBuilder; otherwise,false
.
Remarks
If the object passes is an ContextModuleBuilder, Equals(ContextModuleBuilder?) 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.
Operators
operator ==(ContextModuleBuilder?, ContextModuleBuilder?)
Determines whether the specified ContextModuleBuilder is equal to the current ContextModuleBuilder.
public static bool operator ==(ContextModuleBuilder? left, ContextModuleBuilder? right)
Parameters
left
ContextModuleBuilderright
ContextModuleBuilder
Returns
- bool
true
if the specified ContextModuleBuilder is equal to the current ContextModuleBuilder; otherwise,false
.
operator !=(ContextModuleBuilder?, ContextModuleBuilder?)
Determines whether the specified ContextModuleBuilder is not equal to the current ContextModuleBuilder.
public static bool operator !=(ContextModuleBuilder? left, ContextModuleBuilder? right)
Parameters
left
ContextModuleBuilderright
ContextModuleBuilder
Returns
- bool
true
if the specified ContextModuleBuilder is not equal to the current ContextModuleBuilder; otherwise,false
.