Class CardBuilder
- Namespace
- HeyBox
- Assembly
- HeyBox.Net.Core.dll
用来构建 Card 卡片的构建器。
public class CardBuilder : ICardBuilder, IEquatable<CardBuilder>, IEquatable<ICardBuilder>
- Inheritance
-
CardBuilder
- Implements
- Inherited Members
- Extension Methods
Constructors
CardBuilder(CssColor?, CardSize, IList<IModuleBuilder>?)
初始化一个 CardBuilder 类的新实例。
public CardBuilder(CssColor? color = null, CardSize size = CardSize.Medium, IList<IModuleBuilder>? modules = null)
Parameters
color
CssColor?卡片侧边的颜色。
size
CardSize卡片的大小。
modules
IList<IModuleBuilder>卡片的模块。
Fields
MaxModuleCount
获取卡片的最大模块数量。
public const int MaxModuleCount = 10
Field Value
Properties
Color
获取或设置卡片左侧边的 CSS 颜色。
public CssColor? Color { get; set; }
Property Value
Remarks
未设置时等效于 Default。
Modules
获取或设置卡片的模块。
public IList<IModuleBuilder> Modules { get; set; }
Property Value
Size
获取或设置卡片的大小。
public CardSize Size { get; set; }
Property Value
Type
获取此构建器构建的卡片的类型。
public CardType Type { get; }
Property Value
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
Exceptions
- ArgumentNullException
Modules 为
null
。- ArgumentException
Modules 是一个空列表。
- ArgumentException
Modules 的元素数量超过了 MaxModuleCount。
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
Equals(object?)
Determines whether the specified object is equal to the current object.
public override bool Equals(object? obj)
Parameters
obj
objectThe object to compare with the current object.
Returns
GetHashCode()
Serves as the default hash function.
public override int GetHashCode()
Returns
- int
A hash code for the current object.
WithColor(CssColor?)
设置卡片侧边的颜色。
public CardBuilder WithColor(CssColor? color)
Parameters
color
CssColor?卡片侧边的颜色。
Returns
- CardBuilder
当前构建器。
WithSize(CardSize)
设置卡片的大小。
public CardBuilder WithSize(CardSize size)
Parameters
size
CardSize卡片的大小。
Returns
- CardBuilder
当前构建器。
Operators
operator ==(CardBuilder?, CardBuilder?)
判定两个 CardBuilder 是否相等。
public static bool operator ==(CardBuilder? left, CardBuilder? right)
Parameters
left
CardBuilderright
CardBuilder
Returns
- bool
如果两个 CardBuilder 相等,则为
true
;否则为false
。
operator !=(CardBuilder?, CardBuilder?)
判定两个 CardBuilder 是否不相等。
public static bool operator !=(CardBuilder? left, CardBuilder? right)
Parameters
left
CardBuilderright
CardBuilder
Returns
- bool
如果两个 CardBuilder 不相等,则为
true
;否则为false
。