Table of Contents

Class CardBuilder

Namespace
Kook
Assembly
Kook.Net.Core.dll

用来构建 Card 卡片的构建器。

public class CardBuilder : ICardBuilder, IEquatable<CardBuilder>, IEquatable<ICardBuilder>
Inheritance
CardBuilder
Implements
Inherited Members
Extension Methods

Constructors

CardBuilder(CardTheme, Color?, CardSize, IList<IModuleBuilder>?)

初始化一个 CardBuilder 类的新实例。

public CardBuilder(CardTheme theme = CardTheme.Primary, Color? color = null, CardSize size = CardSize.Large, IList<IModuleBuilder>? modules = null)

Parameters

theme CardTheme

卡片的主题。

color Color?

卡片侧边的颜色。

size CardSize

卡片的大小。

modules IList<IModuleBuilder>

卡片的模块。

Properties

Color

获取或设置卡片侧边的颜色。

public Color? Color { get; set; }

Property Value

Color?

Remarks

此属性的优先级高于 Theme 属性。

Modules

获取或设置卡片的模块。

public IList<IModuleBuilder> Modules { get; set; }

Property Value

IList<IModuleBuilder>

Size

获取或设置卡片的大小。

public CardSize Size { get; set; }

Property Value

CardSize

Theme

获取或设置卡片的主题。

public CardTheme Theme { get; set; }

Property Value

CardTheme

Remarks

Color 属性的优先级高于此属性。

Type

获取此构建器构建的卡片的类型。

public CardType Type { get; }

Property Value

CardType

Methods

AddModule(IModuleBuilder)

添加一个模块到卡片。

public CardBuilder AddModule(IModuleBuilder module)

Parameters

module IModuleBuilder

要添加的模块。

Returns

CardBuilder

当前构建器。

AddModule<T>(Action<T>?)

添加一个模块到卡片。

public CardBuilder AddModule<T>(Action<T>? action = null) where T : IModuleBuilder, new()

Parameters

action Action<T>

一个包含对要添加的新创建的模块进行配置的操作的委托。

Returns

CardBuilder

当前构建器。

Type Parameters

T

Build()

构建当前构建器为一个 Card

public Card Build()

Returns

Card

由当前构建器表示的属性构建的 Card 对象。

Exceptions

InvalidOperationException

卡片的主题不能为 Invisible,该值保留用于图文混排消息,暂不支持手动构建。

Equals(CardBuilder?)

Indicates whether the current object is equal to another object of the same type.

public bool Equals(CardBuilder? cardBuilder)

Parameters

cardBuilder CardBuilder

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

Equals(object?)

Determines whether the specified object is equal to the current object.

public override bool Equals(object? obj)

Parameters

obj object

The object to compare with the current object.

Returns

bool

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

GetHashCode()

Serves as the default hash function.

public override int GetHashCode()

Returns

int

A hash code for the current object.

WithColor(Color?)

设置卡片侧边的颜色。

public CardBuilder WithColor(Color? color)

Parameters

color Color?

卡片侧边的颜色。

Returns

CardBuilder

当前构建器。

Remarks

Color 属性的优先级高于 Theme 属性。

WithSize(CardSize)

设置卡片的大小。

public CardBuilder WithSize(CardSize size)

Parameters

size CardSize

卡片的大小。

Returns

CardBuilder

当前构建器。

WithTheme(CardTheme)

设置卡片的主题。

public CardBuilder WithTheme(CardTheme theme)

Parameters

theme CardTheme

卡片的主题。

Returns

CardBuilder

当前构建器。

Remarks

Color 属性的优先级高于 Theme 属性。

Operators

operator ==(CardBuilder?, CardBuilder?)

判定两个 CardBuilder 是否相等。

public static bool operator ==(CardBuilder? left, CardBuilder? right)

Parameters

left CardBuilder
right CardBuilder

Returns

bool

如果两个 CardBuilder 相等,则为 true;否则为 false

operator !=(CardBuilder?, CardBuilder?)

判定两个 CardBuilder 是否不相等。

public static bool operator !=(CardBuilder? left, CardBuilder? right)

Parameters

left CardBuilder
right CardBuilder

Returns

bool

如果两个 CardBuilder 不相等,则为 true;否则为 false