本文整理汇总了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> <small>(left
/// brace)</small> and ending with <code>}</code> <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();
}
}
示例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 </, producing <\/,
/// 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;
}
}
}