1
>
/*---------------------------------------------------------------------------------------------
platform.ts
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 * as Assert from '../../../base/common/assert.js';
7
>
import * as Types from '../../../base/common/types.js';
8
>
9
>
export interface IRegistry {
10
>
11
>
/**
12
>
* Adds the extension functions and properties defined by data to the
13
>
* platform. The provided id must be unique.
14
>
* @param id a unique identifier
15
>
* @param data a contribution
16
>
*/
17
>
add(id: string, data: any): void;
18
>
19
>
/**
20
>
* Returns true iff there is an extension with the provided id.
21
>
* @param id an extension identifier
22
>
*/
23
>
knows(id: string): boolean;
24
>
25
>
/**
26
>
* Returns the extension functions and properties defined by the specified key or null.
27
>
* @param id an extension identifier
28
>
*/
29
>
as<T>(id: string): T;
30
>
}
31
>
32
>
class RegistryImpl implements IRegistry {
33
>
34
>
private readonly data = new Map<string, any>();
35
>
36
>
public add(id: string, data: any): void {
37
Assert.ok(Types.isString(id));
38
Assert.ok(Types.isObject(data));