This file contains 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
using System; | |
using System.Collections.Generic; | |
namespace zharro.gists | |
{ | |
class ComparerFactory | |
{ | |
public static IComparer<T> Create<T>(Comparison<T> comparer) | |
{ | |
return new DelegateComparer<T>(comparer); |
This file contains 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
/// <summary> | |
/// Agent for interacting with file system | |
/// </summary> | |
public class FileSystemAgent : IFileSystemAgent | |
{ | |
public IList<string> ReadAllLines(string fileName) | |
{ | |
if (!File.Exists(fileName)) | |
{ | |
throw new ArgumentException($"File {fileName} doesn't exist"); |
This file contains 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
using System; | |
class DateTimeRange : ValueObject<DateTimeRange> | |
{ | |
public DateTime Start { get; } | |
public DateTime End { get; } | |
public DateTimeRange(DateTime start, DateTime end) | |
{ | |
Start = start; |
This file contains 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
using System; | |
class Appointment : Entity | |
{ | |
public string Title { get; set; } | |
public int PatientId { get; set; } | |
public int RoomId { get; private set; } | |
public int? DoctorId { get; set; } | |
public bool IsConfirmed { get; private set; } | |
// Value object |
This file contains 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 CustomerService | |
{ | |
public void Process(string customerName, string addressString) | |
{ | |
Address address = CreateAddress(addressString); | |
Customer customer = CreateCustomer(customerName, address); | |
SaveCustomer(customer); | |
} | |
private Address CreateAddress(string addressString) | |
{ |
This file contains 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
using System.Collections.Generic; | |
using System.IO; | |
using System.Linq; | |
namespace ImmutableClearing | |
{ | |
class ApplicationService | |
{ | |
private readonly string _directoryName; | |
private readonly Persister _persister; |