Rhino.ScriptRuntime.DefaultObjectToSource C# (CSharp) Method

DefaultObjectToSource() static private method

static private DefaultObjectToSource ( Context cx, Scriptable scope, Scriptable thisObj, object args ) : string
cx Context
scope Scriptable
thisObj Scriptable
args object
return string
		internal static string DefaultObjectToSource(Context cx, Scriptable scope, Scriptable thisObj, object[] args)
		{
			bool toplevel;
			bool iterating;
			if (cx.iterating == null)
			{
				toplevel = true;
				iterating = false;
				cx.iterating = new ObjToIntMap(31);
			}
			else
			{
				toplevel = false;
				iterating = cx.iterating.Has(thisObj);
			}
			StringBuilder result = new StringBuilder(128);
			if (toplevel)
			{
				result.Append("(");
			}
			result.Append('{');
			// Make sure cx.iterating is set to null when done
			// so we don't leak memory
			try
			{
				if (!iterating)
				{
					cx.iterating.Intern(thisObj);
					// stop recursion.
					object[] ids = thisObj.GetIds();
					for (int i = 0; i < ids.Length; i++)
					{
						object id = ids[i];
						object value;
						if (id is int)
						{
							int intId = System.Convert.ToInt32(((int)id));
							value = thisObj.Get(intId, thisObj);
							if (value == ScriptableConstants.NOT_FOUND)
							{
								continue;
							}
							// a property has been removed
							if (i > 0)
							{
								result.Append(", ");
							}
							result.Append(intId);
						}
						else
						{
							string strId = (string)id;
							value = thisObj.Get(strId, thisObj);
							if (value == ScriptableConstants.NOT_FOUND)
							{
								continue;
							}
							// a property has been removed
							if (i > 0)
							{
								result.Append(", ");
							}
							if (ScriptRuntime.IsValidIdentifierName(strId))
							{
								result.Append(strId);
							}
							else
							{
								result.Append('\'');
								result.Append(ScriptRuntime.EscapeString(strId, '\''));
								result.Append('\'');
							}
						}
						result.Append(':');
						result.Append(ScriptRuntime.Uneval(cx, scope, value));
					}
				}
			}
			finally
			{
				if (toplevel)
				{
					cx.iterating = null;
				}
			}
			result.Append('}');
			if (toplevel)
			{
				result.Append(')');
			}
			return result.ToString();
		}
ScriptRuntime