SQL Operations Studio Public Preview 1 (0.23) release source code

This commit is contained in:
Karl Burtram
2017-11-09 14:30:27 -08:00
parent b88ecb8d93
commit 3cdac41339
8829 changed files with 759707 additions and 286 deletions

View File

@@ -0,0 +1,75 @@
/*---------------------------------------------------------------------------------------------
* 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 Config from './config';
import { workspace, WorkspaceConfiguration } from 'vscode';
import {IConfig} from '../languageservice/interfaces';
import * as Constants from '../models/constants';
/*
* ExtConfig class handles getting values from workspace config or config.json.
*/
export default class ExtConfig implements IConfig {
constructor(private _extensionConfigSectionName: string, private _config?: IConfig,
private _extensionConfig?: WorkspaceConfiguration,
private _workspaceConfig?: WorkspaceConfiguration) {
if (this._config === undefined) {
this._config = new Config(_extensionConfigSectionName);
}
if (this._extensionConfig === undefined) {
this._extensionConfig = workspace.getConfiguration(_extensionConfigSectionName);
}
if (this._workspaceConfig === undefined) {
this._workspaceConfig = workspace.getConfiguration();
}
}
public getDownloadUrl(): string {
return this.getConfigValue(Constants.downloadUrlConfigKey);
}
public getInstallDirectory(): string {
return this.getConfigValue(Constants.installDirConfigKey);
}
public getExecutableFiles(): string[] {
return this.getConfigValue(Constants.executableFilesConfigKey);
}
public getPackageVersion(): string {
return this.getConfigValue(Constants.versionConfigKey);
}
public getConfigValue(configKey: string): any {
let configValue: string = <string>this.getExtensionConfig(`${Constants.serviceConfigKey}.${configKey}`);
if (!configValue) {
configValue = this._config.getConfigValue(configKey);
}
return configValue;
}
public getExtensionConfig(key: string, defaultValue?: any): any {
let configValue = this._extensionConfig.get(key);
if (configValue === undefined) {
configValue = defaultValue;
}
return configValue;
}
public getWorkspaceConfig(key: string, defaultValue?: any): any {
let configValue = this._workspaceConfig.get(key);
if (configValue === undefined) {
configValue = defaultValue;
}
return configValue;
}
public updateWorkspaceConfig(configKey: string, configValue: any) {
this._workspaceConfig.update(configKey, configValue, true);
}
}