private void Foo4() { OrderLine apple = new OrderLine(quantity: 1, unitPrice: 2.5m, discount: 0.0f); Order order = new Order(ImmutableList.Create(apple)); order.Lines.ToList().ForEach((c) => Console.WriteLine(c.Discount)); OrderLine discountedApple = apple.WithDiscount(0.3f); Order discountedOrder = order.ReplaceLine(apple, discountedApple); discountedOrder.Lines.ToList().ForEach((c) => Console.WriteLine(c.Discount)); }
public Order RemoveLine(OrderLine value) { return WithLines(Lines.Remove(value)); }
public Order AddLine(OrderLine value) { return WithLines(Lines.Add(value)); }
public Order ReplaceLine(OrderLine oldValue, OrderLine newValue) { return oldValue == newValue ? this : WithLines(Lines.Replace(oldValue, newValue)); }