54
55
export abstract class AbstractPolicyService extends Disposable implements IPolicyService {
56
>
readonly _serviceBrand: undefined;
policy.ts
57
>
58
>
public policyDefinitions: IStringDictionary<PolicyDefinition> = {};
59
>
protected policies = new Map<PolicyName, PolicyValue>();
60
>
61
>
protected readonly _onDidChange = this._register(new Emitter<readonly PolicyName[]>());
62
>
readonly onDidChange = this._onDidChange.event;
63
64
async updatePolicyDefinitions(policyDefinitions: IStringDictionary<PolicyDefinition>): Promise<IStringDictionary<PolicyValue>> {
65
>
// Replace existing definitions; identity comparison avoids redundant watcher churn.
policy.ts
66
>
let changed = false;
67
>
for (const name of Object.keys(policyDefinitions)) {
68
>
if (this.policyDefinitions[name] !== policyDefinitions[name]) {
69
>
this.policyDefinitions[name] = policyDefinitions[name];
70
>
changed = true;
71
>
}
72
>
}
73
>
74
>
if (changed) {
75
>
await this._updatePolicyDefinitions(this.policyDefinitions);
76
>
}
77
>
78
>
return Iterable.reduce(this.policies.entries(), (r, [name, value]) => ({ ...r, [name]: value }), {});
79
>
}
80
81
getPolicyValue(name: PolicyName): PolicyValue | undefined {