當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript CommandsRegistry.getCommand方法代碼示例

本文整理匯總了TypeScript中vs/platform/commands/common/commands.CommandsRegistry.getCommand方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript CommandsRegistry.getCommand方法的具體用法?TypeScript CommandsRegistry.getCommand怎麽用?TypeScript CommandsRegistry.getCommand使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在vs/platform/commands/common/commands.CommandsRegistry的用法示例。


在下文中一共展示了CommandsRegistry.getCommand方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: test

	test('register/dispose', function () {
		const command = function () { };
		const reg = CommandsRegistry.registerCommand('foo', command);
		assert.ok(CommandsRegistry.getCommand('foo').handler === command);
		reg.dispose();
		assert.ok(CommandsRegistry.getCommand('foo') === undefined);
	});
開發者ID:GYGit,項目名稱:vscode,代碼行數:7,代碼來源:commands.test.ts

示例2: test

	test('dispose on unregister', function () {

		const commands = new MainThreadCommands(OneGetThreadService(null), undefined);
		assert.equal(CommandsRegistry.getCommand('foo'), undefined);

		// register
		commands.$registerCommand('foo');
		assert.ok(CommandsRegistry.getCommand('foo'));

		// unregister
		commands.$unregisterCommand('foo');
		assert.equal(CommandsRegistry.getCommand('foo'), undefined);
	});
開發者ID:SeanKilleen,項目名稱:vscode,代碼行數:13,代碼來源:mainThreadCommands.test.ts

示例3: test

	test('dispose on unregister', function () {

		const commands = new MainThreadCommands(SingleProxyRPCProtocol(null), undefined!);
		assert.equal(CommandsRegistry.getCommand('foo'), undefined);

		// register
		commands.$registerCommand('foo');
		assert.ok(CommandsRegistry.getCommand('foo'));

		// unregister
		commands.$unregisterCommand('foo');
		assert.equal(CommandsRegistry.getCommand('foo'), undefined);
	});
開發者ID:VishalMadhvani,項目名稱:vscode,代碼行數:13,代碼來源:mainThreadCommands.test.ts

示例4: test

	test('CommandsRegistry with precondition', function () {
		let r1 = CommandsRegistry.registerCommand('foo', () => { });

		const precondition = new RawContextKey<boolean>('ddd', false);
		let r2 = CommandsRegistry.registerCommand({
			id: 'bar',
			handler: () => { },
			precondition
		});

		assert.ok(CommandsRegistry.getCommand('bar').precondition === precondition);
		assert.equal(CommandsRegistry.getCommand('foo').precondition, undefined);

		r1.dispose();
		r2.dispose();
	});
開發者ID:SeanKilleen,項目名稱:vscode,代碼行數:16,代碼來源:commands.test.ts

示例5: test

	test('dispose calls unregister', function () {

		let lastUnregister: string;

		const shape = new class extends mock<MainThreadCommandsShape>() {
			$registerCommand(id: string): void {
				//
			}
			$unregisterCommand(id: string): void {
				lastUnregister = id;
			}
		};

		const commands = new ExtHostCommands(SingleProxyRPCProtocol(shape), undefined, new NullLogService());
		commands.registerCommand(true, 'foo', (): any => { }).dispose();
		assert.equal(lastUnregister, 'foo');
		assert.equal(CommandsRegistry.getCommand('foo'), undefined);

	});
開發者ID:AllureFer,項目名稱:vscode,代碼行數:19,代碼來源:extHostCommands.test.ts

示例6: test

	test('dispose calls unregister', function () {

		let lastUnregister: string;

		const shape = new class extends mock<MainThreadCommandsShape>() {
			$registerCommand(id: string): TPromise<any> {
				return undefined;
			}
			$unregisterCommand(id: string): TPromise<any> {
				lastUnregister = id;
				return undefined;
			}
		};

		const commands = new ExtHostCommands(OneGetThreadService(shape), undefined, new NoopLogService());
		commands.registerCommand('foo', (): any => { }).dispose();
		assert.equal(lastUnregister, 'foo');
		assert.equal(CommandsRegistry.getCommand('foo'), undefined);

	});
開發者ID:AlexxNica,項目名稱:sqlopsstudio,代碼行數:20,代碼來源:extHostCommands.test.ts

示例7:

		let connectionService: IConnectionManagementService = accessor.get(IConnectionManagementService);
		let objectExplorerService: IObjectExplorerService = accessor.get(IObjectExplorerService);

		let connectionProfile = TaskUtilities.getCurrentGlobalConnection(objectExplorerService, connectionService, editorService);
		let profilerInput = instantiationService.createInstance(ProfilerInput, connectionProfile);
		return editorService.openEditor(profilerInput, { pinned: true }, false).then(() => TPromise.as(true));
	}
});

KeybindingsRegistry.registerCommandAndKeybindingRule({
	id: 'profiler.newProfiler',
	weight: KeybindingsRegistry.WEIGHT.builtinExtension(),
	when: undefined,
	primary: KeyMod.Alt | KeyCode.KEY_P,
	mac: { primary: KeyMod.WinCtrl | KeyMod.Alt | KeyCode.KEY_P },
	handler: CommandsRegistry.getCommand('profiler.newProfiler').handler
});

KeybindingsRegistry.registerCommandAndKeybindingRule({
	id: 'profiler.toggleStartStop',
	weight: KeybindingsRegistry.WEIGHT.editorContrib(),
	when: undefined,
	primary: KeyMod.Alt | KeyCode.KEY_S,
	mac: { primary: KeyMod.WinCtrl | KeyMod.Alt | KeyCode.KEY_S },
	handler: (accessor: ServicesAccessor) => {
		let profilerService: IProfilerService = accessor.get(IProfilerService);
		let editorService: IWorkbenchEditorService = accessor.get(IWorkbenchEditorService);

		let activeEditor = editorService.getActiveEditor();
		if (activeEditor instanceof ProfilerEditor) {
			let profilerInput = activeEditor.input;
開發者ID:jumpinjackie,項目名稱:sqlopsstudio,代碼行數:31,代碼來源:profilerActions.contribution.ts


注:本文中的vs/platform/commands/common/commands.CommandsRegistry.getCommand方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。