mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
integrate with contextkeyservice (#804)
* commting .d.ts changes * added serverinfo to .d.ts * maybe its working? * works * updated contrib * remove unnecessary code * fix compile errors * change back sqlops engine for merge
This commit is contained in:
49
src/sql/parts/connection/common/connectionContextKey.ts
Normal file
49
src/sql/parts/connection/common/connectionContextKey.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* 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 { RawContextKey, IContextKeyService, IContextKey } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IConnectionProfile } from 'sqlops';
|
||||
|
||||
export class ConnectionContextkey implements IContextKey<IConnectionProfile> {
|
||||
|
||||
static Provider = new RawContextKey<string>('connectionProvider', undefined);
|
||||
static Server = new RawContextKey<string>('serverName', undefined);
|
||||
static Database = new RawContextKey<string>('databasename', undefined);
|
||||
static Connection = new RawContextKey<IConnectionProfile>('connection', undefined);
|
||||
|
||||
private _providerKey: IContextKey<string>;
|
||||
private _serverKey: IContextKey<string>;
|
||||
private _databaseKey: IContextKey<string>;
|
||||
private _connectionKey: IContextKey<IConnectionProfile>;
|
||||
|
||||
constructor(
|
||||
@IContextKeyService contextKeyService: IContextKeyService
|
||||
) {
|
||||
this._providerKey = ConnectionContextkey.Provider.bindTo(contextKeyService);
|
||||
this._serverKey = ConnectionContextkey.Server.bindTo(contextKeyService);
|
||||
this._databaseKey = ConnectionContextkey.Database.bindTo(contextKeyService);
|
||||
this._connectionKey = ConnectionContextkey.Connection.bindTo(contextKeyService);
|
||||
}
|
||||
|
||||
set(value: IConnectionProfile) {
|
||||
this._connectionKey.set(value);
|
||||
this._providerKey.set(value && value.providerName);
|
||||
this._serverKey.set(value && value.serverName);
|
||||
this._databaseKey.set(value && value.databaseName);
|
||||
}
|
||||
|
||||
reset(): void {
|
||||
this._providerKey.reset();
|
||||
this._serverKey.reset();
|
||||
this._databaseKey.reset();
|
||||
this._connectionKey.reset();
|
||||
}
|
||||
|
||||
public get(): IConnectionProfile {
|
||||
return this._connectionKey.get();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user