/// <summary> /// Disposes the Handle. It will mark the JSHandle as disposed and release the <see cref="JSHandle.RemoteObject"/> /// </summary> /// <returns>The async.</returns> public async Task DisposeAsync() { if (Disposed) { return; } Disposed = true; await RemoteObjectHelper.ReleaseObjectAsync(Client, RemoteObject, Logger).ConfigureAwait(false); }
/// <inheritdoc/> public override string ToString() { if (((JObject)RemoteObject)["objectId"] != null) { var type = RemoteObject.subtype ?? RemoteObject.type; return("JSHandle@" + type); } return("JSHandle:" + RemoteObjectHelper.ValueFromRemoteObject <object>(RemoteObject)?.ToString()); }
/// <summary> /// Disposes the Handle. It will mark the JSHandle as disposed and release the <see cref="JSHandle.RemoteObject"/> /// </summary> /// <returns>The async.</returns> public async Task DisposeAsync() { if (Disposed) { return; } Disposed = true; await RemoteObjectHelper.ReleaseObject(Client, RemoteObject, Logger); }
/// <inheritdoc/> public override string ToString() { if ((RemoteObject)[MessageKeys.ObjectId] != null) { var type = RemoteObject[MessageKeys.Subtype] ?? RemoteObject[MessageKeys.Type]; return("JSHandle@" + type); } return("JSHandle:" + RemoteObjectHelper.ValueFromRemoteObject <object>(RemoteObject)?.ToString()); }
/// <inheritdoc/> public override string ToString() { if (RemoteObject.ObjectId != null) { var type = RemoteObject.Subtype != RemoteObjectSubtype.Other ? RemoteObject.Subtype.ToString() : RemoteObject.Type.ToString(); return("JSHandle@" + type.ToLower()); } return("JSHandle:" + RemoteObjectHelper.ValueFromRemoteObject <object>(RemoteObject)?.ToString()); }
/// <inheritdoc/> public override string ToString() { if (RemoteObject.ObjectId != null) { var type = RemoteObject.Subtype != RemoteObjectSubtype.Other ? RemoteObject.Subtype.ToString() : RemoteObject.Type.ToString(); return("JSHandle@" + type.ToLower(System.Globalization.CultureInfo.CurrentCulture)); } return("JSHandle:" + RemoteObjectHelper.ValueFromRemoteObject <object>(RemoteObject, true)?.ToString()); }
/// <summary> /// Returns a JSON representation of the object /// </summary> /// <typeparam name="T">A strongly typed object to parse to</typeparam> /// <returns>Task</returns> /// <remarks> /// The method will return an empty JSON if the referenced object is not stringifiable. It will throw an error if the object has circular references /// </remarks> public async Task <T> JsonValueAsync <T>() { if (RemoteObject.objectId != null) { dynamic response = await Client.SendAsync("Runtime.callFunctionOn", new Dictionary <string, object> { ["functionDeclaration"] = "function() { return this; }", ["objectId"] = RemoteObject.objectId, ["returnByValue"] = true, ["awaitPromise"] = true }); return((T)RemoteObjectHelper.ValueFromRemoteObject <T>(response.result)); } return((T)RemoteObjectHelper.ValueFromRemoteObject <T>(RemoteObject)); }
/// <summary> /// Returns a JSON representation of the object /// </summary> /// <typeparam name="T">A strongly typed object to parse to</typeparam> /// <returns>Task</returns> /// <remarks> /// The method will return an empty JSON if the referenced object is not stringifiable. It will throw an error if the object has circular references /// </remarks> public async Task <T> JsonValueAsync <T>() { var objectId = RemoteObject.ObjectId; if (objectId != null) { var response = await Client.SendAsync <RuntimeCallFunctionOnResponse>("Runtime.callFunctionOn", new RuntimeCallFunctionOnRequest { FunctionDeclaration = "function() { return this; }", ObjectId = objectId, ReturnByValue = true, AwaitPromise = true }).ConfigureAwait(false); return((T)RemoteObjectHelper.ValueFromRemoteObject <T>(response.Result)); } return((T)RemoteObjectHelper.ValueFromRemoteObject <T>(RemoteObject)); }
/// <summary> /// Returns a JSON representation of the object /// </summary> /// <typeparam name="T">A strongly typed object to parse to</typeparam> /// <returns>Task</returns> /// <remarks> /// The method will return an empty JSON if the referenced object is not stringifiable. It will throw an error if the object has circular references /// </remarks> public async Task <T> JsonValueAsync <T>() { var objectId = RemoteObject[MessageKeys.ObjectId]; if (objectId != null) { var response = await Client.SendAsync("Runtime.callFunctionOn", new Dictionary <string, object> { ["functionDeclaration"] = "function() { return this; }", [MessageKeys.ObjectId] = objectId, ["returnByValue"] = true, ["awaitPromise"] = true }).ConfigureAwait(false); return((T)RemoteObjectHelper.ValueFromRemoteObject <T>(response[MessageKeys.Result])); } return((T)RemoteObjectHelper.ValueFromRemoteObject <T>(RemoteObject)); }