本文整理汇总了C#中System.IO.TextWriter.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# TextWriter.ToString方法的具体用法?C# TextWriter.ToString怎么用?C# TextWriter.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.TextWriter
的用法示例。
在下文中一共展示了TextWriter.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Initialize
protected void Initialize()
{
KmlFramework framework = new KmlFramework("aaa");
writer = new StringWriter();
XmlWriter xmlWriter = framework.GenerateWriter(writer);
xmlWriter.Close();
reader = new StringReader(writer.ToString());
}
示例2: ExecuteInternal
internal void ExecuteInternal() {
// See comments in GetSafeExecuteStartPageThunk().
_safeExecuteStartPageThunk(() => {
Output = new StringWriter(CultureInfo.InvariantCulture);
Execute();
Markup = new HtmlString(Output.ToString());
});
}
示例3: Run
public override int Run(TextWriter consoleOutput, CancellationToken cancellationToken)
{
int runResult;
CompilerServerLogger.Log("****Running VB compiler...");
runResult = base.Run(consoleOutput, cancellationToken);
CompilerServerLogger.Log("****VB Compilation complete.\r\n****Return code: {0}\r\n****Output:\r\n{1}\r\n", runResult, consoleOutput.ToString());
return runResult;
}
示例4: Generate
/// <summary>
/// Generates output using the specified writer and output strategy.
/// </summary>
/// <param name="writer">The writer that should be used to generate the output.</param>
/// <param name="outputStrategy">The output strategy that should be used to generate the output.</param>
/// <returns>The output of a benchmark.</returns>
public string Generate(TextWriter writer, IOutputStrategy outputStrategy)
{
Ensure.NotNull(writer, "writer");
Ensure.NotNull(outputStrategy, "outputStrategy");
builder.ToCustom(writer).AsCustom(outputStrategy);
return writer.ToString();
}
示例5: WriteToString
public string WriteToString(JSONNode pNode)
{
using (textWriter = new StringWriter())
{
WriteToStream(pNode, textWriter);
return textWriter.ToString();
}
}
示例6: Run
public override int Run(TextWriter consoleOutput, CancellationToken cancellationToken = default(CancellationToken))
{
int returnCode;
CompilerServerLogger.Log("****Running C# compiler...");
returnCode = base.Run(consoleOutput, cancellationToken);
CompilerServerLogger.Log("****C# Compilation complete.\r\n****Return code: {0}\r\n****Output:\r\n{1}\r\n", returnCode, consoleOutput.ToString());
return returnCode;
}
示例7: 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());
}
示例8: Minify
//static void Main(string[] args)
//{
// if (args.Length != 2)
// {
// Console.WriteLine("invalid arguments, 2 required, 1 in, 1 out");
// return;
// }
// new JavaScriptMinifier().Minify(args[0], args[1]);
//}
public string Minify(string src)
{
using (sr = new StringReader(src))
{
using (sw = new StringWriter())
{
jsmin();
return sw.ToString(); // return the minified string
}
}
}
示例9: MinifyToString
public string MinifyToString(string src)
{
using(sr = new StreamReader(src))
{
using(sw = new StringWriter())
{
jsmin();
return sw.ToString();
}
}
}
示例10: ToString
public override string ToString() {
m_Text = m_ScriptPrescription.m_Template;
m_Writer = new StringWriter();
m_Writer.NewLine = "\n";
// Make sure all line endings are Unix (Mac OS X) format
m_Text = Regex.Replace(m_Text, @"\r\n?", delegate(Match m) {
return "\n";
});
// Class Name
m_Text = m_Text.Replace("$ClassName", ClassName);
m_Text = m_Text.Replace("$NicifiedClassName", ObjectNames.NicifyVariableName(ClassName));
// Other replacements
foreach (KeyValuePair<string, string> kvp in m_ScriptPrescription.m_StringReplacements) m_Text = m_Text.Replace(kvp.Key, kvp.Value);
// Functions
// Find $Functions keyword including leading tabs
Match match = Regex.Match(m_Text, @"(\t*)\$Functions");
if (match.Success) {
// Set indent level to number of tabs before $Functions keyword
IndentLevel = match.Groups[1].Value.Length;
bool hasFunctions = false;
if (m_ScriptPrescription.m_Functions != null) {
foreach (var function in m_ScriptPrescription.m_Functions.Where (f => f.include)) {
WriteFunction(function);
WriteBlankLine();
hasFunctions = true;
}
// Replace $Functions keyword plus newline with generated functions text
if (hasFunctions) m_Text = m_Text.Replace(match.Value + "\n", m_Writer.ToString());
}
if (!hasFunctions) {
/*if (m_ScriptPrescription.m_Lang == Language.Boo && !m_Text.Contains ("def"))
// Replace $Functions keyword with "pass" if no functions in Boo
m_Text = m_Text.Replace (match.Value, m_Indentation + "pass");
else*/
// Otherwise just remove $Functions keyword plus newline
m_Text = m_Text.Replace(match.Value + "\n", string.Empty);
}
}
// Put curly vraces on new line if specified in editor prefs
if (EditorPrefs.GetBool("CurlyBracesOnNewLine")) PutCurveBracesOnNewLine();
// Return the text of the script
return m_Text;
}
示例11: DumpToString
public string DumpToString(IEnumerable objects, SceneVisitor.Options options)
{
string results = null;
using (StringWriter stringWriter = new StringWriter())
{
mWriter = stringWriter;
Traverse(objects, options);
results = mWriter.ToString();
}
mWriter = null;
return results;
}
示例12: Assert_Stream_File_Are_Equals
public void Assert_Stream_File_Are_Equals(TextWriter writer, string expectedFile)
{
string tempFileName = System.IO.Path.GetTempFileName();
File.WriteAllBytes(tempFileName, Encoding.UTF8.GetBytes(writer.ToString()));
BinaryReader expected = new BinaryReader(File.OpenRead(expectedFile));
BinaryReader actual = new BinaryReader(File.OpenRead(tempFileName));
Assert.AreEqual(expected.BaseStream.Length, actual.BaseStream.Length);
while(expected.BaseStream.Length == expected.BaseStream.Position || actual.BaseStream.Length == actual.BaseStream.Position) {
Assert.AreEqual(expected.ReadByte(), actual.ReadByte());
}
expected.Close();
actual.Close();
File.Delete(tempFileName);
}
示例13: ProcessTemplate
protected void ProcessTemplate(string name, Tag tag)
{
if (customTags != null && customTags.ContainsKey(name))
{
ExecuteCustomTag(tag);
return;
}
Template useTemplate = currentTemplate.FindTemplate(name);
if (useTemplate == null)
{
string msg = string.Format("Template '{0}' not found", name);
throw new TemplateRuntimeException(msg, tag.Line, tag.Col);
}
// process inner elements and save content
TextWriter saveWriter = writer;
writer = new StringWriter();
string content = string.Empty;
try
{
ProcessElements(tag.InnerElements);
content = writer.ToString();
}
finally
{
writer = saveWriter;
}
Template saveTemplate = currentTemplate;
variables = new VariableScope(variables);
variables["innerText"] = content;
try
{
foreach (TagAttribute attrib in tag.Attributes)
{
object val = EvalExpression(attrib.Expression);
variables[attrib.Name] = val;
}
currentTemplate = useTemplate;
ProcessElements(currentTemplate.Elements);
}
finally
{
variables = variables.Parent;
currentTemplate = saveTemplate;
}
}
示例14: GetWriteText
/// <summary>
/// 获取用户控件渲染的HTML代码
/// </summary>
/// <param name="writer"></param>
/// <returns></returns>
protected virtual string GetWriteText(TextWriter writer)
{
return writer.ToString();
}
示例15: CheckExternalMonodoc
void CheckExternalMonodoc ()
{
firstCall = false;
try {
outWriter = new StringWriter ();
errWriter = new StringWriter ();
pw = Runtime.ProcessService.StartProcess (
"monodoc", "--help", "", outWriter, errWriter,
delegate {
if (pw.ExitCode != 0)
MessageService.ShowError (
String.Format (
"MonoDoc exited with a exit code = {0}. Error : {1}",
pw.ExitCode, errWriter.ToString ()));
pw = null;
}, true);
pw.WaitForOutput ();
if (outWriter.ToString ().IndexOf ("--about") > 0)
useExternalMonodoc = true;
pw = null;
} catch (Exception e) {
MessageService.ShowError (String.Format (
"Could not start monodoc : {0}", e.ToString ()));
}
if (!useExternalMonodoc)
MessageService.ShowError (
GettextCatalog.GetString ("You need a newer monodoc to use it externally from monodevelop. Using the integrated help viewer now."));
}