Files
azuredatastudio/extensions/resource-deployment/src/ui/model.ts
Arvind Ranasaria 738ca479e4 fixes for #8165, #8167, & #8260 (#8250)
* saving untested work

* fixes for #8165 and #8167

* minor fixes

* fix for #8260

* minor quoting fixes

* fix for #8264

* minor fixes

* minor fixes.

* move tools constants to their own files

* remove execution cell results from notebooks.

* remove extraneous changes

* move ensuring of  StoragePath to platformservice

* remove fix for #8264 pending pm input
2019-11-08 09:11:21 -08:00

45 lines
1.8 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 { NoteBookEnvironmentVariablePrefix } from '../interfaces';
export class Model {
private propValueObject: { [s: string]: string | undefined } = {};
public setPropertyValue(property: string, value: string | number | boolean | undefined): void {
if (typeof value === 'boolean') {
this.propValueObject[property] = value ? 'true' : 'false';
} else if (typeof value === 'number') {
this.propValueObject[property] = value.toString();
} else {
this.propValueObject[property] = value;
}
}
public getIntegerValue(propName: string, defaultValue: number = 0): number {
const value = this.propValueObject[propName];
return value === undefined ? defaultValue : Number.parseInt(value);
}
public getStringValue(propName: string, defaultValue?: string): string | undefined {
const value = this.propValueObject[propName];
return value === undefined ? defaultValue : value;
}
public getBooleanValue(propName: string, defaultValue: boolean = false): boolean {
const value = this.propValueObject[propName];
return value === undefined ? defaultValue : value === 'true';
}
public setEnvironmentVariables(): void {
Object.keys(this.propValueObject).filter(propertyName => propertyName.startsWith(NoteBookEnvironmentVariablePrefix)).forEach(propertyName => {
const value = this.getStringValue(propertyName);
if (value !== undefined && value !== '') {
process.env[propertyName] = value;
}
process.env[propertyName] = value === undefined ? '' : value;
});
}
}