public Workflow() { invalidOrder = new OrderError(); invalidZipCodeErrorCollection = new OrderErrorCollection(); invalidItemNumErrorCollection = new OrderErrorCollection(); invalidOrdersCollection = new OrderErrorCollection(); InitializeComponent(); }
// The definition of the extension method for the class OrderErrorCollection. public static void PrintOrderErrors(this OrderErrorCollection orderErrorCollection) { Console.WriteLine(); foreach (OrderError orderError in orderErrorCollection) { Console.WriteLine(orderError.ErrorText); } }
// Overload the operator + for two OrderErrorCollection objects. public static OrderErrorCollection operator +(OrderErrorCollection orderErrorCollection1, OrderErrorCollection orderErrorCollection2) { OrderErrorCollection orderErrorCollection = new OrderErrorCollection(); if (null != orderErrorCollection1) { foreach (OrderError orderError in orderErrorCollection1) { orderErrorCollection.Add(orderError); } } if (null != orderErrorCollection2) { foreach (OrderError orderError in orderErrorCollection2) { orderErrorCollection.Add(orderError); } } return(orderErrorCollection); }