

A second variation of the shopping cart DTOs using custom attributes. · GitHub
source link: https://gist.github.com/einarwh/edc260ed58992c53b4e9d8916301d1a6
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Instantly share code, notes, and snippets.
abstract class ShoppingCart { public ShoppingCart(string state) { State = state; } [JsonProperty("_state")] public string State { get; } }
class EmptyCart : ShoppingCart { public EmptyCart() : base("empty") {} }
class ActiveCart : ShoppingCart { public ActiveCart() : base("paid") { }
[JsonProperty("unpaidItems")] public Item[] UnpaidItems { get; set; } }
class PaidCart : ShoppingCart { public PaidCart() : base("paid") {} [JsonProperty("paidItems")] public Item[] PaidItems { get; set; }
[JsonProperty("payment")] public Money Payment { get; set; }
[JsonProperty("timestamp")] public string Timestamp { get; set; } }
class Item { [JsonProperty("id")] public string Id { get; set; }
[JsonProperty("title")] public string Title { get; set; }
[JsonProperty("description", NullValueHandling = NullValueHandling.Ignore)] public string Description { get; set; } }
class Money { [JsonProperty("amount")] public double Amount { get; set; }
[JsonProperty("currency")] public string Currency { get; set; } }
Recommend
-
8
How @dynamicMemberLookup Works Internally in Swift (+ Creating Custom Swift Attributes) How @dynamicMemberLookup Works Internally in Swift (+ Creating Custom Swift Attributes) December 6, 2018 Th...
-
13
A variation of shopping cart DTOs that violate C# naming standards for properties. · GitHub Instantly share code, notes, and snippets. A variation of...
-
18
Serializing paid cart DTO variation 1 as JSON text. · GitHub Instantly share code, notes, and snippets. Serializing paid cart DTO variation 1 as JSON...
-
13
A third variation of the shopping cart DTO Instantly share code, notes, and snippets. A third variation of the shopping cart DTO - everything at once...
-
13
Conversation Copy link Member ...
-
13
Solstice Based upon the famous IR_BLACK theme for VIM. Packaged to work with Vundle or Pathogen. To make this and other themes play nicely with your 256/16 colors terminal automagically, use something like
-
17
Custom security attributes in Azure AD part 3: working with custom security attributes After
-
11
Custom security attributes in Azure AD part 4: compare with older methods In previous articles of these series, we first looked at the various methods we could use to extend the Azure AD directory schema. Aft...
-
7
Custom security attributes in Azure AD part 1: a trip down memory lane While Azure AD has never been positioned as a direct replacement for Active Directory, many customers have expectations that functionalities t...
-
3
WordPress Block Editor - Adding a Query Block Variation with nested InnerBlocks As of October 29th, 2022, WordPress core does not have a Query block variation that includes the post's Categories. This code snippet fixes that....
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK