Skip to content

Class TodoItem

Namespace: MyApp.Domain
Assembly: MyApp.Domain.dll

A single todo item in the example application.

public sealed record TodoItem : IEquatable<TodoItem>

Inheritance

object ← TodoItem

Implements

IEquatable<TodoItem>

Inherited Members

object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.ReferenceEquals(object?, object?), object.ToString()

Constructors

TodoItem(Guid, string, bool)

A single todo item in the example application.

public TodoItem(Guid Id, string Title, bool IsCompleted)

Parameters

Id Guid

The stable identifier of the item.

Title string

The human-readable title of the item.

IsCompleted bool

A value indicating whether the item is done.

Properties

Id

The stable identifier of the item.

public Guid Id { get; init; }

Property Value

Guid

IsCompleted

A value indicating whether the item is done.

public bool IsCompleted { get; init; }

Property Value

bool

Title

The human-readable title of the item.

public string Title { get; init; }

Property Value

string

Methods

Create(string)

Creates a new, uncompleted todo item with a fresh identifier.

public static TodoItem Create(string title)

Parameters

title string

The title of the item.

Returns

TodoItem

A new .

Exceptions

ArgumentException

Thrown when title is null or whitespace.

WithCompletion(bool)

Returns a copy of this item marked as completed or uncompleted.

public TodoItem WithCompletion(bool isCompleted)

Parameters

isCompleted bool

The new completion state.

Returns

TodoItem

A new with the given completion state.