1 // ****************************************************************
\r
2 // Copyright 2008, Charlie Poole
\r
3 // This is free software licensed under the NUnit license. You may
\r
4 // obtain a copy of the license at http://nunit.org/?p=license&r=2.4
\r
5 // ****************************************************************
\r
12 /// Abstract base for classes that capture text output
\r
13 /// and redirect it to a TextWriter.
\r
15 public abstract class TextCapture
\r
17 #region Private Fields
\r
19 /// True if capture is enabled
\r
21 private bool enabled;
\r
24 /// The TextWriter to which text is redirected
\r
26 private TextWriter writer;
\r
31 /// The TextWriter to which text is redirected
\r
33 public TextWriter Writer
\r
35 get { return writer; }
\r
40 if (writer != null && enabled)
\r
46 /// Controls whether text is captured or not
\r
50 get { return enabled; }
\r
53 if (enabled != value)
\r
55 if (writer != null && enabled)
\r
60 if (writer != null && enabled && DefaultThreshold != "Off")
\r
67 /// Returns the default threshold value, which represents
\r
68 /// the degree of verbosity of the output text stream.
\r
69 /// Returns "None" in the base class. Derived classes that
\r
70 /// support verbosity levels should override it.
\r
72 public virtual string DefaultThreshold
\r
74 get { return "None"; }
\r
78 #region Abstract Members
\r
80 /// Override this to perform whatever actions are needed
\r
81 /// to start capturing text and sending it to the Writer.
\r
83 protected abstract void StartCapture();
\r
86 /// Override this to perform whatever actions are needed
\r
87 /// to flush remaining output and stop capturing text.
\r
88 /// The Writer should not be changed, allowing capture
\r
89 /// to be restarted at a future point.
\r
91 protected abstract void StopCapture();
\r