Table of Contents

Class ImageElementBuilder

Namespace
Kook
Assembly
Kook.Net.Core.dll

An element builder to build an ImageElement.

public class ImageElementBuilder : IElementBuilder, IEquatable<ImageElementBuilder>, IEquatable<IElementBuilder>
Inheritance
ImageElementBuilder
Implements
Inherited Members

Constructors

ImageElementBuilder()

Initialized a new instance of the ImageElementBuilder class.

public ImageElementBuilder()

ImageElementBuilder(string, string?, ImageSize, bool)

Initialized a new instance of the ImageElementBuilder class.

public ImageElementBuilder(string source, string? alternative = null, ImageSize size = ImageSize.Small, bool circle = false)

Parameters

source string

The source of the image.

alternative string

The alternative text of the image.

size ImageSize

The size of the image.

circle bool

Whether the image should be rendered as a circle.

Fields

MaxAlternativeLength

Gets the maximum image alternative text length allowed by Kook.

public const int MaxAlternativeLength = 20

Field Value

int

Properties

Alternative

Gets or sets the alternative text of an ImageElementBuilder.

public string? Alternative { get; set; }

Property Value

string

A string that represents the alternative text of the ImageElementBuilder.

Circle

Gets or sets whether the image should be rendered as a circle.

public bool? Circle { get; set; }

Property Value

bool?

true if the image should be rendered as a circle; otherwise, false; or null if whether the image should be rendered as a circle is not specified.

Size

Gets or sets the size of the image of an ImageElementBuilder.

public ImageSize? Size { get; set; }

Property Value

ImageSize?

An ImageSize that represents the size of the image of the ImageElementBuilder; null if the size is not specified.

Source

Gets or sets the source of an ImageElementBuilder.

public string? Source { get; set; }

Property Value

string

A string that represents the source of the ImageElementBuilder.

Type

Gets the type of the element that this builder builds.

public ElementType Type { get; }

Property Value

ElementType

An ElementType that represents the type of element that this builder builds.

Methods

Build()

Builds the ImageElementBuilder into an ImageElement.

public ImageElement Build()

Returns

ImageElement

An ImageElement represents the built element object.

Exceptions

ArgumentNullException

The Source url is null.

ArgumentException

The Source url is empty.

InvalidOperationException

The Source url does not include a protocol (either HTTP or HTTPS).

ArgumentException

The length of Alternative is greater than MaxAlternativeLength.

Equals(ImageElementBuilder?)

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

public bool Equals(ImageElementBuilder? imageElementBuilder)

Parameters

imageElementBuilder ImageElementBuilder

The ImageElementBuilder to compare with the current ImageElementBuilder.

Returns

bool

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

Equals(object?)

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

public override bool Equals(object? obj)

Parameters

obj object

The object to compare with the current ImageElementBuilder.

Returns

bool

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

GetHashCode()

Serves as the default hash function.

public override int GetHashCode()

Returns

int

A hash code for the current object.

WithAlternative(string?)

Sets the alternative text of an ImageElementBuilder.

public ImageElementBuilder WithAlternative(string? alternative)

Parameters

alternative string

The alternative text to be set.

Returns

ImageElementBuilder

The current builder.

WithCircle(bool?)

Sets whether the image should be rendered as a circle.

public ImageElementBuilder WithCircle(bool? circle)

Parameters

circle bool?

true if the image should be rendered as a circle; otherwise, false.

Returns

ImageElementBuilder

The current builder.

WithSize(ImageSize?)

Sets the size of the image of an ImageElementBuilder.

public ImageElementBuilder WithSize(ImageSize? size)

Parameters

size ImageSize?

The size to be set.

Returns

ImageElementBuilder

The current builder.

WithSource(string?)

Sets the source of an ImageElementBuilder.

public ImageElementBuilder WithSource(string? source)

Parameters

source string

The source to be set.

Returns

ImageElementBuilder

The current builder.

Operators

operator ==(ImageElementBuilder?, ImageElementBuilder?)

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

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

Parameters

left ImageElementBuilder
right ImageElementBuilder

Returns

bool

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

implicit operator ImageElementBuilder(string)

Initialized a new instance of the ImageElementBuilder class with the specified content.

public static implicit operator ImageElementBuilder(string source)

Parameters

source string

The content of the ImageElement.

Returns

ImageElementBuilder

An ImageElementBuilder object that is initialized with the specified image source.

operator !=(ImageElementBuilder?, ImageElementBuilder?)

Determines whether the specified ImageElementBuilder is not equal to the current ImageElementBuilder.

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

Parameters

left ImageElementBuilder
right ImageElementBuilder

Returns

bool

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