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


TypeScript ServiceCollection.set方法代碼示例

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


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

示例1: test

	test('TextDiffEditorModel', function (done) {
		let services = new ServiceCollection();
		services.set(IModeService, createMockModeService());
		services.set(IModelService, createMockModelService());
		let inst = new InstantiationService(services);
		let input = inst.createInstance(StringEditorInput, 'name', 'description', 'value', 'text/plain', false);
		let otherInput = inst.createInstance(StringEditorInput, 'name2', 'description', 'value2', 'text/plain', false);
		let diffInput = new DiffEditorInput('name', 'description', input, otherInput);

		diffInput.resolve(true).then(function (model: any) {
			assert(model);
			assert(model instanceof TextDiffEditorModel);

			let diffEditorModel = model.textDiffEditorModel;
			assert(diffEditorModel.original);
			assert(diffEditorModel.modified);

			return diffInput.resolve(true).then(function (model: any) {
				assert(model.isResolved());

				assert(diffEditorModel !== model.textDiffEditorModel);
				diffInput.dispose();
				assert(!model.textDiffEditorModel);
			});
		}).done(() => {
			done();
		});
	});
開發者ID:13572293130,項目名稱:vscode,代碼行數:28,代碼來源:editorModel.test.ts

示例2: main

function main(server: Server): void {
	const services = new ServiceCollection();

	services.set(IEventService, new SyncDescriptor(EventService));
	services.set(IEnvironmentService, new SyncDescriptor(EnvironmentService, parseArgs(process.argv), process.execPath));
	services.set(IConfigurationService, new SyncDescriptor(ConfigurationService));
	services.set(IRequestService, new SyncDescriptor(RequestService));

	const instantiationService = new InstantiationService(services);

	instantiationService.invokeFunction(accessor => {
		const appenders: AppInsightsAppender[] = [];

		if (product.aiConfig && product.aiConfig.key) {
			appenders.push(new AppInsightsAppender(eventPrefix, null, product.aiConfig.key));
		}

		if (product.aiConfig && product.aiConfig.asimovKey) {
			appenders.push(new AppInsightsAppender(eventPrefix, null, product.aiConfig.asimovKey));
		}

		// It is important to dispose the AI adapter properly because
		// only then they flush remaining data.
		process.once('exit', () => appenders.forEach(a => a.dispose()));

		const appender = combinedAppender(...appenders);
		server.registerChannel('telemetryAppender', new TelemetryAppenderChannel(appender));

		const services = new ServiceCollection();
		const { appRoot, extensionsPath, extensionDevelopmentPath, isBuilt } = accessor.get(IEnvironmentService);

		if (isBuilt && !extensionDevelopmentPath && product.enableTelemetry) {
			const config: ITelemetryServiceConfig = {
				appender,
				commonProperties: resolveCommonProperties(product.commit, pkg.version),
				piiPaths: [appRoot, extensionsPath]
			};

			services.set(ITelemetryService, new SyncDescriptor(TelemetryService, config));
		} else {
			services.set(ITelemetryService, NullTelemetryService);
		}

		services.set(IExtensionManagementService, new SyncDescriptor(ExtensionManagementService));
		services.set(IExtensionGalleryService, new SyncDescriptor(ExtensionGalleryService));

		const instantiationService2 = instantiationService.createChild(services);

		instantiationService2.invokeFunction(accessor => {
			const extensionManagementService = accessor.get(IExtensionManagementService);
			const channel = new ExtensionManagementChannel(extensionManagementService);
			server.registerChannel('extensions', channel);

			// eventually clean up old extensions
			setTimeout(() => (extensionManagementService as ExtensionManagementService).removeDeprecatedExtensions(), 100);
		});
	});
}
開發者ID:GYGit,項目名稱:vscode,代碼行數:58,代碼來源:sharedProcessMain.ts

示例3: ServiceCollection

	instantiationService.invokeFunction(accessor => {
		const services = new ServiceCollection();
		const environmentService = accessor.get(IEnvironmentService);
		const { appRoot, extensionsPath, extensionDevelopmentLocationURI, isBuilt, installSourcePath } = environmentService;
		const telemetryLogService = new FollowerLogService(logLevelClient, createSpdLogService('telemetry', initData.logLevel, environmentService.logsPath));
		telemetryLogService.info('The below are logs for every telemetry event sent from VS Code once the log level is set to trace.');
		telemetryLogService.info('===========================================================');

		let appInsightsAppender: ITelemetryAppender | null = NullAppender;
		if (!extensionDevelopmentLocationURI && !environmentService.args['disable-telemetry'] && product.enableTelemetry) {
			if (product.aiConfig && product.aiConfig.asimovKey && isBuilt) {
				appInsightsAppender = new AppInsightsAppender(eventPrefix, null, product.aiConfig.asimovKey, telemetryLogService);
				disposables.push(appInsightsAppender); // Ensure the AI appender is disposed so that it flushes remaining data
			}
			const config: ITelemetryServiceConfig = {
				appender: combinedAppender(appInsightsAppender, new LogAppender(logService)),
				commonProperties: resolveCommonProperties(product.commit, pkg.version, configuration.machineId, installSourcePath),
				piiPaths: [appRoot, extensionsPath]
			};

			services.set(ITelemetryService, new SyncDescriptor(TelemetryService, [config]));
		} else {
			services.set(ITelemetryService, NullTelemetryService);
		}
		server.registerChannel('telemetryAppender', new TelemetryAppenderChannel(appInsightsAppender));

		services.set(IExtensionManagementService, new SyncDescriptor(ExtensionManagementService, [false]));
		services.set(IExtensionGalleryService, new SyncDescriptor(ExtensionGalleryService));
		services.set(ILocalizationsService, new SyncDescriptor(LocalizationsService));

		const instantiationService2 = instantiationService.createChild(services);

		instantiationService2.invokeFunction(accessor => {

			const extensionManagementService = accessor.get(IExtensionManagementService);
			const channel = new ExtensionManagementChannel(extensionManagementService, () => null);
			server.registerChannel('extensions', channel);

			const localizationsService = accessor.get(ILocalizationsService);
			const localizationsChannel = new LocalizationsChannel(localizationsService);
			server.registerChannel('localizations', localizationsChannel);

			// clean up deprecated extensions
			(extensionManagementService as ExtensionManagementService).removeDeprecatedExtensions();
			// update localizations cache
			(localizationsService as LocalizationsService).update();
			// cache clean ups
			disposables.push(combinedDisposable([
				instantiationService2.createInstance(NodeCachedDataCleaner),
				instantiationService2.createInstance(LanguagePackCachedDataCleaner),
				instantiationService2.createInstance(StorageDataCleaner),
				instantiationService2.createInstance(LogsDataCleaner)
			]));
			disposables.push(extensionManagementService as ExtensionManagementService);
		});
	});
開發者ID:joelday,項目名稱:vscode,代碼行數:56,代碼來源:sharedProcessMain.ts

示例4:

			this.createWorkspaceService(payload, environmentService, remoteAgentService, logService).then(service => {

				// Workspace
				serviceCollection.set(IWorkspaceContextService, service);

				// Configuration
				serviceCollection.set(IConfigurationService, service);

				return service;
			}),
開發者ID:joelday,項目名稱:vscode,代碼行數:10,代碼來源:main.ts

示例5: initialize

	public initialize(mainThread:WorkerServer, complete:ICallback, error:ICallback, progress:ICallback, initData:IInitData):void {

		const services = new ServiceCollection();

		const extensionService = new WorkerExtensionService();
		const contextService = new BaseWorkspaceContextService(initData.contextService.workspace, initData.contextService.configuration, initData.contextService.options);
		this.threadService = new WorkerThreadService(mainThread.getRemoteCom());
		this.threadService.setInstantiationService(new InstantiationService(new ServiceCollection([IThreadService, this.threadService])));
		const telemetryServiceInstance = new RemoteTelemetryService('workerTelemetry', this.threadService);
		const resourceService = new ResourceService();
		const markerService = new SecondaryMarkerService(this.threadService);
		const modeService = new ModeServiceImpl(this.threadService, extensionService);
		const requestService = new BaseRequestService(contextService, telemetryServiceInstance);

		services.set(IExtensionService, extensionService);
		services.set(IThreadService, this.threadService);
		services.set(IModeService, modeService);
		services.set(IWorkspaceContextService, contextService);
		services.set(IEventService, new EventService());
		services.set(IResourceService, resourceService);
		services.set(IMarkerService, markerService);
		services.set(ITelemetryService, telemetryServiceInstance);
		services.set(IRequestService, requestService);

		const instantiationService = new InstantiationService(services);
		this.threadService.setInstantiationService(instantiationService);

		// Instantiate thread actors
		this.threadService.getRemotable(ModeServiceWorkerHelper);
		this.threadService.getRemotable(ModelServiceWorkerHelper);

		complete(undefined);
	}
開發者ID:13572293130,項目名稱:vscode,代碼行數:33,代碼來源:editorWorkerServer.ts

示例6: createMockModeService

export function createMockModeService(): IModeService {
	let services = new ServiceCollection();
	let inst = new InstantiationService(services);

	var extensionService = new MockExtensionService();
	services.set(IExtensionService, extensionService);

	var modeService = new MockModeService(inst, extensionService);
	services.set(IModeService, modeService);

	return modeService;
}
開發者ID:AjuanM,項目名稱:vscode,代碼行數:12,代碼來源:servicesTestUtils.ts

示例7: createMockModeService

export function createMockModeService(): IModeService {
	var threadService = NULL_THREAD_SERVICE;
	var extensionService = new MockExtensionService();
	var modeService = new MockModeService(threadService, extensionService);
	var services = new ServiceCollection();
	services.set(IThreadService, threadService);
	services.set(IExtensionService, extensionService);
	services.set(IModeService, modeService);
	var inst = new InstantiationService(services);
	threadService.setInstantiationService(inst);
	return modeService;
}
開發者ID:INTELOGIE,項目名稱:vscode,代碼行數:12,代碼來源:servicesTestUtils.ts

示例8: AppInsightsAppender

	instantiationService.invokeFunction(accessor => {
		const appenders: AppInsightsAppender[] = [];

		if (product.aiConfig && product.aiConfig.asimovKey) {
			appenders.push(new AppInsightsAppender(eventPrefix, null, product.aiConfig.asimovKey));
		}

		// It is important to dispose the AI adapter properly because
		// only then they flush remaining data.
		disposables.push(...appenders);

		const appender = combinedAppender(...appenders);
		server.registerChannel('telemetryAppender', new TelemetryAppenderChannel(appender));

		const services = new ServiceCollection();
		const environmentService = accessor.get(IEnvironmentService);
		const { appRoot, extensionsPath, extensionDevelopmentPath, isBuilt, installSourcePath } = environmentService;

		if (isBuilt && !extensionDevelopmentPath && !environmentService.args['disable-telemetry'] && product.enableTelemetry) {
			const config: ITelemetryServiceConfig = {
				appender,
				commonProperties: resolveCommonProperties(product.commit, pkg.version, configuration.machineId, installSourcePath),
				piiPaths: [appRoot, extensionsPath]
			};

			services.set(ITelemetryService, new SyncDescriptor(TelemetryService, config));
		} else {
			services.set(ITelemetryService, NullTelemetryService);
		}

		services.set(IExtensionManagementService, new SyncDescriptor(ExtensionManagementService));
		services.set(IExtensionGalleryService, new SyncDescriptor(ExtensionGalleryService));
		services.set(ILocalizationsService, new SyncDescriptor(LocalizationsService));

		const instantiationService2 = instantiationService.createChild(services);

		instantiationService2.invokeFunction(accessor => {
			const extensionManagementService = accessor.get(IExtensionManagementService);
			const channel = new ExtensionManagementChannel(extensionManagementService);
			server.registerChannel('extensions', channel);

			// clean up deprecated extensions
			(extensionManagementService as ExtensionManagementService).removeDeprecatedExtensions();

			const localizationsService = accessor.get(ILocalizationsService);
			const localizationsChannel = new LocalizationsChannel(localizationsService);
			server.registerChannel('localizations', localizationsChannel);

			createSharedProcessContributions(instantiationService2);
			disposables.push(extensionManagementService as ExtensionManagementService);
		});
	});
開發者ID:liunian,項目名稱:vscode,代碼行數:52,代碼來源:sharedProcessMain.ts

示例9: main

function main(server: Server): void {
	const services = new ServiceCollection();

	services.set(IEventService, new SyncDescriptor(EventService));
	services.set(IEnvironmentService, new SyncDescriptor(EnvironmentService));
	services.set(IExtensionManagementService, new SyncDescriptor(ExtensionManagementService));
	services.set(IConfigurationService, new SyncDescriptor(NodeConfigurationService));

	const instantiationService = new InstantiationService(services);

	instantiationService.invokeFunction(accessor => {
		const appenders: AppInsightsAppender[] = [];

		if (product.aiConfig && product.aiConfig.key) {
			appenders.push(new AppInsightsAppender(eventPrefix, null, product.aiConfig.key));
		}

		if (product.aiConfig && product.aiConfig.asimovKey) {
			appenders.push(new AppInsightsAppender(eventPrefix, null, product.aiConfig.asimovKey));
		}

		// It is important to dispose the AI adapter properly because
		// only then they flush remaining data.
		process.once('exit', () => appenders.forEach(a => a.dispose()));

		const appender = combinedAppender(...appenders);
		server.registerChannel('telemetryAppender', new TelemetryAppenderChannel(appender));

		const { appRoot, extensionsPath } = accessor.get(IEnvironmentService);
		const config: ITelemetryServiceConfig = {
			appender,
			commonProperties: TPromise.as({}),
			piiPaths: [appRoot, extensionsPath]
		};

		const services = new ServiceCollection();
		services.set(ITelemetryService, new SyncDescriptor(TelemetryService, config));
		const instantiationService2 = instantiationService.createChild(services);

		instantiationService2.invokeFunction(accessor => {
			// const telemetryService = accessor.get(ITelemetryService);

			const extensionManagementService = accessor.get(IExtensionManagementService);
			const channel = new ExtensionManagementChannel(extensionManagementService);
			server.registerChannel('extensions', channel);

			// eventually clean up old extensions
			setTimeout(() => (extensionManagementService as ExtensionManagementService).removeDeprecatedExtensions(), 5000);
		});
	});
}
開發者ID:Magicwalker,項目名稱:vscode,代碼行數:51,代碼來源:sharedProcessMain.ts


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