public Cook(IPublisher publisher, IHorn horn, string cookName, int processingTime) { _publisher = publisher; _horn = horn; _cookName = cookName; _processingTime = processingTime; }
private static void StartPrintingQueueStats(IHorn horn, IList <ITrackable> trackables, StatsProjection statsProjection) { var thread = new Thread(() => { while (true) { horn.Note("[stats]: " + JsonConvert.SerializeObject(new { queueLengths = trackables.ToDictionary(x => x.QueueName, x => x.QueueDepth), statsProjection = statsProjection }, Formatting.Indented)); Thread.Sleep(500); } }) { IsBackground = true }; thread.Start(); }
IHorn horn; // IHorn (Interface) là một Dependecy của Car public Car(IHorn horn) => this.horn = horn; // Inject từ hàm tạo
public Cashier(IPublisher publisher, IHorn horn) { _publisher = publisher; _horn = horn; }
public Waiter(IPublisher publisher, IHorn horn) { _publisher = publisher; _horn = horn; }
public Printer(IHorn horn) { _horn = horn; }
public AssistantManager(IPublisher publisher, IHorn horn) { _publisher = publisher; _horn = horn; }
IHorn horn; // horn là một Dependecy của Car, triển khai từ Interface IHorn public Car(IHorn horn) => this.horn = horn;