本文整理汇总了C#中org.Has方法的典型用法代码示例。如果您正苦于以下问题:C# org.Has方法的具体用法?C# org.Has怎么用?C# org.Has使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org
的用法示例。
在下文中一共展示了org.Has方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToString
/// <summary>Convert a JSONObject into an HTTP header.</summary>
/// <remarks>
/// Convert a JSONObject into an HTTP header. A request header must contain
/// <pre>{
/// Method: "POST" (for example),
/// "Request-URI": "/" (for example),
/// "HTTP-Version": "HTTP/1.1" (for example)
/// }</pre>
/// A response header must contain
/// <pre>{
/// "HTTP-Version": "HTTP/1.1" (for example),
/// "Status-Code": "200" (for example),
/// "Reason-Phrase": "OK" (for example)
/// }</pre>
/// Any other members of the JSONObject will be output as HTTP fields.
/// The result will end with two CRLF pairs.
/// </remarks>
/// <param name="jo">A JSONObject</param>
/// <returns>An HTTP header string.</returns>
/// <exception cref="JSONException">
/// if the object does not contain enough
/// information.
/// </exception>
/// <exception cref="org.json.JSONException"/>
public static string ToString(org.json.JSONObject jo)
{
System.Collections.Generic.IEnumerator<string> keys = jo.Keys();
string @string;
System.Text.StringBuilder sb = new System.Text.StringBuilder();
if (jo.Has("Status-Code") && jo.Has("Reason-Phrase"))
{
sb.Append(jo.GetString("HTTP-Version"));
sb.Append(' ');
sb.Append(jo.GetString("Status-Code"));
sb.Append(' ');
sb.Append(jo.GetString("Reason-Phrase"));
}
else
{
if (jo.Has("Method") && jo.Has("Request-URI"))
{
sb.Append(jo.GetString("Method"));
sb.Append(' ');
sb.Append('"');
sb.Append(jo.GetString("Request-URI"));
sb.Append('"');
sb.Append(' ');
sb.Append(jo.GetString("HTTP-Version"));
}
else
{
throw new org.json.JSONException("Not enough material for an HTTP header.");
}
}
sb.Append(CRLF);
while (keys.HasNext())
{
@string = keys.Next();
if (!"HTTP-Version".Equals(@string) && !"Status-Code".Equals(@string) && !"Reason-Phrase".Equals(@string) && !"Method".Equals(@string) && !"Request-URI".Equals(@string) && !jo.IsNull(@string))
{
sb.Append(@string);
sb.Append(": ");
sb.Append(jo.GetString(@string));
sb.Append(CRLF);
}
}
sb.Append(CRLF);
return sb.ToString();
}
示例2: ToString
/// <summary>Convert a JSONObject into a cookie specification string.</summary>
/// <remarks>
/// Convert a JSONObject into a cookie specification string. The JSONObject
/// must contain "name" and "value" members.
/// If the JSONObject contains "expires", "domain", "path", or "secure"
/// members, they will be appended to the cookie specification string.
/// All other members are ignored.
/// </remarks>
/// <param name="jo">A JSONObject</param>
/// <returns>A cookie specification string</returns>
/// <exception cref="JSONException"/>
/// <exception cref="org.json.JSONException"/>
public static string ToString(org.json.JSONObject jo)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append(Escape(jo.GetString("name")));
sb.Append("=");
sb.Append(Escape(jo.GetString("value")));
if (jo.Has("expires"))
{
sb.Append(";expires=");
sb.Append(jo.GetString("expires"));
}
if (jo.Has("domain"))
{
sb.Append(";domain=");
sb.Append(Escape(jo.GetString("domain")));
}
if (jo.Has("path"))
{
sb.Append(";path=");
sb.Append(Escape(jo.GetString("path")));
}
if (jo.OptBoolean("secure"))
{
sb.Append(";secure");
}
return sb.ToString();
}