public Task ReleaseHandleAsync(JSHandle handle) => ReleaseObjectAsync(_client, handle.RemoteObject);
internal void CreateRemoteObject(ChannelOwnerType type, string guid, JsonElement?initializer) { IChannelOwner result = null; switch (type) { case ChannelOwnerType.BindingCall: result = new BindingCall(this, guid, initializer?.ToObject <BindingCallInitializer>(_connection.GetDefaultJsonSerializerOptions())); break; case ChannelOwnerType.Playwright: #pragma warning disable CA2000 // Dispose objects before losing scope result = new Playwright(this, guid, initializer?.ToObject <PlaywrightInitializer>(_connection.GetDefaultJsonSerializerOptions()), _loggerFactory); #pragma warning restore CA2000 // Dispose objects before losing scope break; case ChannelOwnerType.Browser: result = new Browser(this, guid, initializer?.ToObject <BrowserInitializer>(_connection.GetDefaultJsonSerializerOptions())); break; case ChannelOwnerType.BrowserType: result = new BrowserType(this, guid, initializer?.ToObject <BrowserTypeInitializer>(_connection.GetDefaultJsonSerializerOptions())); break; case ChannelOwnerType.Context: result = new BrowserContext(this, guid, initializer?.ToObject <BrowserContextInitializer>(_connection.GetDefaultJsonSerializerOptions())); break; case ChannelOwnerType.ConsoleMessage: result = new ConsoleMessage(this, guid, initializer?.ToObject <ConsoleMessageInitializer>(_connection.GetDefaultJsonSerializerOptions())); break; case ChannelOwnerType.Dialog: result = new Dialog(this, guid, initializer?.ToObject <DialogInitializer>(_connection.GetDefaultJsonSerializerOptions())); break; case ChannelOwnerType.Download: result = new Download(this, guid, initializer?.ToObject <DownloadInitializer>(_connection.GetDefaultJsonSerializerOptions())); break; case ChannelOwnerType.ElementHandle: result = new ElementHandle(this, guid, initializer?.ToObject <ElementHandleInitializer>(_connection.GetDefaultJsonSerializerOptions())); break; case ChannelOwnerType.Frame: result = new Frame(this, guid, initializer?.ToObject <FrameInitializer>(_connection.GetDefaultJsonSerializerOptions())); break; case ChannelOwnerType.JSHandle: result = new JSHandle(this, guid, initializer?.ToObject <JSHandleInitializer>(_connection.GetDefaultJsonSerializerOptions())); break; case ChannelOwnerType.Page: result = new Page(this, guid, initializer?.ToObject <PageInitializer>(_connection.GetDefaultJsonSerializerOptions())); break; case ChannelOwnerType.Request: result = new Request(this, guid, initializer?.ToObject <RequestInitializer>(_connection.GetDefaultJsonSerializerOptions())); break; case ChannelOwnerType.Response: result = new Response(this, guid, initializer?.ToObject <ResponseInitializer>(_connection.GetDefaultJsonSerializerOptions())); break; case ChannelOwnerType.Route: result = new Route(this, guid, initializer?.ToObject <RouteInitializer>(_connection.GetDefaultJsonSerializerOptions())); break; default: Debug.Write("Missing type " + type); break; } _objects.TryAdd(guid, result); _connection.OnObjectCreated(guid, result); }