import { inject , injectable } from 'inversify' ; import { Memento } from 'vscode' ; import { IServiceContainer } from '../ioc/types' ; import { IStateStore , IStateStoreFactory } from './types/stateStore' ; export class WorkspaceMementoStore implements IStateStore { constructor ( private store ) { } public has ( key ) { return this . store . get ( key ) !== undefined ; } public async set < T > ( key , data ) { await this . store . update ( key , data ) ; } public get < T > ( key ) { return this . store . get ( key ) ; } } @ injectable ( ) export class WorkspaceStateStoreFactory implements IStateStoreFactory { constructor ( @ inject ( IServiceContainer ) private serviceContainer ) { } public createStore ( ) { return new WorkspaceMementoStore ( this . serviceContainer . get < Memento > ( 'workspaceMementoStore' ) ) ; } } @ injectable ( ) export class GlobalStateStoreFactory implements IStateStoreFactory { constructor ( @ inject ( IServiceContainer ) private serviceContainer ) { } public createStore ( ) { return new WorkspaceMementoStore ( this . serviceContainer . get < Memento > ( 'globalMementoStore' ) ) ; } }