/// <summary> /// interface method that process the document /// </summary> /// <param name="doc">document containing the customer order</param> /// <returns>response document</returns> public IDocument ProcessDocument(IDocument doc) { IDocument request = null; IDocument response = null; nextComponent.Request = doc; //Start each processing unit by calling Accept(v) method while (nextComponent != null) { //trigger the process flow logics nextComponent.Accept(v); request = nextComponent.Request; response = nextComponent.Response; //set the next proessing unit nextComponent = nextComponent.NextComponent; //if this is the last processing unit, retrieve //the request and response document if (nextComponent != null) { nextComponent.Request = request; nextComponent.Response = response; } } //if next document layer exist, proceed with the next layer. if (Next != null) { response = Next.ProcessDocument(response); } return(response); }