/** **************************************************************************************** * Sets a new writer. The actual writer is implemented as a stack. It is important to * keep the right order when pushing and popping writers, as there lifetime is externally * managed. (In standard use-cases, only one, app-specific writer should be pushed anyhow). * To give a little assurance, method #PopWriter takes the same parameter as this method * does, to verify if if the one to be removed is really the topmost. * * @param newWriter The writer to use. ******************************************************************************************/ public void PushWriter(ReportWriter newWriter) { try { Lock.Acquire(); if (writers.Count > 0) { writers.Peek().NotifyActivation(Phase.End); } writers.Push(newWriter); newWriter.NotifyActivation(Phase.Begin); } finally { Lock.Release(); } }
/** **************************************************************************************** * Sets a new writer. The actual writer is implemented as a stack. It is important to * keep the right order when pushing and popping writers, as there lifetime is externally * managed. (In standard use-cases, only one, app-specific writer should be pushed anyhow). * To give a little assurance, method #PopWriter takes the same parameter as this method * does, to verify if if the one to be removed is really the topmost. * * @param newWriter The writer to use. ******************************************************************************************/ public void PushWriter( ReportWriter newWriter ) { try { Lock.Acquire(); if ( writers.Count > 0 ) writers.Peek().NotifyActivation( Phase.End ); writers.Push( newWriter ); newWriter.NotifyActivation( Phase.Begin ); } finally { Lock.Release(); } }