chore: format corrections

This commit is contained in:
Oli Sturm
2023-10-20 10:10:20 +01:00
parent a2d1e4adc2
commit 0957d0c6ed
11 changed files with 110 additions and 31 deletions
+13 -10
View File
@@ -1,19 +1,23 @@
namespace CS9 {
// ReSharper disable All
namespace CS9 {
class Program {
// Relational patterns (>= operator et al.)
// Logical patterns ("or", also "and" and "not")
// Note: parens ( and ) can be used to determine precedence
bool IsPastMidYear(DateTime dt) => dt is { Month: >= 7 };
bool IsThisYearOrLast(DateTime dt) => dt is { Year: 2022 or 2021 };
bool IsSummer(DateTime dt) => dt is
{ Month: 7 or 8 } or
{ Month: 6, Day: >= 21 } or
{ Month: 9, Day: < 21 };
{ Month: 7 or 8 } or
{ Month: 6, Day: >= 21 } or
{ Month: 9, Day: < 21 };
// Class with "Deconstruct" implementation
class Order {
public int ItemCount { get; set; }
public double ItemPrice { get; set; }
public void Deconstruct(out int itemCount, out double itemPrice) {
itemCount = ItemCount;
itemPrice = ItemPrice;
@@ -24,17 +28,16 @@
ValuableDueToHighCount,
ValuableDueToHighItemPrice,
ValuableDueToHighTotal,
NotValuable,
NotValuable
}
// Positional patterns with placeholders - note that
// the element lists must be "complete"!
static OrderValue OrderValueCategory(Order o) =>
o switch
{
( < 0, _) => throw new ArgumentException("Positive itemCounts please!"),
o switch {
(< 0, _) => throw new ArgumentException("Positive itemCounts please!"),
(_, < 0) => throw new ArgumentException("Positive itemPrices please!"),
( >= 100, _) => OrderValue.ValuableDueToHighCount,
(>= 100, _) => OrderValue.ValuableDueToHighCount,
(_, >= 1000) => OrderValue.ValuableDueToHighItemPrice,
// Assign variable names for further processing
@@ -47,4 +50,4 @@
static void Main(string[] args) {
}
}
}
}