本文整理汇总了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();
});
});
示例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);
});
});
}
示例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);
});
});
示例4:
this.createWorkspaceService(payload, environmentService, remoteAgentService, logService).then(service => {
// Workspace
serviceCollection.set(IWorkspaceContextService, service);
// Configuration
serviceCollection.set(IConfigurationService, service);
return service;
}),
示例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);
}
示例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;
}
示例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;
}
示例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);
});
});
示例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);
});
});
}