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
<?xml version="1.0" encoding="utf-8"?> | |
<feed xmlns="http://www.w3.org/2005/Atom"> | |
<title>Example Feed</title> | |
<subtitle>A subtitle.</subtitle> | |
<link href="http://example.org/feed/" rel="self" /> | |
<id>urn:uuid:60a76c80-d399-11d9-b91C-0003939e0af6</id> | |
<updated>2003-12-13T18:30:02Z</updated> | |
<author> | |
<name>John Doe</name> | |
<email>johndoe@example.com</email> |
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 static Func<T> Retry(Func<T> original, int retryCount) | |
{ | |
return () => | |
{ | |
while (true) | |
{ | |
try | |
{ | |
return original(); | |
} |
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> | |
/// Utility methods for <see cref="System.Threading.Tasks.Task"/>. | |
/// </summary> | |
public static class TaskHelper | |
{ | |
/// <summary> | |
/// Returns a task which retries the task returned by the specified task provider. | |
/// </summary> | |
/// <typeparam name="TResult"></typeparam> | |
/// <param name="taskProvider">The task returning function.</param> |
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
// A repository. | |
public interface IPurchaseOrderRepository | |
{ | |
PurchaseOrder Get(string id); | |
// The commit method would likely be moved to a Unit of Work managed by infrastructure. | |
void Commit(); | |
} | |
// A marker interface for a domain event. | |
public interface IDomainEvent { } |
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 Order | |
{ | |
public string Id { get; private set; } | |
public string Number { get; private set; } | |
public string CustomerId { get; private set; } | |
public DateTime Date { get; private set; } | |
public ICollection<OrderLineItem> Items { get; private set; } | |
public decimal ShippingCharge { get; private set; } | |
public decimal TaxCharge { get; private set; } | |
public decimal Total |
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 interface IOrderRepository | |
{ | |
Order Get(string Id); | |
IList<Order> GetMostRecent(string customerId, int max = 20); | |
void Add(Order order); | |
void Remove(string Id); | |
} |
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
select top(@max) | |
Id, | |
OrderNumber, | |
Date, | |
Total = o.TaxCharge + o.ShippingCharge + (select sum(i.Amount * i.Quantity) from OrderLineItems i where i.OrderId = o.Id) | |
from Orders o | |
where o.CustomerId = @customerId | |
order by o.Date desc |
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 OrderReadModel | |
{ | |
public string Id { get; private set; } | |
public string OrderNumber { get; private set; } | |
public DateTime Date { get; private set; } | |
public decimal Total { get; private set; } | |
} |
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 UserProfile | |
{ | |
public UserProfile(string name) | |
{ | |
this.Name = name; | |
} | |
public string Name | |
{ | |
get { return _name; } |
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 UserProfile | |
{ | |
public string Name { get; set; } | |
// implementation omitted | |
public bool IsValid { get; } | |
} | |
var profile = new UserProfile(); | |
// must query to ascertain validity | |
if (!profile.IsValid) |
OlderNewer