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


C# System.IO.StringWriter.GetBuffer方法代码示例

本文整理汇总了C#中System.IO.StringWriter.GetBuffer方法的典型用法代码示例。如果您正苦于以下问题:C# System.IO.StringWriter.GetBuffer方法的具体用法?C# System.IO.StringWriter.GetBuffer怎么用?C# System.IO.StringWriter.GetBuffer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.IO.StringWriter的用法示例。


在下文中一共展示了System.IO.StringWriter.GetBuffer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ToString

		/// <summary>Make a prettyprinted JSON text of this JSONObject.</summary>
		/// <remarks>
		/// Make a prettyprinted JSON text of this JSONObject.
		/// <p>
		/// Warning: This method assumes that the data structure is acyclical.
		/// </remarks>
		/// <param name="indentFactor">The number of spaces to add to each level of indentation.</param>
		/// <returns>
		/// a printable, displayable, portable, transmittable representation
		/// of the object, beginning with <code>{</code>&nbsp;<small>(left
		/// brace)</small> and ending with <code>}</code>&nbsp;<small>(right
		/// brace)</small>.
		/// </returns>
		/// <exception cref="JSONException">If the object contains an invalid number.</exception>
		/// <exception cref="org.json.JSONException"/>
		public virtual string ToString(int indentFactor)
		{
			System.IO.StringWriter w = new System.IO.StringWriter();
			lock (w.GetBuffer())
			{
				return this.Write(w, indentFactor, 0).ToString();
			}
		}
开发者ID:davidraleigh,项目名称:geometry-api-cs-tests,代码行数:23,代码来源:JSONObject.cs

示例2: Quote

		/// <summary>
		/// Produce a string in double quotes with backslash sequences in all the
		/// right places.
		/// </summary>
		/// <remarks>
		/// Produce a string in double quotes with backslash sequences in all the
		/// right places. A backslash will be inserted within &lt;/, producing &lt;\/,
		/// allowing JSON text to be delivered in HTML. In JSON text, a string cannot
		/// contain a control character or an unescaped quote or backslash.
		/// </remarks>
		/// <param name="string">A String</param>
		/// <returns>A String correctly formatted for insertion in a JSON text.</returns>
		public static string Quote(string @string)
		{
			System.IO.StringWriter sw = new System.IO.StringWriter();
			lock (sw.GetBuffer())
			{
				try
				{
					return Quote(@string, sw).ToString();
				}
				catch (System.IO.IOException)
				{
					// will never happen - we are writing to a string writer
					return string.Empty;
				}
			}
		}
开发者ID:davidraleigh,项目名称:geometry-api-cs-tests,代码行数:28,代码来源:JSONObject.cs


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