forked from dotnet/samples
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
reworked Issue dotnet#6893 keeping existing subfolders for BillW
- Loading branch information
DickBaker
committed
Jun 1, 2024
1 parent
5ce1531
commit bcd3452
Showing
11 changed files
with
281 additions
and
179 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
csharp/tutorials/patterns/finished/toll-calculator/ExternalSystems-ctor.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// suggest owner refactor to constructor | ||
namespace ConsumerVehicleRegistration2 | ||
{ | ||
public class Car | ||
{ | ||
public Car(int passengers) => Passengers = passengers; | ||
|
||
public required int Passengers { get; set; } | ||
} | ||
} | ||
|
||
namespace CommercialRegistration2 | ||
{ | ||
public class DeliveryTruck | ||
{ | ||
public DeliveryTruck(int grossWeight) => GrossWeight = grossWeight; | ||
|
||
public required int GrossWeight { get; set; } | ||
} | ||
} | ||
|
||
namespace LiveryRegistration2 | ||
{ | ||
public class Taxi | ||
{ | ||
public Taxi(int fares) => Fares = fares; | ||
|
||
public required int Fares { get; set; } | ||
} | ||
|
||
public class Bus | ||
{ | ||
public Bus(int riders, int capacity = 90) | ||
{ | ||
Riders = riders; | ||
Capacity = capacity; | ||
} | ||
|
||
public required int Capacity { get; set; } | ||
public required int Riders { get; set; } | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
csharp/tutorials/patterns/finished/toll-calculator/ExternalSystems-pctor.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// suggest owner refactor to primary constructor | ||
namespace ConsumerVehicleRegistration3 | ||
{ | ||
public class Car(int passengers) | ||
{ | ||
public required int Passengers { get; set; } = passengers; | ||
} | ||
} | ||
|
||
namespace CommercialRegistration3 | ||
{ | ||
public class DeliveryTruck(int grossWeight) | ||
{ | ||
public required int GrossWeight { get; set; } = grossWeight; | ||
} | ||
} | ||
|
||
namespace LiveryRegistration3 | ||
{ | ||
public class Taxi(int fares) | ||
{ | ||
public required int Fares { get; set; } = fares; | ||
} | ||
|
||
public class Bus(int riders, int capacity = 90) | ||
{ | ||
public required int Capacity { get; set; } = capacity; | ||
public required int Riders { get; set; } = riders; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
csharp/tutorials/patterns/finished/toll-calculator/ExternalSystems-record.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// suggest owner refactor from class to positional record | ||
namespace ConsumerVehicleRegistration4 | ||
{ | ||
public record Car(int Passengers); | ||
} | ||
|
||
namespace CommercialRegistration4 | ||
{ | ||
public record DeliveryTruck(int GrossWeight); | ||
} | ||
|
||
namespace LiveryRegistration4 | ||
{ | ||
public record Taxi(int Fares); | ||
|
||
public record Bus(int Riders, int Capacity = 90); | ||
} |
14 changes: 8 additions & 6 deletions
14
csharp/tutorials/patterns/finished/toll-calculator/ExternalSystems.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,31 @@ | ||
namespace ConsumerVehicleRegistration | ||
// you are not owner, so YOU have no control over these external namespaces or definitions | ||
// but OWNER could refactor with constructor, or from class to positional record [examples below] | ||
namespace ConsumerVehicleRegistration | ||
{ | ||
public class Car | ||
{ | ||
public int Passengers { get; set; } | ||
public required int Passengers { get; set; } | ||
} | ||
} | ||
|
||
namespace CommercialRegistration | ||
{ | ||
public class DeliveryTruck | ||
{ | ||
public int GrossWeightClass { get; set; } | ||
public int GrossWeight { get; set; } = 4000; // default weight (hence required omitted) | ||
} | ||
} | ||
|
||
namespace LiveryRegistration | ||
{ | ||
public class Taxi | ||
{ | ||
public int Fares { get; set; } | ||
public required int Fares { get; set; } | ||
} | ||
|
||
public class Bus | ||
{ | ||
public int Capacity { get; set; } | ||
public int Riders { get; set; } | ||
public required int Capacity { get; set; } | ||
public required int Riders { get; 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
Oops, something went wrong.