public bool IsRush() { bool isRush = false; if (ShippingAddress.Country == "USA") { if (OrderTotal > 100) { if (OrderItems.Count(item => !item.IsInStock) == 0) { if (OrderItems.Count(item => item.ContainsHazardousMaterial) == 0) { isRush = true; } } } } return(isRush); #region var spec = new RushOrderSpecification(); return(spec.IsSatisfiedBy(this)); #endregion }
public static void Main(string[] args) { Console.WriteLine("Specification Pattern Demo"); RushOrderSpecification specification = new RushOrderSpecification(); bool response = specification.IsSatisfied( new Order { InStock = true, IsFlamable = false, Qty = 120, TotalAmount = 101 }); Console.WriteLine($"Can order by placed? {response}"); Console.ReadKey(); }