Rhino.NativeBoolean.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(BOOLEAN_TAG))
			{
				return base.ExecIdCall(f, cx, scope, thisObj, args);
			}
			int id = f.MethodId();
			if (id == Id_constructor)
			{
				bool b;
				if (args.Length == 0)
				{
					b = false;
				}
				else
				{
					b = args[0] is ScriptableObject && ((ScriptableObject)args[0]).AvoidObjectDetection() ? true : ScriptRuntime.ToBoolean(args[0]);
				}
				if (thisObj == null)
				{
					// new Boolean(val) creates a new boolean object.
					return new Rhino.NativeBoolean(b);
				}
				// Boolean(val) converts val to a boolean.
				return ScriptRuntime.WrapBoolean(b);
			}
			// The rest of Boolean.prototype methods require thisObj to be Boolean
			if (!(thisObj is Rhino.NativeBoolean))
			{
				throw IncompatibleCallError(f);
			}
			bool value = ((Rhino.NativeBoolean)thisObj).booleanValue;
			switch (id)
			{
				case Id_toString:
				{
					return value ? "true" : "false";
				}

				case Id_toSource:
				{
					return value ? "(new Boolean(true))" : "(new Boolean(false))";
				}

				case Id_valueOf:
				{
					return ScriptRuntime.WrapBoolean(value);
				}
			}
			throw new ArgumentException(id.ToString());
		}