Recently I had to integrate with a “delivery” web service that provided it’s own contracts as part of a NuGet package. My immediate thought was “sweet, now I don’t have to do all of that boring typing to add all of the requisite types”. That was until I ran into some code that looks similar to this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
public abstract class BaseDeliverable { } public class CollectionDeliverable : BaseDeliverable { public string CollectionReference { get; set; } } public class QrCodeDeliverable : BaseDeliverable { public List<string> TicketIds { get; set; } public string QrCode { get; set; } } public class RequiresDocumentsDeliverable : BaseDeliverable { public List<Document> Documents { get; set; } } public class Delivery { public string Id { get; set; } public string Type { get; set; } public string State { get; set; } public string DisplayName { get; set; } public string Reference { get; set; } public List<BaseDeliverable> Deliverables { get; set; } } |
The problem When making calls to the delivery web service, the response was expected to be of type Delivery which is shown…
Read More Read More