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


TypeScript IStorageService.get方法代碼示例

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


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

示例1: 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

示例2: 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,代碼來源:

示例3: test

	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

示例4: 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

示例5: 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

示例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: 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


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