File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ /* ---------------------------------------------------------------------------------------------
2+ * Copyright (c) Applied Eng & Design All rights reserved.
3+ * Licensed under the MIT License. See License.md in the project root for license information.
4+ * -------------------------------------------------------------------------------------------- */
5+ 'use strict' ;
6+
7+ export type LSSState = 'global' | 'workspace' ;
8+
9+ import { ExtensionContext , Memento } from 'vscode' ;
10+
11+ export class LocalStorageService {
12+ private _wsState : Memento ;
13+ private _globalState : Memento ;
14+
15+ constructor ( context : ExtensionContext ) {
16+ this . _wsState = context . workspaceState ;
17+ this . _globalState = context . globalState ;
18+ }
19+
20+ public getValue < T > ( key : string , loc : LSSState ) : T | undefined {
21+ if ( loc === 'workspace' ) {
22+ return this . _wsState . get < T > ( key ) ;
23+ } else {
24+ return this . _globalState . get < T > ( key ) ;
25+ }
26+ }
27+
28+ public async setValue < T > ( key : string , value : T , loc : LSSState ) {
29+ if ( loc === 'workspace' ) {
30+ await this . _wsState . update ( key , value ) ;
31+ } else {
32+ await this . _globalState . update ( key , value ) ;
33+ }
34+ }
35+ }
You can’t perform that action at this time.
0 commit comments