Class CardBuilder
- Namespace
- Kook
- Assembly
- Kook.Net.Core.dll
Represents a builder class for creating a Card.
public class CardBuilder : ICardBuilder, IEquatable<CardBuilder>, IEquatable<ICardBuilder>
- Inheritance
-
CardBuilder
- Implements
- Inherited Members
- Extension Methods
Constructors
CardBuilder(CardTheme, Color?, CardSize, IList<IModuleBuilder>?)
Initializes a new instance of the CardBuilder class with the specified parameters.
public CardBuilder(CardTheme theme = CardTheme.Primary, Color? color = null, CardSize size = CardSize.Large, IList<IModuleBuilder>? modules = null)
Parameters
theme
CardThemeThe theme of the card.
color
Color?The color displayed along the left side of the card.
size
CardSizeThe size of the card.
modules
IList<IModuleBuilder>The modules in the card.
Properties
Color
Gets or sets the color displayed along the left side of the card.
public Color? Color { get; set; }
Property Value
Modules
Gets or sets the modules in the card.
public IList<IModuleBuilder> Modules { get; set; }
Property Value
- IList<IModuleBuilder>
An IList<T> containing the modules in the card.
Size
Gets or sets the size of the card.
public CardSize Size { get; set; }
Property Value
Theme
Gets or sets the theme of the card.
public CardTheme Theme { get; set; }
Property Value
Type
Gets the type of the card.
public CardType Type { get; }
Property Value
Methods
AddModule(IModuleBuilder)
Adds a module to the card.
public CardBuilder AddModule(IModuleBuilder module)
Parameters
module
IModuleBuilderAn IModuleBuilder that represents the module to be added to the card.
Returns
- CardBuilder
The current builder.
AddModule<T>(Action<T>?)
Adds a module to the card.
public CardBuilder AddModule<T>(Action<T>? action = null) where T : IModuleBuilder, new()
Parameters
action
Action<T>The action to adds a module to the card.
Returns
- CardBuilder
The current builder.
Type Parameters
T
Build()
Builds the CardBuilder into a Card.
public Card Build()
Returns
- Card
A KMarkdownElement represents the built element object.
Exceptions
- InvalidOperationException
The theme of the card cannot be invisible, which is reserved for text graphics mixed messages.
Equals(CardBuilder?)
Determines whether the specified CardBuilder is equal to the current CardBuilder.
public bool Equals(CardBuilder? cardBuilder)
Parameters
cardBuilder
CardBuilderThe CardBuilder to compare with the current CardBuilder.
Returns
- bool
true
if the specified CardBuilder is equal to the current CardBuilder; otherwise,false
.
Equals(object?)
Determines whether the specified object is equal to the current CardBuilder.
public override bool Equals(object? obj)
Parameters
obj
objectThe object to compare with the current CardBuilder.
Returns
- bool
true
if the specified object is equal to the current CardBuilder; otherwise,false
.
GetHashCode()
Serves as the default hash function.
public override int GetHashCode()
Returns
- int
A hash code for the current object.
WithColor(Color?)
Sets the color displayed along the left side of the card.
public CardBuilder WithColor(Color? color)
Parameters
color
Color?A Color value that represents the color displayed along the left side of the card to be set.
Returns
- CardBuilder
The current builder.
WithSize(CardSize)
Sets the size of the card.
public CardBuilder WithSize(CardSize size)
Parameters
Returns
- CardBuilder
The current builder.
WithTheme(CardTheme)
Sets the theme of the card.
public CardBuilder WithTheme(CardTheme theme)
Parameters
Returns
- CardBuilder
The current builder.
Operators
operator ==(CardBuilder?, CardBuilder?)
Determines whether the specified CardBuilder is equal to the current CardBuilder.
public static bool operator ==(CardBuilder? left, CardBuilder? right)
Parameters
left
CardBuilderright
CardBuilder
Returns
- bool
true
if the specified CardBuilder is equal to the current CardBuilder; otherwise,false
.
operator !=(CardBuilder?, CardBuilder?)
Determines whether the specified CardBuilder is not equal to the current CardBuilder.
public static bool operator !=(CardBuilder? left, CardBuilder? right)
Parameters
left
CardBuilderright
CardBuilder
Returns
- bool
true
if the specified CardBuilder is not equal to the current CardBuilder; otherwise,false
.