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


C# org.Length方法代码示例

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


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

示例1: ToString

		/// <summary>Reverse the JSONML transformation, making an XML text from a JSONArray.</summary>
		/// <param name="ja">A JSONArray.</param>
		/// <returns>An XML string.</returns>
		/// <exception cref="JSONException"/>
		/// <exception cref="org.json.JSONException"/>
		public static string ToString(org.json.JSONArray ja)
		{
			int i;
			org.json.JSONObject jo;
			string key;
			System.Collections.Generic.IEnumerator<string> keys;
			int length;
			object @object;
			System.Text.StringBuilder sb = new System.Text.StringBuilder();
			string tagName;
			string value;
			// Emit <tagName
			tagName = ja.GetString(0);
			org.json.XML.NoSpace(tagName);
			tagName = org.json.XML.Escape(tagName);
			sb.Append('<');
			sb.Append(tagName);
			@object = ja.Opt(1);
			if (@object is org.json.JSONObject)
			{
				i = 2;
				jo = (org.json.JSONObject)@object;
				// Emit the attributes
				keys = jo.Keys();
				while (keys.HasNext())
				{
					key = keys.Next();
					org.json.XML.NoSpace(key);
					value = jo.OptString(key);
					if (value != null)
					{
						sb.Append(' ');
						sb.Append(org.json.XML.Escape(key));
						sb.Append('=');
						sb.Append('"');
						sb.Append(org.json.XML.Escape(value));
						sb.Append('"');
					}
				}
			}
			else
			{
				i = 1;
			}
			// Emit content in body
			length = ja.Length();
			if (i >= length)
			{
				sb.Append('/');
				sb.Append('>');
			}
			else
			{
				sb.Append('>');
				do
				{
					@object = ja.Get(i);
					i += 1;
					if (@object != null)
					{
						if (@object is string)
						{
							sb.Append(org.json.XML.Escape(@object.ToString()));
						}
						else
						{
							if (@object is org.json.JSONObject)
							{
								sb.Append(ToString((org.json.JSONObject)@object));
							}
							else
							{
								if (@object is org.json.JSONArray)
								{
									sb.Append(ToString((org.json.JSONArray)@object));
								}
								else
								{
									sb.Append(@object.ToString());
								}
							}
						}
					}
				}
				while (i < length);
				sb.Append('<');
				sb.Append('/');
				sb.Append(tagName);
				sb.Append('>');
			}
			return sb.ToString();
		}
开发者ID:davidraleigh,项目名称:geometry-api-cs-tests,代码行数:97,代码来源:JSONML.cs

示例2: ToString

		/// <summary>
		/// Produce a comma delimited text from a JSONArray of JSONObjects using
		/// a provided list of names.
		/// </summary>
		/// <remarks>
		/// Produce a comma delimited text from a JSONArray of JSONObjects using
		/// a provided list of names. The list of names is not included in the
		/// output.
		/// </remarks>
		/// <param name="names">A JSONArray of strings.</param>
		/// <param name="ja">A JSONArray of JSONObjects.</param>
		/// <returns>A comma delimited text.</returns>
		/// <exception cref="JSONException"/>
		/// <exception cref="org.json.JSONException"/>
		public static string ToString(org.json.JSONArray names, org.json.JSONArray ja)
		{
			if (names == null || names.Length() == 0)
			{
				return null;
			}
			System.Text.StringBuilder sb = new System.Text.StringBuilder();
			for (int i = 0; i < ja.Length(); i += 1)
			{
				org.json.JSONObject jo = ja.OptJSONObject(i);
				if (jo != null)
				{
					sb.Append(RowToString(jo.ToJSONArray(names)));
				}
			}
			return sb.ToString();
		}
开发者ID:davidraleigh,项目名称:geometry-api-cs-tests,代码行数:31,代码来源:CDL.cs

示例3: ToJSONArray

		/// <summary>
		/// Produce a JSONArray of JSONObjects from a comma delimited text string
		/// using a supplied JSONArray as the source of element names.
		/// </summary>
		/// <param name="names">A JSONArray of strings.</param>
		/// <param name="x">A JSONTokener of the source text.</param>
		/// <returns>A JSONArray of JSONObjects.</returns>
		/// <exception cref="JSONException"/>
		/// <exception cref="org.json.JSONException"/>
		public static org.json.JSONArray ToJSONArray(org.json.JSONArray names, org.json.JSONTokener x)
		{
			if (names == null || names.Length() == 0)
			{
				return null;
			}
			org.json.JSONArray ja = new org.json.JSONArray();
			for (; ; )
			{
				org.json.JSONObject jo = RowToJSONObject(names, x);
				if (jo == null)
				{
					break;
				}
				ja.Put(jo);
			}
			if (ja.Length() == 0)
			{
				return null;
			}
			return ja;
		}
开发者ID:davidraleigh,项目名称:geometry-api-cs-tests,代码行数:31,代码来源:CDL.cs

示例4: RowToString

		/// <summary>Produce a comma delimited text row from a JSONArray.</summary>
		/// <remarks>
		/// Produce a comma delimited text row from a JSONArray. Values containing
		/// the comma character will be quoted. Troublesome characters may be
		/// removed.
		/// </remarks>
		/// <param name="ja">A JSONArray of strings.</param>
		/// <returns>A string ending in NEWLINE.</returns>
		public static string RowToString(org.json.JSONArray ja)
		{
			System.Text.StringBuilder sb = new System.Text.StringBuilder();
			for (int i = 0; i < ja.Length(); i += 1)
			{
				if (i > 0)
				{
					sb.Append(',');
				}
				object @object = ja.Opt(i);
				if (@object != null)
				{
					string @string = @object.ToString();
					if (@string.Length > 0 && (@string.IndexOf(',') >= 0 || @string.IndexOf('\n') >= 0 || @string.IndexOf('\r') >= 0 || @string.IndexOf(0) >= 0 || @string[0] == '"'))
					{
						sb.Append('"');
						int length = @string.Length;
						for (int j = 0; j < length; j += 1)
						{
							char c = @string[j];
							if (c >= ' ' && c != '"')
							{
								sb.Append(c);
							}
						}
						sb.Append('"');
					}
					else
					{
						sb.Append(@string);
					}
				}
			}
			sb.Append('\n');
			return sb.ToString();
		}
开发者ID:davidraleigh,项目名称:geometry-api-cs-tests,代码行数:44,代码来源:CDL.cs

示例5: GetNames

		/// <summary>Get an array of field names from a JSONObject.</summary>
		/// <returns>An array of field names, or null if there are no names.</returns>
		public static string[] GetNames(org.json.JSONObject jo)
		{
			int length = jo.Length();
			if (length == 0)
			{
				return null;
			}
			System.Collections.Generic.IEnumerator<string> iterator = jo.Keys();
			string[] names = new string[length];
			int i = 0;
			while (iterator.HasNext())
			{
				names[i] = iterator.Next();
				i += 1;
			}
			return names;
		}
开发者ID:davidraleigh,项目名称:geometry-api-cs-tests,代码行数:19,代码来源:JSONObject.cs

示例6: ToJSONArray

		/// <summary>
		/// Produce a JSONArray containing the values of the members of this
		/// JSONObject.
		/// </summary>
		/// <param name="names">
		/// A JSONArray containing a list of key strings. This determines
		/// the sequence of the values in the result.
		/// </param>
		/// <returns>A JSONArray of values.</returns>
		/// <exception cref="JSONException">If any of the values are non-finite numbers.</exception>
		/// <exception cref="org.json.JSONException"/>
		public virtual org.json.JSONArray ToJSONArray(org.json.JSONArray names)
		{
			if (names == null || names.Length() == 0)
			{
				return null;
			}
			org.json.JSONArray ja = new org.json.JSONArray();
			for (int i = 0; i < names.Length(); i += 1)
			{
				ja.Put(this.Opt(names.GetString(i)));
			}
			return ja;
		}
开发者ID:davidraleigh,项目名称:geometry-api-cs-tests,代码行数:24,代码来源:JSONObject.cs


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