/*--------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ import { SyncDescriptor } from './descriptors'; import { ServiceIdentifier, BrandedService } from './instantiation'; const _registry: [ServiceIdentifier, SyncDescriptor][] = []; export function registerSingleton( id: ServiceIdentifier, ctor: new (...services: Services) => T, supportsDelayedInstantiation?: boolean ): void; export function registerSingleton( id: ServiceIdentifier, descriptor: SyncDescriptor ): void; export function registerSingleton( id: ServiceIdentifier, ctorOrDescriptor: { new (...services: Services): T } | SyncDescriptor, supportsDelayedInstantiation?: boolean ): void { if (!(ctorOrDescriptor instanceof SyncDescriptor)) { ctorOrDescriptor = new SyncDescriptor( ctorOrDescriptor as new (...args: any[]) => T, [], supportsDelayedInstantiation ); } _registry.push([id, ctorOrDescriptor]); } export function getSingletonServiceDescriptors(): [ ServiceIdentifier, SyncDescriptor ][] { return _registry; }