Table of Contents

Class ButtonNodeBuilder

Namespace
HeyBox
Assembly
HeyBox.Net.Core.dll

用来构建 ButtonNode 元素的构建器。

public class ButtonNodeBuilder : INodeBuilder, IEquatable<ButtonNodeBuilder>, IEquatable<INodeBuilder>
Inheritance
ButtonNodeBuilder
Implements
Inherited Members

Constructors

ButtonNodeBuilder()

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

public ButtonNodeBuilder()

ButtonNodeBuilder(string, ButtonEvent, string, ButtonTheme, NodeWidth?)

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

public ButtonNodeBuilder(string text, ButtonEvent @event, string value, ButtonTheme theme = ButtonTheme.Default, NodeWidth? width = null)

Parameters

text string

按钮的文本。

event ButtonEvent

按钮的点击事件类型。

value string

按钮的值。

theme ButtonTheme

按钮的主题。

width NodeWidth?

节点的宽度。

Remarks

如果 event 设置为 LinkTo, 则在用户点击按钮时,黑盒语音会将用户重定向到 value 指定的 URL。
无论 event 设置为何值,用户点击按钮时,黑盒语音都会通过网关下发按钮点击事件,并携带所有按钮的属性值。

Fields

MaxButtonTextLength

按钮文本的最大长度。

public const int MaxButtonTextLength = 12

Field Value

int

Properties

Event

获取或设置按钮被点击时触发的事件类型。

public ButtonEvent Event { get; set; }

Property Value

ButtonEvent

Remarks

如果此属性的值设置为 LinkTo, 则在用户点击按钮时,黑盒语音会将用户重定向到 value 指定的 URL。
无论此设置为何值,用户点击按钮时,黑盒语音都会通过网关下发按钮点击事件,并携带所有按钮的属性值。

Text

获取或设置按钮的文本元素。

public string? Text { get; set; }

Property Value

string

Theme

获取或设置按钮的主题。

public ButtonTheme Theme { get; set; }

Property Value

ButtonTheme

Type

获取此构建器构建的节点的类型。

public NodeType Type { get; }

Property Value

NodeType

Value

获取或设置按钮的值。

public string? Value { get; set; }

Property Value

string

Remarks

如果 设置为 LinkTo, 则在用户点击按钮时,黑盒语音会将用户重定向到此属性值指定的 URL。
无论设置为何值,用户点击按钮时,黑盒语音都会通过网关下发按钮点击事件,并携带所有按钮的属性值。

Width

获取或设置此构建器构建的节点的大小。

public NodeWidth? Width { get; set; }

Property Value

NodeWidth?

Methods

Build()

构建当前构建器为一个 ButtonNode

public ButtonNode Build()

Returns

ButtonNode

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

Exceptions

ArgumentNullException

Textnull

ArgumentException

Text 为空字符串。

ArgumentNullException

Valuenull

ArgumentException

Value 为空字符串。

ArgumentException

文本的长度超过了 MaxButtonTextLength

UriFormatException

Value 不是有效的 URL。

Equals(ButtonNodeBuilder?)

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

public bool Equals(ButtonNodeBuilder? buttonNodeBuilder)

Parameters

buttonNodeBuilder ButtonNodeBuilder

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.

WithEvent(ButtonEvent)

设置按钮被点击时触发的事件类型,值将被设置到 Event 属性上。

public ButtonNodeBuilder WithEvent(ButtonEvent @event)

Parameters

event ButtonEvent

按钮的点击事件类型。

Returns

ButtonNodeBuilder

当前构建器。

WithText(string)

设置按钮的文本。

public ButtonNodeBuilder WithText(string text)

Parameters

text string

按钮的文本。

Returns

ButtonNodeBuilder

当前构建器。

WithTheme(ButtonTheme)

设置按钮的主题,值将被设置到 Theme 属性上。

public ButtonNodeBuilder WithTheme(ButtonTheme theme)

Parameters

theme ButtonTheme

按钮的主题。

Returns

ButtonNodeBuilder

当前构建器。

WithValue(string)

设置按钮的值,值将被设置到 Value 属性上。

public ButtonNodeBuilder WithValue(string value)

Parameters

value string

按钮的值。

Returns

ButtonNodeBuilder

当前构建器。

WithWidth(NodeWidth)

设置节点的宽度,值将被设置到 Width 属性上。

public ButtonNodeBuilder WithWidth(NodeWidth width)

Parameters

width NodeWidth

节点的宽度。

Returns

ButtonNodeBuilder

当前构建器。

Operators

operator ==(ButtonNodeBuilder?, ButtonNodeBuilder?)

判定两个 ButtonNodeBuilder 是否相等。

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

Parameters

left ButtonNodeBuilder
right ButtonNodeBuilder

Returns

bool

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

operator !=(ButtonNodeBuilder?, ButtonNodeBuilder?)

判定两个 ButtonNodeBuilder 是否不相等。

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

Parameters

left ButtonNodeBuilder
right ButtonNodeBuilder

Returns

bool

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