/// <summary> /// Makes this object non-extensible, which means no new properties can be added to it. /// </summary> /// <param name="throwOnError"> <c>true</c> to throw an exception if the object could not /// be made non-extensible. </param> /// <returns> <c>true</c> if the operation was successful, <c>false</c> otherwise. </returns> internal override bool PreventExtensions(bool throwOnError) { // Check for revocation. if (target == null || handler == null) { throw new JavaScriptException(ErrorType.TypeError, "Cannot call 'preventExtensions' on a proxy that has been revoked."); } // Call the handler, if one exists. var trap = handler.GetMethod("preventExtensions"); if (trap == null) { return(target.PreventExtensions(throwOnError)); } var result = TypeConverter.ToBoolean(trap.CallLateBound(handler, target)); // Validate. if (!result) { if (throwOnError) { throw new JavaScriptException(ErrorType.TypeError, "'preventExtensions' on proxy: trap returned falsish."); } return(false); } var targetIsExtensible = target.IsExtensible; if (targetIsExtensible) { throw new JavaScriptException(ErrorType.TypeError, "'preventExtensions' on proxy: trap returned truish but the proxy target is extensible."); } return(true); }