mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-22 01:25:38 -05:00
* removes more builder references * remove builder from profiler * formatting * fix profiler dailog * remove builder from oatuhdialog * remove the rest of builder references * formatting * add more strict null checks to base * enable strict tslint rules * fix formatting * fix compile error * fix the rest of the hygeny issues and add pipeline step * fix pipeline files
44 lines
1.9 KiB
TypeScript
44 lines
1.9 KiB
TypeScript
/*---------------------------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
|
*--------------------------------------------------------------------------------------------*/
|
|
|
|
'use strict';
|
|
|
|
import * as azdata from 'azdata';
|
|
|
|
export class AgentUtils {
|
|
|
|
private static _agentService: azdata.AgentServicesProvider;
|
|
private static _connectionService: azdata.ConnectionProvider;
|
|
private static _queryProvider: azdata.QueryProvider;
|
|
|
|
public static async getAgentService(): Promise<azdata.AgentServicesProvider> {
|
|
if (!AgentUtils._agentService) {
|
|
let currentConnection = await azdata.connection.getCurrentConnection();
|
|
this._agentService = azdata.dataprotocol.getProvider<azdata.AgentServicesProvider>(currentConnection.providerId, azdata.DataProviderType.AgentServicesProvider);
|
|
}
|
|
return AgentUtils._agentService;
|
|
}
|
|
|
|
public static async getDatabases(ownerUri: string): Promise<string[]> {
|
|
if (!AgentUtils._connectionService) {
|
|
let currentConnection = await azdata.connection.getCurrentConnection();
|
|
this._connectionService = azdata.dataprotocol.getProvider<azdata.ConnectionProvider>(currentConnection.providerId, azdata.DataProviderType.ConnectionProvider);
|
|
}
|
|
return AgentUtils._connectionService.listDatabases(ownerUri).then(result => {
|
|
if (result && result.databaseNames && result.databaseNames.length > 0) {
|
|
return result.databaseNames;
|
|
}
|
|
});
|
|
}
|
|
|
|
public static async getQueryProvider(): Promise<azdata.QueryProvider> {
|
|
if (!AgentUtils._queryProvider) {
|
|
let currentConnection = await azdata.connection.getCurrentConnection();
|
|
this._queryProvider = azdata.dataprotocol.getProvider<azdata.QueryProvider>(currentConnection.providerId, azdata.DataProviderType.QueryProvider);
|
|
}
|
|
return this._queryProvider;
|
|
}
|
|
|
|
} |