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


TypeScript memento.Memento類代碼示例

本文整理匯總了TypeScript中vs/workbench/common/memento.Memento的典型用法代碼示例。如果您正苦於以下問題:TypeScript Memento類的具體用法?TypeScript Memento怎麽用?TypeScript Memento使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1:

		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,代碼行數:8,代碼來源:component.ts

示例2: constructor

	constructor(
		private _storageService: IStorageService,
		private _context: Memento,
		private _configurationEditService: ConfigurationEditingService,
		private _workspaceConfigurationService: IWorkspaceConfigurationService,
		private _credentialService: ICredentialsService,
		private _capabilitiesService: ICapabilitiesService,
		private _connectionConfig?: IConnectionConfig
	) {
		if (_context) {
			this._memento = this._context.getMemento(this._storageService, MementoScope.GLOBAL);
		}
		this._groupIdToFullNameMap = {};
		this._groupFullNameToIdMap = {};
		if (!this._connectionConfig) {
			this._connectionConfig = new ConnectionConfig(this._configurationEditService,
				this._workspaceConfigurationService, this._capabilitiesService);
		}
	}
開發者ID:AlexxNica,項目名稱:sqlopsstudio,代碼行數:19,代碼來源:connectionStore.ts

示例3: test

	test('Save and Load', () => {
		let myMemento = new Memento('memento.test');

		// Global
		let memento = myMemento.getMemento(storage, context);
		memento.foo = [1, 2, 3];

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

		myMemento.saveMemento();

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

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

		// Global
		memento = myMemento.getMemento(storage, context);
		memento.foo = [4, 5, 6];

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

		myMemento.saveMemento();

		// Global
		memento = myMemento.getMemento(storage, context);
		assert.deepEqual(memento, { foo: [4, 5, 6] });
		globalMemento = myMemento.getMemento(storage, Scope.GLOBAL);
		assert.deepEqual(globalMemento, memento);

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

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

		// Delete Workspace
		memento = myMemento.getMemento(storage, Scope.WORKSPACE);
		delete memento.foo;

		myMemento.saveMemento();

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

		// Workspace
		memento = myMemento.getMemento(storage, Scope.WORKSPACE);
		assert.deepEqual(memento, {});
	});
開發者ID:AjuanM,項目名稱:vscode,代碼行數:63,代碼來源:memento.test.ts

示例4: test

	test("Save and Load", () => {
		let myMemento = new Memento("memento.test");

		// Global
		let memento = myMemento.getMemento(storage, context)
		memento.foo = [1, 2, 3];

		// Workspace
		memento = myMemento.getMemento(storage, Scope.WORKSPACE)
		assert(memento);
		memento.foo = "Hello World";

		myMemento.saveMemento();

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

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

		// Global
		memento = myMemento.getMemento(storage, context)
		memento.foo = [4, 5, 6];

		// Workspace
		memento = myMemento.getMemento(storage, Scope.WORKSPACE)
		assert(memento);
		memento.foo = "World Hello";

		myMemento.saveMemento();

		// Global
		memento = myMemento.getMemento(storage, context)
		assert.deepEqual(memento, { foo: [4, 5, 6] });
		globalMemento = myMemento.getMemento(storage, Scope.GLOBAL);
		assert.deepEqual(globalMemento, memento);

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

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

		// Delete Workspace
		memento = myMemento.getMemento(storage, Scope.WORKSPACE)
		delete memento.foo;

		myMemento.saveMemento();

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

		// Workspace
		memento = myMemento.getMemento(storage, Scope.WORKSPACE)
		assert.deepEqual(memento, {});
	});
開發者ID:578723746,項目名稱:vscode,代碼行數:63,代碼來源:memento.test.ts

示例5: getMemento

	protected getMemento(scope: StorageScope): object {
		return this.memento.getMemento(scope);
	}
開發者ID:DonJayamanne,項目名稱:vscode,代碼行數:3,代碼來源:component.ts

示例6: saveMemento

	/**
	* Saves all data of the mementos that have been loaded to the local storage. This includes
	* global and workspace scope.
	*
	* Mementos are shared across components with the same id. This means that multiple components
	* with the same id will store data into the same data structure.
	*/
	protected saveMemento(): void {
		this.componentMemento.saveMemento();
	}
開發者ID:diarmaidm,項目名稱:vscode,代碼行數:10,代碼來源:component.ts

示例7: getMemento

	/**
	* Returns a JSON Object that represents the data of this memento. The optional
	* parameter scope allows to specify the scope of the memento to load. If not
	* provided, the scope will be global, Scope.WORKSPACE can be used to
	* scope the memento to the workspace.
	*
	* Mementos are shared across components with the same id. This means that multiple components
	* with the same id will store data into the same data structure.
	*/
	protected getMemento(storageService: IStorageService, scope: Scope = Scope.GLOBAL): any {
		return this.componentMemento.getMemento(storageService, scope);
	}
開發者ID:diarmaidm,項目名稱:vscode,代碼行數:12,代碼來源:component.ts


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