mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-25 17:23:10 -05:00
* Merge from vscode a234f13c45b40a0929777cb440ee011b7549eed2 * update distro * fix layering * update distro * fix tests
36 lines
1.2 KiB
TypeScript
36 lines
1.2 KiB
TypeScript
/*---------------------------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
|
*--------------------------------------------------------------------------------------------*/
|
|
|
|
import * as vscode from 'vscode';
|
|
import { ApiWrapper } from './apiWrapper';
|
|
|
|
/**
|
|
* Global context for the application
|
|
*/
|
|
export class AppContext {
|
|
|
|
private serviceMap: Map<string, any> = new Map();
|
|
|
|
constructor(public readonly extensionContext: vscode.ExtensionContext, public readonly apiWrapper: ApiWrapper) {
|
|
this.apiWrapper = apiWrapper || new ApiWrapper();
|
|
}
|
|
|
|
public getService<T>(serviceName: string): T {
|
|
const service = this.serviceMap.get(serviceName) as T;
|
|
if (!service) {
|
|
console.warn('Service ', serviceName, ' is not registered');
|
|
}
|
|
return service;
|
|
}
|
|
|
|
public registerService<T>(serviceName: string, service: T): void {
|
|
if (this.serviceMap.has(serviceName)) {
|
|
console.warn('Multiple services ', serviceName, ' registered!');
|
|
} else {
|
|
this.serviceMap.set(serviceName, service);
|
|
}
|
|
}
|
|
}
|