Jurassic.Library.ObjectInstance.TryCallMemberFunction C# (CSharp) Method

TryCallMemberFunction() public method

Calls the function with the given name.
public TryCallMemberFunction ( object &result, object key ) : bool
result object The result of calling the function.
key object The name or symbol of the function to call.
return bool
        public bool TryCallMemberFunction(out object result, object key, params object[] parameters)
        {
            var function = GetPropertyValue(key);
            if ((function is FunctionInstance) == false)
            {
                result = null;
                return false;
            }
            result = ((FunctionInstance)function).CallLateBound(this, parameters);
            return true;
        }

Usage Example

示例#1
0
        public static string ToString(ObjectInstance thisObj)
        {
            // Try calling thisObj.join().
            object result;
            if (thisObj.TryCallMemberFunction(out result, "join") == true)
                return TypeConverter.ToString(result);

            // Otherwise, use the default Object.prototype.toString() method.
            return ObjectInstance.ToStringJS(thisObj.Engine, thisObj);
        }