/*--------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ import { IDisposable } from 'vs/base/common/lifecycle'; import { IConstructorSignature1, BrandedService } from 'vs/platform/instantiation/common/instantiation'; import { IExtHostContext } from 'vs/workbench/api/common/extHost.protocol'; import { ProxyIdentifier } from 'vs/workbench/services/extensions/common/proxyIdentifier'; export type IExtHostNamedCustomer = [ProxyIdentifier, IExtHostCustomerCtor]; export type IExtHostCustomerCtor = IConstructorSignature1; export function extHostNamedCustomer(id: ProxyIdentifier) { return function (ctor: { new(context: IExtHostContext, ...services: Services): T }): void { ExtHostCustomersRegistryImpl.INSTANCE.registerNamedCustomer(id, ctor); }; } export function extHostCustomer(ctor: { new(context: IExtHostContext, ...services: Services): T }): void { ExtHostCustomersRegistryImpl.INSTANCE.registerCustomer(ctor); } export namespace ExtHostCustomersRegistry { export function getNamedCustomers(): IExtHostNamedCustomer[] { return ExtHostCustomersRegistryImpl.INSTANCE.getNamedCustomers(); } export function getCustomers(): IExtHostCustomerCtor[] { return ExtHostCustomersRegistryImpl.INSTANCE.getCustomers(); } } class ExtHostCustomersRegistryImpl { public static readonly INSTANCE = new ExtHostCustomersRegistryImpl(); private _namedCustomers: IExtHostNamedCustomer[]; private _customers: IExtHostCustomerCtor[]; constructor() { this._namedCustomers = []; this._customers = []; } public registerNamedCustomer(id: ProxyIdentifier, ctor: IExtHostCustomerCtor): void { const entry: IExtHostNamedCustomer = [id, ctor]; this._namedCustomers.push(entry); } public getNamedCustomers(): IExtHostNamedCustomer[] { return this._namedCustomers; } public registerCustomer(ctor: IExtHostCustomerCtor): void { this._customers.push(ctor); } public getCustomers(): IExtHostCustomerCtor[] { return this._customers; } }