/*--------------------------------------------------------------------------------------------- * 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.ts'; import type { Category, LanguageTranslations, NlsString, Policy, PolicyType } from './types.ts'; export abstract class BasePolicy implements Policy { readonly type: PolicyType; readonly name: string; readonly category: Category; readonly minimumVersion: string; protected description: NlsString; protected moduleName: string; constructor( type: PolicyType, name: string, category: Category, minimumVersion: string, description: NlsString, moduleName: string, ) { this.type = type; this.name = name; this.category = category; this.minimumVersion = minimumVersion; this.description = description; this.moduleName = moduleName; } protected renderADMLString(nlsString: NlsString, translations?: LanguageTranslations): string { return renderADMLString(this.name, this.moduleName, nlsString, translations); } renderADMX(regKey: string) { return [ ``, ` `, ` `, ` `, ...this.renderADMXElements(), ` `, `` ]; } protected abstract renderADMXElements(): string[]; renderADMLStrings(translations?: LanguageTranslations) { return [ `${this.name}`, this.renderADMLString(this.description, translations) ]; } renderADMLPresentation(): string { return `${this.renderADMLPresentationContents()}`; } protected abstract renderADMLPresentationContents(): string; renderProfile() { return [`${this.name}`, this.renderProfileValue()]; } renderProfileManifest(translations?: LanguageTranslations): string { return ` ${this.renderProfileManifestValue(translations)} `; } abstract renderJsonValue(): string | number | boolean | object | null; abstract renderProfileValue(): string; abstract renderProfileManifestValue(translations?: LanguageTranslations): string; }