Style: C# 12 Primary constructor
This commit is contained in:
@@ -8,10 +8,10 @@ public abstract class BaseEntity
|
||||
// Using non-generic integer types for simplicity
|
||||
public int Id { get; set; }
|
||||
|
||||
private readonly List<BaseEvent> _domainEvents = new();
|
||||
private readonly List<BaseEvent> _domainEvents = [];
|
||||
|
||||
[NotMapped]
|
||||
public IReadOnlyCollection<BaseEvent> DomainEvents => _domainEvents.AsReadOnly();
|
||||
public IEnumerable<BaseEvent> DomainEvents => _domainEvents.AsReadOnly();
|
||||
|
||||
public void AddDomainEvent(BaseEvent domainEvent)
|
||||
{
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// Learn more: https://docs.microsoft.com/en-us/dotnet/standard/microservices-architecture/microservice-ddd-cqrs-patterns/implement-value-objects
|
||||
public abstract class ValueObject
|
||||
{
|
||||
protected static bool EqualOperator(ValueObject left, ValueObject right)
|
||||
private static bool EqualOperator(ValueObject left, ValueObject right)
|
||||
{
|
||||
if (left is null ^ right is null)
|
||||
{
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
namespace Hutopy.Domain.Events;
|
||||
|
||||
public class TodoItemCompletedEvent : BaseEvent
|
||||
public class TodoItemCompletedEvent(
|
||||
TodoItem item)
|
||||
: BaseEvent
|
||||
{
|
||||
public TodoItemCompletedEvent(TodoItem item)
|
||||
{
|
||||
Item = item;
|
||||
}
|
||||
|
||||
public TodoItem Item { get; }
|
||||
public TodoItem Item { get; } = item;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
namespace Hutopy.Domain.Events;
|
||||
|
||||
public class TodoItemCreatedEvent : BaseEvent
|
||||
public class TodoItemCreatedEvent(
|
||||
TodoItem item)
|
||||
: BaseEvent
|
||||
{
|
||||
public TodoItemCreatedEvent(TodoItem item)
|
||||
{
|
||||
Item = item;
|
||||
}
|
||||
|
||||
public TodoItem Item { get; }
|
||||
public TodoItem Item { get; } = item;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
namespace Hutopy.Domain.Events;
|
||||
|
||||
public class TodoItemDeletedEvent : BaseEvent
|
||||
public class TodoItemDeletedEvent(
|
||||
TodoItem item)
|
||||
: BaseEvent
|
||||
{
|
||||
public TodoItemDeletedEvent(TodoItem item)
|
||||
{
|
||||
Item = item;
|
||||
}
|
||||
|
||||
public TodoItem Item { get; }
|
||||
public TodoItem Item { get; } = item;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
namespace Hutopy.Domain.Exceptions;
|
||||
|
||||
public class UnsupportedColourException : Exception
|
||||
{
|
||||
public UnsupportedColourException(string code)
|
||||
: base($"Colour \"{code}\" is unsupported.")
|
||||
{
|
||||
}
|
||||
}
|
||||
public class UnsupportedColourException(
|
||||
string code) : Exception($"Colour \"{code}\" is unsupported.");
|
||||
|
||||
@@ -47,7 +47,7 @@ public class Colour(string code) : ValueObject
|
||||
return Code;
|
||||
}
|
||||
|
||||
protected static IEnumerable<Colour> SupportedColours
|
||||
private static IEnumerable<Colour> SupportedColours
|
||||
{
|
||||
get
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user