/// <summary>
        /// This method is called to give the listener a chance to replace the TextWriter
        /// used to render the page.
        /// </summary>
        /// <param name="writer">The original TextWriter for the output stream</param>
        /// <returns>A TextWriter that will be used for writing the output.</returns>
        public TextWriter DecorateWriter(TextWriter writer)
        {
            try
            {
                TextWriterDecorator decorator = new TextWriterDecorator(writer, this, _writers.Count);

                foreach (TextWriterDecorator existingWriter in _writers)
                {
                    AddTextRelationship(existingWriter, decorator);
                }

                _writers.Add(decorator);

                return(decorator);
            }
            catch
            {
                return(writer);
            }
        }
 internal void AddTextRelationship(TextWriterDecorator copyingToWriter, TextWriterDecorator copyingFromWriter)
 {
     _mappingDataWriter.WriteTextRelationship(copyingToWriter.RenderedOutputIndex, copyingFromWriter.RenderedOutputIndex, copyingToWriter.OutputPosition);
 }
 public PageExecutionContext(MappingDataWriter mappingDataWriter, string sourceFilePath, TextWriter writer)
 {
     _mappingDataWriter = mappingDataWriter;
     _sourceFilePath    = sourceFilePath;
     _writer            = writer as TextWriterDecorator;
 }