Castle.MonoRail.Views.Brail.BrailBase.SetOutputStream C# (CSharp) Method

SetOutputStream() public method

This is required because we may want to replace the output stream and get the correct behavior from components call RenderText() or RenderSection()
public SetOutputStream ( TextWriter newOutputStream ) : IDisposable
newOutputStream System.IO.TextWriter
return IDisposable
		public IDisposable SetOutputStream(TextWriter newOutputStream)
		{
			ReturnOutputStreamToInitialWriter disposable = new ReturnOutputStreamToInitialWriter(OutputStream, this);
			outputStream = newOutputStream;
			return disposable;
		}

Usage Example

 public void RenderBody(TextWriter writer)
 {
     if (body == null)
     {
         throw new MonoRailException("This component does not have a body content to be rendered");
     }
     using (parent.SetOutputStream(writer))
     {
         body.Call(new object[] { writer });
     }
 }