mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-20 00:28:52 +01:00
64 lines
2.3 KiB
TypeScript
64 lines
2.3 KiB
TypeScript
/*---------------------------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
*--------------------------------------------------------------------------------------------*/
|
|
|
|
import { renderADMLString } from './render';
|
|
import { Category, LanguageTranslations, NlsString, Policy, PolicyType } from './types';
|
|
|
|
export abstract class BasePolicy implements Policy {
|
|
constructor(
|
|
readonly type: PolicyType,
|
|
readonly name: string,
|
|
readonly category: Category,
|
|
readonly minimumVersion: string,
|
|
protected description: NlsString,
|
|
protected moduleName: string,
|
|
) { }
|
|
|
|
protected renderADMLString(nlsString: NlsString, translations?: LanguageTranslations): string {
|
|
return renderADMLString(this.name, this.moduleName, nlsString, translations);
|
|
}
|
|
|
|
renderADMX(regKey: string) {
|
|
return [
|
|
`<policy name="${this.name}" class="Both" displayName="$(string.${this.name})" explainText="$(string.${this.name}_${this.description.nlsKey.replace(/\./g, '_')})" key="Software\\Policies\\Microsoft\\${regKey}" presentation="$(presentation.${this.name})">`,
|
|
` <parentCategory ref="${this.category.name.nlsKey}" />`,
|
|
` <supportedOn ref="Supported_${this.minimumVersion.replace(/\./g, '_')}" />`,
|
|
` <elements>`,
|
|
...this.renderADMXElements(),
|
|
` </elements>`,
|
|
`</policy>`
|
|
];
|
|
}
|
|
|
|
protected abstract renderADMXElements(): string[];
|
|
|
|
renderADMLStrings(translations?: LanguageTranslations) {
|
|
return [
|
|
`<string id="${this.name}">${this.name}</string>`,
|
|
this.renderADMLString(this.description, translations)
|
|
];
|
|
}
|
|
|
|
renderADMLPresentation(): string {
|
|
return `<presentation id="${this.name}">${this.renderADMLPresentationContents()}</presentation>`;
|
|
}
|
|
|
|
protected abstract renderADMLPresentationContents(): string;
|
|
|
|
renderProfile() {
|
|
return [`<key>${this.name}</key>`, this.renderProfileValue()];
|
|
}
|
|
|
|
renderProfileManifest(translations?: LanguageTranslations): string {
|
|
return `<dict>
|
|
${this.renderProfileManifestValue(translations)}
|
|
</dict>`;
|
|
}
|
|
|
|
abstract renderJsonValue(): string | number | boolean | object | null;
|
|
abstract renderProfileValue(): string;
|
|
abstract renderProfileManifestValue(translations?: LanguageTranslations): string;
|
|
}
|