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 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 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
| Customer customer = await session.GetAsync<Customer>(1); |
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 static class Calculator | |
| { | |
| public static int Add(int value1, int value2) | |
| { | |
| return value1 + value2; | |
| } | |
| } |
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 AllowanceAmount : ValueObject | |
| { | |
| public const int MaxLength = 50; | |
| public string Value { get; } | |
| private AllowanceAmount(string 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 Customer | |
| { | |
| public string Name { get; set; } | |
| public string Email { get; set; } | |
| } | |
| Customer customer = GetCustomer(); | |
| customer.Name = customer.Email; // Compiles perfectly |
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 OrderRepository | |
| { | |
| public void Save(Order order) | |
| { | |
| /* ... */ | |
| } | |
| public Order GetById(long id) | |
| { | |
| /* ... */ |
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 StatisticsCalculator | |
| { | |
| public async Task<(double weightDelivered, double totalCost)> Calculate(int customerId) | |
| { | |
| List<DeliveryRecord> records = await GetDeliveries(customerId); | |
| double weightDelivered = records.Sum(x => x.Weight); | |
| double totalCost = records.Sum(x => x.Cost); | |
| return (weightDelivered, totalCost); |
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 SomeService | |
| { | |
| public void FirePeriodicJob() | |
| { | |
| /* Runs asynchronously */ | |
| } | |
| } |