本文整理汇总了TypeScript中vs/platform/instantiation/common/instantiation.IInstantiationService.createInstance方法的典型用法代码示例。如果您正苦于以下问题:TypeScript IInstantiationService.createInstance方法的具体用法?TypeScript IInstantiationService.createInstance怎么用?TypeScript IInstantiationService.createInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vs/platform/instantiation/common/instantiation.IInstantiationService
的用法示例。
在下文中一共展示了IInstantiationService.createInstance方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: createSharedProcessContributions
export function createSharedProcessContributions(service: IInstantiationService): IDisposable {
return combinedDisposable([
service.createInstance(NodeCachedDataCleaner),
service.createInstance(LanguagePackCachedDataCleaner),
service.createInstance(StorageDataCleaner)
]);
}
示例2: triggerAndDisposeAction
export function triggerAndDisposeAction(instantitationService: IInstantiationService, telemetryService: ITelemetryService, partService: IPartService, descriptor: SyncActionDescriptor, args: any): TPromise<any> {
let actionInstance = instantitationService.createInstance(descriptor.syncDescriptor);
actionInstance.label = descriptor.label || actionInstance.label;
// don't run the action when not enabled
if (!actionInstance.enabled) {
actionInstance.dispose();
return void 0;
}
const from = args && args.from || 'keybinding';
if (telemetryService) {
telemetryService.publicLog('workbenchActionExecuted', { id: actionInstance.id, from });
}
// run action when workbench is created
return partService.joinCreation().then(() => {
try {
return TPromise.as(actionInstance.run(undefined, { from })).then(() => {
actionInstance.dispose();
}, (err) => {
actionInstance.dispose();
return TPromise.wrapError(err);
});
} catch (err) {
actionInstance.dispose();
return TPromise.wrapError(err);
}
});
}
示例3: catch
return lifecycleService.when(LifecyclePhase.Running).then(() => {
const actionInstance = instantitationService.createInstance(descriptor.syncDescriptor);
try {
actionInstance.label = descriptor.label || actionInstance.label;
// don't run the action when not enabled
if (!actionInstance.enabled) {
actionInstance.dispose();
return void 0;
}
const from = args && args.from || 'keybinding';
return TPromise.as(actionInstance.run(undefined, { from })).then(() => {
actionInstance.dispose();
}, (err) => {
actionInstance.dispose();
return TPromise.wrapError(err);
});
} catch (err) {
actionInstance.dispose();
return TPromise.wrapError(err);
}
});
示例4: catch
return lifecycleService.when(LifecyclePhase.Ready).then(() => {
const actionInstance = instantiationService.createInstance(descriptor.syncDescriptor);
try {
actionInstance.label = descriptor.label || actionInstance.label;
// don't run the action when not enabled
if (!actionInstance.enabled) {
actionInstance.dispose();
return undefined;
}
const from = args && args.from || 'keybinding';
return Promise.resolve(actionInstance.run(undefined, { from })).then(() => {
actionInstance.dispose();
}, err => {
actionInstance.dispose();
return Promise.reject(err);
});
} catch (err) {
actionInstance.dispose();
return Promise.reject(err);
}
});
示例5: createConnectionTree
/**
* Create a Recent Connections tree
*/
public static createConnectionTree(treeContainer: HTMLElement, instantiationService: IInstantiationService, useController?: IController): Tree {
const dataSource = instantiationService.createInstance(RecentConnectionDataSource);
const renderer = instantiationService.createInstance(ServerTreeRenderer, true);
const controller = useController ? useController : new DefaultController();
const dnd = instantiationService.createInstance(RecentConnectionsDragAndDrop);
const filter = new DefaultFilter();
const sorter = undefined;
const accessibilityProvider = new DefaultAccessibilityProvider();
return new Tree(treeContainer, { dataSource, renderer, controller, dnd, filter, sorter, accessibilityProvider },
{
indentPixels: 10,
twistiePixels: 20,
ariaLabel: nls.localize('treeAriaLabel', "Recent Connections")
});
}
示例6: test
test('getFilteredResource return markers grouped by resource', function () {
const marker1 = aMarker('res1');
const marker2 = aMarker('res2');
const marker3 = aMarker('res1');
const marker4 = aMarker('res3');
const marker5 = aMarker('res4');
const marker6 = aMarker('res2');
const testObject = instantiationService.createInstance(TestMarkersModel, [marker1, marker2, marker3, marker4, marker5, marker6]);
const actuals = testObject.filteredResources;
assert.equal(4, actuals.length);
assert.ok(compareResource(actuals[0], 'res1'));
assert.equal(2, actuals[0].markers.length);
assert.ok(hasMarker(actuals[0].markers, marker1));
assert.ok(hasMarker(actuals[0].markers, marker3));
assert.ok(compareResource(actuals[1], 'res2'));
assert.equal(2, actuals[1].markers.length);
assert.ok(hasMarker(actuals[1].markers, marker2));
assert.ok(hasMarker(actuals[1].markers, marker6));
assert.ok(compareResource(actuals[2], 'res3'));
assert.equal(1, actuals[2].markers.length);
assert.ok(hasMarker(actuals[2].markers, marker4));
assert.ok(compareResource(actuals[3], 'res4'));
assert.equal(1, actuals[3].markers.length);
assert.ok(hasMarker(actuals[3].markers, marker5));
});
示例7: _triggerAndDisposeAction
private _triggerAndDisposeAction(instantitationService: IInstantiationService, lifecycleService: ILifecycleService, descriptor: SyncActionDescriptor, args: any): Thenable<void> {
const actionInstance = instantitationService.createInstance(descriptor.syncDescriptor);
actionInstance.label = descriptor.label || actionInstance.label;
// don't run the action when not enabled
if (!actionInstance.enabled) {
actionInstance.dispose();
return void 0;
}
const from = args && args.from || 'keybinding';
// run action when workbench is created
return lifecycleService.when(LifecyclePhase.Running).then(() => {
try {
return TPromise.as(actionInstance.run(undefined, { from })).then(() => {
actionInstance.dispose();
}, (err) => {
actionInstance.dispose();
return TPromise.wrapError(err);
});
} catch (err) {
actionInstance.dispose();
return TPromise.wrapError(err);
}
});
}
示例8: test
test('dont show after initial run', function() {
welcomePageEnvConfig = 'url';
hideWelcomeSettingsValue = 'true';
let gettingStarted = instantiation.createInstance(TestGettingStarted);
assert(gettingStarted.lastUrl === undefined, 'no page is opened after initial run');
assert(hideWelcomeSettingsValue !== null, 'a flag is set to hide welcome page');
});
示例9: test
test('Alle Drei Zusammen', function () {
let searchResult = instantiation.createInstance(SearchResult, null);
let fileMatch = aFileMatch('far\\boo', searchResult);
let lineMatch = new Match(fileMatch, 'foo bar', 1, 0, 3);
assert(lineMatch.parent() === fileMatch);
assert(fileMatch.parent() === searchResult);
});