Skip to content

Instantly share code, notes, and snippets.

@einarwh
Last active August 13, 2020 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save einarwh/bb4809047c366132374dae89ab6b5b43 to your computer and use it in GitHub Desktop.
Save einarwh/bb4809047c366132374dae89ab6b5b43 to your computer and use it in GitHub Desktop.
A variation of shopping cart DTOs that violate C# naming standards for properties.
public abstract class ShoppingCart
{
public ShoppingCart(string state)
{
_state = state;
}
public string _state { get; }
}
public class EmptyCart : ShoppingCart
{
public EmptyCart() : base("empty") {}
}
public class ActiveCart : ShoppingCart
{
public ActiveCart() : base("active") { }
public Item[] unpaidItems { get; set; }
}
public class PaidCart : ShoppingCart
{
public PaidCart() : base("paid") {}
public object[] paidItems { get; set; }
public Money payment { get; set; }
public string timestamp { get; set; }
}
public class Item
{
public string id { get; set; }
public string title { get; set; }
public string description { get; set; }
}
public class Money
{
public float amount { get; set; }
public string currency { get; set; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment