public void Process(TableRequests table) { var chickens = table[typeof(Chicken)]; for (int i = 0; i < chickens.Length; i++) { var chicken = (Chicken)chickens[i]; chicken.Obtain(); chicken.CutUp(); chicken.Cook(); } var eggs = table[typeof(Egg)]; for (int i = 0; i < eggs.Length; i++) { using (var egg = (Egg)eggs[i]) { egg.Obtain(); try { egg.Crack(); } catch { } egg.Cook(); } } }
public void Process(TableRequests table) { var foods = table.Get <Food>(); foreach (Food food in foods) { food.Prepare(); } Processed?.Invoke(table); }
public void Process(TableRequests table) { lock (locker) { l = true; var foods = table.Get <Food>(); Parallel.ForEach(foods, food => { Food f = (Food)food; f.Prepare(); }); Thread.Sleep(30000); l = false; } }
public void Processed(TableRequests tableRequests) { foreach (KeyValuePair <string, List <IMenuItem> > row in tableRequests) { var ch = 0; var e = 0; Type t = null; foreach (IMenuItem value in row.Value) { if (value is Chicken) { ch++; } else if (value is Egg) { e++; } else if (value is Drink) { t = value.GetType(); } } var str = $"Customer {row.Key} is served {ch} chicken, {e} egg, "; if (t != null) { str += $"{t.Name}"; } else { str += "no drinks"; } resultOfCooks.Add(str); } served = false; tableRequests.Clear(); }
public Server() { cook = new Cook(); tableRequests = new TableRequests(); }
public Server() { resultOfCooks = new List <string>(); tableRequests = new TableRequests(); }