Pull render service off instantiation service safely

This commit is contained in:
Daniel Imms
2020-02-04 07:01:25 -08:00
parent 489d8110c9
commit 3d2d35f5b6
5 changed files with 20 additions and 13 deletions
+5 -1
View File
@@ -36,7 +36,7 @@ export class ServiceCollection {
return this._entries.has(id);
}
get<T>(id: IServiceIdentifier<T>): T {
get<T>(id: IServiceIdentifier<T>): T | undefined {
return this._entries.get(id);
}
}
@@ -52,6 +52,10 @@ export class InstantiationService implements IInstantiationService {
this._services.set(id, instance);
}
public getService<T>(id: IServiceIdentifier<T>): T | undefined {
return this._services.get(id);
}
public createInstance<T>(ctor: any, ...args: any[]): any {
const serviceDependencies = getServiceDependencies(ctor).sort((a, b) => a.index - b.index);
+1
View File
@@ -171,6 +171,7 @@ export interface IConstructorSignature8<A1, A2, A3, A4, A5, A6, A7, A8, T> {
export const IInstantiationService = createDecorator<IInstantiationService>('InstantiationService');
export interface IInstantiationService {
setService<T>(id: IServiceIdentifier<T>, instance: T): void;
getService<T>(id: IServiceIdentifier<T>): T | undefined;
createInstance<T>(ctor: IConstructorSignature0<T>): T;
createInstance<A1, T>(ctor: IConstructorSignature1<A1, T>, first: A1): T;