This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public struct Email | |
{ | |
public string Value { get; } | |
public bool IsConfirmed { get; } | |
public Email(string value, bool isConfirmed) | |
{ | |
Value = value; | |
IsConfirmed = isConfirmed; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Customer | |
{ | |
private CustomerStatus _status = CustomerStatus.Regular; | |
public void Promote() | |
{ | |
_status = CustomerStatus.Preferred; | |
} | |
public decimal GetDiscount() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class OrderSubmitted : IDomainEvent | |
{ | |
public Order Order { get; } | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public abstract class ValueObject<T> | |
where T : ValueObject<T> | |
{ | |
public override bool Equals(object obj) | |
{ | |
var valueObject = obj as T; | |
if (ReferenceEquals(valueObject, null)) | |
return false; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Company | |
{ | |
public void AssignDelivery(Delivery delivery) | |
{ | |
if (!delivery.IsValid()) | |
throw new Exception(); | |
_deliveries.Add(delivery); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class Vector { | |
private _x: number; | |
private _y: number; | |
public getX(): number { | |
return this._x; | |
} | |
public getY(): number { | |
return this._y; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public struct DecimalGreaterThanZero : IEquatable<DecimalGreaterThanZero> | |
{ | |
private readonly decimal _value; | |
public DecimalGreaterThanZero(decimal value) | |
{ | |
if (CanCreate(value) == false) | |
throw new ArgumentException("Value must be greater than zero.", nameof(value)); | |
_value = value; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FurnitureEntity : Entity { /* ... */ } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Fabric : AggregateRootWithLinkedObjects | |
{ | |
public bool PreOrder { get; protected set; } | |
private string _Due { get; set; } | |
public Maybe<string> Due | |
{ | |
get => _Due; | |
protected set => _Due = value.Unwrap(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Fabric : AggregateRootWithLinkedObjects | |
{ | |
public bool PreOrder { get; protected set; } | |
private string _Due { get; set; } | |
public Maybe<string> Due | |
{ | |
get => _Due; | |
protected set => _Due = value.Unwrap(); | |
} |