Table of Contents

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

int

Properties

Elements

Gets or sets the elements of the context module.

public IList<IElementBuilder> Elements { get; set; }

Property Value

IList<IElementBuilder>

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 ImageElementBuilder

The 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 KMarkdownElementBuilder

The 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 PlainTextElementBuilder

The 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 ContextModuleBuilder

The 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 object

The 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 ContextModuleBuilder
right 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 ContextModuleBuilder
right ContextModuleBuilder

Returns

bool

true if the specified ContextModuleBuilder is not equal to the current ContextModuleBuilder; otherwise, false.