本文整理汇总了TypeScript中vs/platform/storage/common/storageService.StorageService类的典型用法代码示例。如果您正苦于以下问题:TypeScript StorageService类的具体用法?TypeScript StorageService怎么用?TypeScript StorageService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了StorageService类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: test
test('Remove Data', () => {
let s = new StorageService(new InMemoryLocalStorage(), null, contextService.getWorkspace());
s.store('Monaco.IDE.Core.Storage.Test.remove', 'foobar');
assert.strictEqual('foobar', s.get('Monaco.IDE.Core.Storage.Test.remove'));
s.remove('Monaco.IDE.Core.Storage.Test.remove');
assert.ok(!s.get('Monaco.IDE.Core.Storage.Test.remove'));
});
开发者ID:FabianLauer,项目名称:vscode,代码行数:8,代码来源:storageService.test.ts
示例2: test
test('Migrate Storage (empty => multi root)', () => {
const workspaceToMigrateFrom = URI.from({ path: '1500007676869', scheme: 'empty' }).toString();
createService(workspaceToMigrateFrom);
const workspaceToMigrateTo = URI.from({ path: '2500007676869', scheme: 'root' }).toString();
migrateStorageToMultiRootWorkspace(workspaceToMigrateFrom, { id: '2500007676869', configPath: null }, storage);
const s2 = new StorageService(storage, storage, workspaceToMigrateTo);
const parsed = parseStorage(storage);
assert.equal(parsed.empty.size, 1);
assert.equal(parsed.folder.size, 0);
assert.equal(parsed.multiRoot.size, 1);
const migratedStorage = parsed.multiRoot.get(workspaceToMigrateTo);
assert.equal(Object.keys(migratedStorage).length, 4);
assert.equal(migratedStorage['key1'], s2.get('key1', StorageScope.WORKSPACE));
assert.equal(migratedStorage['key2.something'], s2.get('key2.something', StorageScope.WORKSPACE));
assert.equal(migratedStorage['key3/special'], s2.get('key3/special', StorageScope.WORKSPACE));
assert.equal(migratedStorage['key4 space'], s2.get('key4 space', StorageScope.WORKSPACE));
});
开发者ID:ramesius,项目名称:vscode,代码行数:22,代码来源:migration.test.ts
示例3: createService
function createService(workspaceId?: string): StorageService {
const service = new StorageService(storage, storage, workspaceId, workspaceId && startsWith(workspaceId, 'file:') ? Date.now() : void 0);
// Unrelated
storage.setItem('foo', 'bar');
storage.setItem('storage://foo', 'bar');
storage.setItem('storage://global/storage://foo', 'bar');
// Global
service.store('key1', 'value1');
service.store('key2.something', JSON.stringify({ foo: 'bar' }));
service.store('key3/special', true);
service.store('key4 space', 4);
// Workspace
service.store('key1', 'value1', StorageScope.WORKSPACE);
service.store('key2.something', JSON.stringify({ foo: 'bar' }), StorageScope.WORKSPACE);
service.store('key3/special', true, StorageScope.WORKSPACE);
service.store('key4 space', 4, StorageScope.WORKSPACE);
return service;
}
开发者ID:ramesius,项目名称:vscode,代码行数:22,代码来源:migration.test.ts
示例4: suite
suite('Memento', () => {
let context: Scope = undefined;
let storage: StorageService;
setup(() => {
storage = new StorageService(new InMemoryLocalStorage(), null, TestWorkspace.id);
});
test('Loading and Saving Memento with Scopes', () => {
let myMemento = new Memento('memento.test');
// Global
let memento: any = myMemento.getMemento(storage);
memento.foo = [1, 2, 3];
let globalMemento = myMemento.getMemento(storage, Scope.GLOBAL);
assert.deepEqual(globalMemento, memento);
// Workspace
memento = myMemento.getMemento(storage, Scope.WORKSPACE);
assert(memento);
memento.foo = 'Hello World';
myMemento.saveMemento();
// Global
memento = myMemento.getMemento(storage);
assert.deepEqual(memento, { foo: [1, 2, 3] });
globalMemento = myMemento.getMemento(storage, Scope.GLOBAL);
assert.deepEqual(globalMemento, memento);
// Workspace
memento = myMemento.getMemento(storage, Scope.WORKSPACE);
assert.deepEqual(memento, { foo: 'Hello World' });
// Assert the Mementos are stored properly in storage
assert.deepEqual(JSON.parse(storage.get('memento/memento.test')), { foo: [1, 2, 3] });
assert.deepEqual(JSON.parse(storage.get('memento/memento.test', StorageScope.WORKSPACE)), { foo: 'Hello World' });
// 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, {});
// 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);
});
test('Save and Load', () => {
let myMemento = new Memento('memento.test');
// Global
let memento: any = 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);
//.........这里部分代码省略.........
开发者ID:developers23,项目名称:vscode,代码行数:101,代码来源:memento.test.ts
示例5: suite
suite('Telemetry - common properties', function () {
const parentDir = getRandomTestPath(os.tmpdir(), 'vsctests', 'telemetryservice');
const installSource = path.join(parentDir, 'installSource');
const commit: string = void 0;
const version: string = void 0;
let storageService: StorageService;
setup(() => {
storageService = new StorageService(new InMemoryLocalStorage(), null, TestWorkspace.id);
});
teardown(done => {
del(parentDir, os.tmpdir(), done);
});
test('default', function () {
return mkdirp(parentDir).then(() => {
fs.writeFileSync(installSource, 'my.install.source');
return resolveWorkbenchCommonProperties(storageService, commit, version, 'someMachineId', installSource).then(props => {
assert.ok('commitHash' in props);
assert.ok('sessionID' in props);
assert.ok('timestamp' in props);
assert.ok('common.platform' in props);
assert.ok('common.nodePlatform' in props);
assert.ok('common.nodeArch' in props);
assert.ok('common.timesincesessionstart' in props);
assert.ok('common.sequence' in props);
// assert.ok('common.version.shell' in first.data); // only when running on electron
// assert.ok('common.version.renderer' in first.data);
assert.ok('common.osVersion' in props, 'osVersion');
assert.ok('common.platformVersion' in props, 'platformVersion');
assert.ok('version' in props);
assert.equal(props['common.source'], 'my.install.source');
assert.ok('common.firstSessionDate' in props, 'firstSessionDate');
assert.ok('common.lastSessionDate' in props, 'lastSessionDate'); // conditional, see below, 'lastSessionDate'ow
assert.ok('common.isNewSession' in props, 'isNewSession');
// machine id et al
assert.ok('common.instanceId' in props, 'instanceId');
assert.ok('common.machineId' in props, 'machineId');
fs.unlinkSync(installSource);
return resolveWorkbenchCommonProperties(storageService, commit, version, 'someMachineId', installSource).then(props => {
assert.ok(!('common.source' in props));
});
});
});
});
test('lastSessionDate when aviablale', function () {
storageService.store('telemetry.lastSessionDate', new Date().toUTCString());
return resolveWorkbenchCommonProperties(storageService, commit, version, 'someMachineId', installSource).then(props => {
assert.ok('common.lastSessionDate' in props); // conditional, see below
assert.ok('common.isNewSession' in props);
assert.equal(props['common.isNewSession'], 0);
});
});
test('values chance on ask', function () {
return resolveWorkbenchCommonProperties(storageService, commit, version, 'someMachineId', installSource).then(props => {
let value1 = props['common.sequence'];
let value2 = props['common.sequence'];
assert.ok(value1 !== value2, 'seq');
value1 = props['timestamp'];
value2 = props['timestamp'];
assert.ok(value1 !== value2, 'timestamp');
value1 = props['common.timesincesessionstart'];
return TPromise.timeout(10).then(_ => {
value2 = props['common.timesincesessionstart'];
assert.ok(value1 !== value2, 'timesincesessionstart');
});
});
});
});
开发者ID:JarnoNijboer,项目名称:vscode,代码行数:84,代码来源:commonProperties.test.ts
示例6: Memento
test('Loading and Saving Memento with Scopes', () => {
let myMemento = new Memento('memento.test');
// Global
let memento: any = myMemento.getMemento(storage);
memento.foo = [1, 2, 3];
let globalMemento = myMemento.getMemento(storage, Scope.GLOBAL);
assert.deepEqual(globalMemento, memento);
// Workspace
memento = myMemento.getMemento(storage, Scope.WORKSPACE);
assert(memento);
memento.foo = 'Hello World';
myMemento.saveMemento();
// Global
memento = myMemento.getMemento(storage);
assert.deepEqual(memento, { foo: [1, 2, 3] });
globalMemento = myMemento.getMemento(storage, Scope.GLOBAL);
assert.deepEqual(globalMemento, memento);
// Workspace
memento = myMemento.getMemento(storage, Scope.WORKSPACE);
assert.deepEqual(memento, { foo: 'Hello World' });
// Assert the Mementos are stored properly in storage
assert.deepEqual(JSON.parse(storage.get('memento/memento.test')), { foo: [1, 2, 3] });
assert.deepEqual(JSON.parse(storage.get('memento/memento.test', StorageScope.WORKSPACE)), { foo: 'Hello World' });
// 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, {});
// 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:developers23,项目名称:vscode,代码行数:54,代码来源:memento.test.ts
示例7: function
test('lastSessionDate when aviablale', async function () {
storageService.store('telemetry.lastSessionDate', new Date().toUTCString());
const props = await resolveWorkbenchCommonProperties(storageService, 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:ramesius,项目名称:vscode,代码行数:9,代码来源:commonProperties.test.ts
示例8: resolveWorkbenchCommonProperties
test('lastSessionDate when aviablale', function () {
storageService.store('telemetry.lastSessionDate', new Date().toUTCString());
return resolveWorkbenchCommonProperties(storageService, commit, version, source).then(props => {
assert.ok('common.lastSessionDate' in props); // conditional, see below
assert.ok('common.isNewSession' in props);
assert.equal(props['common.isNewSession'], 0);
});
});
开发者ID:SeanKilleen,项目名称:vscode,代码行数:11,代码来源:commonProperties.test.ts
注:本文中的vs/platform/storage/common/storageService.StorageService类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论