• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript storage.IStorageService类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中vs/platform/storage/common/storage.IStorageService的典型用法代码示例。如果您正苦于以下问题:TypeScript IStorageService类的具体用法?TypeScript IStorageService怎么用?TypeScript IStorageService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了IStorageService类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: loadExperiments

export function loadExperiments(storageService: IStorageService, configurationService: IConfigurationService): ITelemetryExperiments {

	const key = 'experiments.randomness';
	let valueString = storageService.get(key);
	if (!valueString) {
		valueString = Math.random().toString();
		storageService.store(key, valueString);
	}

	const random0 = parseFloat(valueString);
	let [random1, showDefaultViewlet] = splitRandom(random0);
	const [random2, showCommandsWatermark] = splitRandom(random1);
	let [, openUntitledFile] = splitRandom(random2);

	// is the user a first time user?
	let isNewSession = storageService.get('telemetry.lastSessionDate') ? false : true;
	if (!isNewSession) {
		// for returning users we fall back to the default configuration for the sidebar and the initially opened, empty editor
		showDefaultViewlet = defaultExperiments.showDefaultViewlet;
		openUntitledFile = defaultExperiments.openUntitledFile;
	}

	return applyOverrides(configurationService, {
		showDefaultViewlet,
		showCommandsWatermark,
		openUntitledFile
	});
}
开发者ID:,项目名称:,代码行数:28,代码来源:


示例2: loadExperiments

export function loadExperiments(contextService: IWorkspaceContextService, storageService: IStorageService, configurationService: IConfigurationService): ITelemetryExperiments {

	const key = 'experiments.randomness';
	let valueString = storageService.get(key);
	if (!valueString) {
		valueString = Math.random().toString();
		storageService.store(key, valueString);
	}

	const random1 = parseFloat(valueString);
	let [random2, showNewUserWatermark] = splitRandom(random1);
	let [random3, openUntitledFile] = splitRandom(random2);
	let [, openGettingStarted] = splitRandom(random3);

	const newUserDuration = 24 * 60 * 60 * 1000;
	const firstSessionDate = storageService.get('telemetry.firstSessionDate');
	const isNewUser = !firstSessionDate || Date.now() - Date.parse(firstSessionDate) < newUserDuration;
	if (!isNewUser || contextService.hasWorkspace()) {
		showNewUserWatermark = defaultExperiments.showNewUserWatermark;
		openUntitledFile = defaultExperiments.openUntitledFile;
	}

	const isNewSession = !storageService.get('telemetry.lastSessionDate');
	const now = Date.now();
	if (!(isNewSession && now >= beginGettingStartedExp && now < endGettingStartedExp)) {
		openGettingStarted = undefined;
	}

	return applyOverrides(configurationService, {
		showNewUserWatermark,
		openUntitledFile,
		openGettingStarted
	});
}
开发者ID:StateFarmIns,项目名称:vscode,代码行数:34,代码来源:telemetry.ts


示例3: getExperimentsRandomness

function getExperimentsRandomness(storageService: IStorageService) {
	const key = 'experiments.randomness';
	let valueString = storageService.get(key);
	if (!valueString) {
		valueString = Math.random().toString();
		storageService.store(key, valueString);
	}

	return parseFloat(valueString);
}
开发者ID:Chan-PH,项目名称:vscode,代码行数:10,代码来源:experiments.ts


示例4: getGloballyDisabledExtensions

export function getGloballyDisabledExtensions(extensionEnablementService: IExtensionEnablementService, storageService: IStorageService, installedExtensions: { id: string; }[]) {
	const globallyDisabled = extensionEnablementService.getGloballyDisabledExtensions();
	if (!storageService.getBoolean(BetterMergeCheckKey, StorageScope.GLOBAL, false)) {
		storageService.store(BetterMergeCheckKey, true);
		if (globallyDisabled.every(disabled => disabled.id !== BetterMergeId) && installedExtensions.some(d => d.id === BetterMergeId)) {
			globallyDisabled.push({ id: BetterMergeId });
			extensionEnablementService.setEnablement({ id: BetterMergeId }, false);
			storageService.store(BetterMergeDisabledNowKey, true);
		}
	}
	return globallyDisabled;
}
开发者ID:SeanKilleen,项目名称:vscode,代码行数:12,代码来源:extensionManagementUtil.ts


示例5: loadExperiments

export function loadExperiments(storageService: IStorageService, configurationService: IConfigurationService): ITelemetryExperiments {
	const key = 'experiments.randomness';
	let valueString = storageService.get(key);
	if (!valueString) {
		valueString = Math.random().toString();
		storageService.store(key, valueString);
	}
	const random0 = parseFloat(valueString);
	const [random1, showDefaultViewlet] = splitRandom(random0);
	const [random2, showCommandsWatermark] = splitRandom(random1);
	const [, openUntitledFile] = splitRandom(random2);
	return applyOverrides(configurationService, {
		showDefaultViewlet,
		showCommandsWatermark,
		openUntitledFile
	});
}
开发者ID:asotog,项目名称:vscode,代码行数:17,代码来源:telemetry.ts


示例6: resolveWorkbenchCommonProperties

export async function resolveWorkbenchCommonProperties(storageService: IStorageService, commit: string | undefined, version: string | undefined, machineId: string, installSourcePath: string, remoteAuthority?: string): Promise<{ [name: string]: string | undefined }> {
	const result = await resolveCommonProperties(commit, version, machineId, installSourcePath);
	const instanceId = storageService.get(instanceStorageKey, StorageScope.GLOBAL)!;
	const firstSessionDate = storageService.get(firstSessionDateStorageKey, StorageScope.GLOBAL)!;
	const lastSessionDate = storageService.get(lastSessionDateStorageKey, StorageScope.GLOBAL)!;

	// __GDPR__COMMON__ "common.version.shell" : { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth" }
	result['common.version.shell'] = process.versions && process.versions['electron'];
	// __GDPR__COMMON__ "common.version.renderer" : { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth" }
	result['common.version.renderer'] = process.versions && process.versions['chrome'];
	// __GDPR__COMMON__ "common.firstSessionDate" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
	result['common.firstSessionDate'] = firstSessionDate;
	// __GDPR__COMMON__ "common.lastSessionDate" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
	result['common.lastSessionDate'] = lastSessionDate || '';
	// __GDPR__COMMON__ "common.isNewSession" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
	result['common.isNewSession'] = !lastSessionDate ? '1' : '0';
	// __GDPR__COMMON__ "common.instanceId" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
	result['common.instanceId'] = instanceId;
	// __GDPR__COMMON__ "common.remoteAuthority" : { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth" }
	result['common.remoteAuthority'] = cleanRemoteAuthority(remoteAuthority);

	return result;
}
开发者ID:PKRoma,项目名称:vscode,代码行数:23,代码来源:workbenchCommonProperties.ts


示例7: constructor

	constructor(
		id: string,
		themeService: IThemeService,
		storageService: IStorageService
	) {
		super(themeService);

		this.id = id;
		this.memento = new Memento(this.id, storageService);

		this._register(storageService.onWillSaveState(() => {

			// Ask the component to persist state into the memento
			this.saveState();

			// Then save the memento into storage
			this.memento.saveMemento();
		}));
	}
开发者ID:DonJayamanne,项目名称:vscode,代码行数:19,代码来源:component.ts


示例8: Memento

	test('Loading and Saving Memento with Scopes', () => {
		let myMemento = new Memento('memento.test', storage);

		// Global
		let memento: any = myMemento.getMemento(StorageScope.GLOBAL);
		memento.foo = [1, 2, 3];
		let globalMemento = myMemento.getMemento(StorageScope.GLOBAL);
		assert.deepEqual(globalMemento, memento);

		// Workspace
		memento = myMemento.getMemento(StorageScope.WORKSPACE);
		assert(memento);
		memento.foo = 'Hello World';

		myMemento.saveMemento();

		// Global
		memento = myMemento.getMemento(StorageScope.GLOBAL);
		assert.deepEqual(memento, { foo: [1, 2, 3] });
		globalMemento = myMemento.getMemento(StorageScope.GLOBAL);
		assert.deepEqual(globalMemento, memento);

		// Workspace
		memento = myMemento.getMemento(StorageScope.WORKSPACE);
		assert.deepEqual(memento, { foo: 'Hello World' });

		// Assert the Mementos are stored properly in storage
		assert.deepEqual(JSON.parse(storage.get('memento/memento.test', StorageScope.GLOBAL)), { foo: [1, 2, 3] });

		assert.deepEqual(JSON.parse(storage.get('memento/memento.test', StorageScope.WORKSPACE)), { foo: 'Hello World' });

		// Delete Global
		memento = myMemento.getMemento(context);
		delete memento.foo;

		// Delete Workspace
		memento = myMemento.getMemento(StorageScope.WORKSPACE);
		delete memento.foo;

		myMemento.saveMemento();

		// Global
		memento = myMemento.getMemento(context);
		assert.deepEqual(memento, {});

		// Workspace
		memento = myMemento.getMemento(StorageScope.WORKSPACE);
		assert.deepEqual(memento, {});

		// Assert the Mementos are also removed from storage
		assert.strictEqual(storage.get('memento/memento.test', StorageScope.GLOBAL, null), null);

		assert.strictEqual(storage.get('memento/memento.test', StorageScope.WORKSPACE, null), null);
	});
开发者ID:DonJayamanne,项目名称:vscode,代码行数:54,代码来源:memento.test.ts


示例9: function

	test('lastSessionDate when aviablale', async function () {

		nestStorage2Service.store('telemetry.lastSessionDate', new Date().toUTCString(), StorageScope.GLOBAL);

		const props = await resolveWorkbenchCommonProperties(nestStorage2Service, commit, version, 'someMachineId', installSource);
		assert.ok('common.lastSessionDate' in props); // conditional, see below
		assert.ok('common.isNewSession' in props);
		assert.equal(props['common.isNewSession'], 0);
	});
开发者ID:KTXSoftware,项目名称:KodeStudio,代码行数:9,代码来源:commonProperties.test.ts


示例10: resolveCommonProperties

	return resolveCommonProperties(commit, version, machineId, installSourcePath).then(result => {
		const instanceId = storageService.get('telemetry.instanceId', StorageScope.GLOBAL)!;
		const firstSessionDate = storageService.get('telemetry.firstSessionDate', StorageScope.GLOBAL)!;
		const lastSessionDate = storageService.get(lastSessionDateStorageKey, StorageScope.GLOBAL)!;

		// __GDPR__COMMON__ "common.version.shell" : { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth" }
		result['common.version.shell'] = process.versions && process.versions['electron'];
		// __GDPR__COMMON__ "common.version.renderer" : { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth" }
		result['common.version.renderer'] = process.versions && process.versions['chrome'];
		// __GDPR__COMMON__ "common.firstSessionDate" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
		result['common.firstSessionDate'] = firstSessionDate;
		// __GDPR__COMMON__ "common.lastSessionDate" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
		result['common.lastSessionDate'] = lastSessionDate || '';
		// __GDPR__COMMON__ "common.isNewSession" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
		result['common.isNewSession'] = !lastSessionDate ? '1' : '0';
		// __GDPR__COMMON__ "common.instanceId" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
		result['common.instanceId'] = instanceId;

		return result;
	});
开发者ID:donaldpipowitch,项目名称:vscode,代码行数:20,代码来源:workbenchCommonProperties.ts



注:本文中的vs/platform/storage/common/storage.IStorageService类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript storageLegacyMigration.parseStorage函数代码示例发布时间:2022-05-25
下一篇:
TypeScript migration.parseStorage函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap