public void HandleDocument(Document document) { // тк документ хранит состояние, берем только нужный обработчик if (document.CurrentInstantion != this.InstansionType) { NextInstantion?.HandleDocument(document); return; } HandleDocumentInternal(document, () => MoveNext(document)); }
private void MoveNext(Document document) { if (NextInstantion == null) { Console.WriteLine("End chain"); return; } Console.WriteLine($"{this.GetType().Name} handled doc"); document.CurrentInstantion = NextInstantion.InstansionType; NextInstantion.HandleDocument(document); }