Rhino.NativeJSON.ExecIdCall C# (CSharp) Method

ExecIdCall() public method

public ExecIdCall ( IdFunctionObject f, Context cx, Scriptable scope, Scriptable thisObj, object args ) : object
f IdFunctionObject
cx Context
scope Scriptable
thisObj Scriptable
args object
return object
		public override object ExecIdCall(IdFunctionObject f, Context cx, Scriptable scope, Scriptable thisObj, object[] args)
		{
			if (!f.HasTag(JSON_TAG))
			{
				return base.ExecIdCall(f, cx, scope, thisObj, args);
			}
			int methodId = f.MethodId();
			switch (methodId)
			{
				case Id_toSource:
				{
					return "JSON";
				}

				case Id_parse:
				{
					string jtext = ScriptRuntime.ToString(args, 0);
					object reviver = null;
					if (args.Length > 1)
					{
						reviver = args[1];
					}
					if (reviver is Callable)
					{
						return Parse(cx, scope, jtext, (Callable)reviver);
					}
					else
					{
						return Parse(cx, scope, jtext);
					}
					goto case Id_stringify;
				}

				case Id_stringify:
				{
					object value = null;
					object replacer = null;
					object space = null;
					switch (args.Length)
					{
						case 3:
						default:
						{
							space = args[2];
							goto case 2;
						}

						case 2:
						{
							replacer = args[1];
							goto case 1;
						}

						case 1:
						{
							value = args[0];
							goto case 0;
						}

						case 0:
						{
							break;
						}
					}
					return Stringify(cx, scope, value, replacer, space);
				}

				default:
				{
					throw new InvalidOperationException(methodId.ToString());
				}
			}
		}