Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/build/lib/policies/objectPolicy.ts
4772 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import { BasePolicy } from './basePolicy.ts';
7
import type { CategoryDto, PolicyDto } from './policyDto.ts';
8
import { renderProfileString } from './render.ts';
9
import { type Category, type NlsString, PolicyType, type LanguageTranslations } from './types.ts';
10
11
export class ObjectPolicy extends BasePolicy {
12
13
static from(category: CategoryDto, policy: PolicyDto): ObjectPolicy | undefined {
14
const { type, name, minimumVersion, localization } = policy;
15
16
if (type !== 'object' && type !== 'array') {
17
return undefined;
18
}
19
20
return new ObjectPolicy(name, { moduleName: '', name: { nlsKey: category.name.key, value: category.name.value } }, minimumVersion, { nlsKey: localization.description.key, value: localization.description.value }, '');
21
}
22
23
private constructor(
24
name: string,
25
category: Category,
26
minimumVersion: string,
27
description: NlsString,
28
moduleName: string,
29
) {
30
super(PolicyType.Object, name, category, minimumVersion, description, moduleName);
31
}
32
33
protected renderADMXElements(): string[] {
34
return [`<multiText id="${this.name}" valueName="${this.name}" required="true" />`];
35
}
36
37
renderADMLPresentationContents() {
38
return `<multiTextBox refId="${this.name}" />`;
39
}
40
41
renderJsonValue() {
42
return '';
43
}
44
45
renderProfileValue(): string {
46
return `<string></string>`;
47
}
48
49
renderProfileManifestValue(translations?: LanguageTranslations): string {
50
return `<key>pfm_default</key>
51
<string></string>
52
<key>pfm_description</key>
53
<string>${renderProfileString(this.name, this.moduleName, this.description, translations)}</string>
54
<key>pfm_name</key>
55
<string>${this.name}</string>
56
<key>pfm_title</key>
57
<string>${this.name}</string>
58
<key>pfm_type</key>
59
<string>string</string>
60
`;
61
}
62
}
63
64