当前位置: 首页>>代码示例>>C#>>正文


C# TextWriter.ToString方法代码示例

本文整理汇总了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());
 }
开发者ID:ouyh18,项目名称:LteTools,代码行数:8,代码来源:FrameworkWriter.cs

示例2: ExecuteInternal

 internal void ExecuteInternal() {
     // See comments in GetSafeExecuteStartPageThunk().
     _safeExecuteStartPageThunk(() => {
         Output = new StringWriter(CultureInfo.InvariantCulture);
         Execute();
         Markup = new HtmlString(Output.ToString());
     });
 }
开发者ID:adrianvallejo,项目名称:MVC3_Source,代码行数:8,代码来源:ApplicationStartPage.cs

示例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;
 }
开发者ID:GloryChou,项目名称:roslyn,代码行数:8,代码来源:VisualBasicCompilerServer.cs

示例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();
        }
开发者ID:vosen,项目名称:agdur,代码行数:14,代码来源:TextGenerator.cs

示例5: WriteToString

 public string WriteToString(JSONNode pNode)
 {
     using (textWriter = new StringWriter())
     {
         WriteToStream(pNode, textWriter);
         return textWriter.ToString();
     }
 }
开发者ID:substans,项目名称:JohJSON,代码行数:8,代码来源:JSONNodeWriter.cs

示例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;
        }
开发者ID:nemec,项目名称:roslyn,代码行数:9,代码来源:CSharpCompilerServer.cs

示例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());
 }
开发者ID:Mvc-UpdatePanel,项目名称:Mvc.UpdatePanel,代码行数:11,代码来源:Utils.cs

示例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
         }
     }
 }
开发者ID:tocsoft,项目名称:WebsiteGenerator,代码行数:20,代码来源:JSMin.cs

示例9: MinifyToString

 public string MinifyToString(string src)
 {
     using(sr = new StreamReader(src))
     {
         using(sw = new StringWriter())
         {
             jsmin();
             return sw.ToString();
         }
     }
 }
开发者ID:leexioua2,项目名称:js-builder,代码行数:11,代码来源:JSMin.cs

示例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;
		}
开发者ID:Cyberbanan,项目名称:Unity3d.UI.Windows,代码行数:51,代码来源:NewScriptGenerator.cs

示例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;
 }
开发者ID:zhaoqingqing,项目名称:Unity_Utlity_Scripts,代码行数:14,代码来源:ExaminerVisitorDump.cs

示例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);
        }
开发者ID:jakubsuchybio,项目名称:MFF-Csharp,代码行数:17,代码来源:Huffman1Tests.cs

示例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;
            }
        }
开发者ID:refinedKing,项目名称:WeiXin--Vs2010-,代码行数:52,代码来源:TemplateManager.cs

示例14: GetWriteText

		/// <summary>
		/// 获取用户控件渲染的HTML代码
		/// </summary>
		/// <param name="writer"></param>
		/// <returns></returns>
		protected virtual string GetWriteText(TextWriter writer)
		{
			return writer.ToString();
		}
开发者ID:ChinaSuperLiu,项目名称:ClownFish.Mvc,代码行数:9,代码来源:UcExecutor.cs

示例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."));
		}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:30,代码来源:HelpOperations.cs


注:本文中的System.IO.TextWriter.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。