本文整理汇总了C#中System.IO.TextWriter.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# TextWriter.GetType方法的具体用法?C# TextWriter.GetType怎么用?C# TextWriter.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.TextWriter
的用法示例。
在下文中一共展示了TextWriter.GetType方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Create
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);
}
示例2: ClosePrintStream
public void ClosePrintStream(
TextWriter printStream)
{
if (printStream.GetType().ToString() == typeof(StreamWriter).ToString())
{
var streamWriter = (StreamWriter) printStream;
streamWriter.Close();
}
}
示例3: ContextInfo
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());
}
示例4: GetEncodedWriter
private static TextWriter GetEncodedWriter(TextWriter writer)
{
if(typeof(EncodedTextWriter).IsAssignableFrom(writer.GetType()))
{
return writer;
}
else
{
return new EncodedTextWriter(writer);
}
}
示例5: GetUnencodedWriter
private static TextWriter GetUnencodedWriter(TextWriter writer)
{
if (typeof(EncodedTextWriter).IsAssignableFrom(writer.GetType()))
{
return ((EncodedTextWriter)writer).UnderlyingWriter;
}
else
{
return writer;
}
}