public static TextWriterOriginator Create(TextWriter writer)
 {
     if (writer is SpoolWriter)
         return new SpoolWriterOriginator((SpoolWriter) writer);
     if (writer is StringWriter)
         return new StringWriterOriginator((StringWriter)writer);
     throw new InvalidCastException("writer is unknown type " + writer.GetType().FullName);
 }
 public void ClosePrintStream(
     TextWriter printStream)
 {
     if (printStream.GetType().ToString() == typeof(StreamWriter).ToString())
     {
         var streamWriter = (StreamWriter) printStream;
         streamWriter.Close();
     }
 }
Example #3
0
 public static IHtmlString ContextInfo(TextWriter writer)
 {
     var res = new StringBuilder();
     res.AppendLine("<pre style='margin:10px'>");
     res.AppendLine("TextWriter");
     res.AppendLine("Type: {0}", writer.GetType().Name);
     res.AppendLine("TextWriter.GetHashCode:{0}", writer.GetHashCode());
     res.AppendLine("TextWriter.ToString:{0}", writer.ToString());
     res.AppendLine("</pre>");
     return new MvcHtmlString(res.ToString());
 }
 private static TextWriter GetEncodedWriter(TextWriter writer)
 {
     if(typeof(EncodedTextWriter).IsAssignableFrom(writer.GetType()))
     {
         return writer;
     }
     else
     {
         return new EncodedTextWriter(writer);
     }
 }
 private static TextWriter GetUnencodedWriter(TextWriter writer)
 {
     if (typeof(EncodedTextWriter).IsAssignableFrom(writer.GetType()))
     {
         return ((EncodedTextWriter)writer).UnderlyingWriter;
     }
     else
     {
         return writer;
     }
 }