This simple plugin allows you to create a fluent builde class for any POCO object. It is added to the right-click context menu when clicking on a .cs file in the Solution Explorer: For example, the class: C# Edit|Remove csharp public class CommitBooking { public string basketCode { get; set; } public string bookingType { get; set; } public string bookingReason { get; set; } public List<Paymentmethod> paymentMethods { get; set; } } public class CommitBooking { public string basketCode { get; set; } public string bookingType { get; set; } public string bookingReason { get; set; } public List<Paymentmethod> paymentMethods { get; set; } } Is created in a CommitBookingBuilder.cs like the below: C# Edit|Remove csharp public class CommitBookingBuilder { private CommitBooking p_commitbooking = new CommitBooking(); public CommitBookingBuilder basketCode(string basketcode) { p_commitbooking.basketCode = basketcode; return this; } public CommitBookingBuilder bookingType(string bookingtype) { p_commitbooking.bookingType = bookingtype; return this; } public CommitBookingBuilder bookingReason(string bookingreason) { p_commitbooking.bookingReason = bookingreason; return this; } public CommitBookingBuilder paymentMethods(System.Collections.Generic.List<DummyService.Paymentmethod> paymentmethods) { p_commitbooking.paymentMethods = paymentmethods; return this; } public CommitBooking build() { return p_commitbooking; } } public class CommitBookingBuilder { private CommitBooking p_commitbooking = new CommitBooking(); public CommitBookingBuilder basketCode(string basketcode) { p_commitbooking.basketCode = basketcode; return this; } public CommitBookingBuilder bookingType(string bookingtype) { p_commitbooking.bookingType = bookingtype; return this; } public CommitBookingBuilder bookingReason(string bookingreason) { p_commitbooking.bookingReason = bookingreason; return this; } public CommitBookingBuilder paymentMethods(System.Collections.Generic.List<DummyService.Paymentmethod> paymentmethods) { p_commitbooking.paymentMethods = paymentmethods; return this; } public CommitBooking build() { return p_commitbooking; } } Which allows you to express and build an object like this: C# Edit|Remove csharp CommitBooking c = new CommitBookingBuilder() .basketCode("123") .bookingType("ABC") .bookingReason("ZZZ") .build(); CommitBooking c = new CommitBookingBuilder() .basketCode("123") .bookingType("ABC") .bookingReason("ZZZ") .build(); If you do not call .build() then you will return a Builder object instead - which can be useful when you want to extend the builder in other ways. |