mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-16 17:22:29 -05:00
* moving test files and inital refactoring * relayer extension host code * fix imports * make insights work * relayer dashboard * relayer notebooks * moveing more code around * formatting * accept angular as browser * fix serializer * add missing files * remove declarations from extensions * fix build errors * more relayering * change urls to relative to help code relayering * remove layering to prep for merge * fix hygiene errors * fix hygiene errors * fix tests
60 lines
2.2 KiB
TypeScript
60 lines
2.2 KiB
TypeScript
/*---------------------------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
|
*--------------------------------------------------------------------------------------------*/
|
|
|
|
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
|
|
import {
|
|
SqlExtHostContext, ExtHostSerializationProviderShape,
|
|
MainThreadSerializationProviderShape, SqlMainContext
|
|
} from 'sql/workbench/api/common/sqlExtHost.protocol';
|
|
import { ISerializationService } from 'sql/platform/serialization/common/serializationService';
|
|
import * as azdata from 'azdata';
|
|
import { IExtHostContext } from 'vs/workbench/api/common/extHost.protocol';
|
|
import { extHostNamedCustomer } from 'vs/workbench/api/common/extHostCustomers';
|
|
|
|
@extHostNamedCustomer(SqlMainContext.MainThreadSerializationProvider)
|
|
export class MainThreadSerializationProvider implements MainThreadSerializationProviderShape {
|
|
|
|
private _proxy: ExtHostSerializationProviderShape;
|
|
|
|
private _toDispose: IDisposable[];
|
|
|
|
private _registrations: { [handle: number]: IDisposable; } = Object.create(null);
|
|
|
|
constructor(
|
|
extHostContext: IExtHostContext,
|
|
@ISerializationService private serializationService: ISerializationService
|
|
|
|
) {
|
|
if (extHostContext) {
|
|
this._proxy = extHostContext.getProxy(SqlExtHostContext.ExtHostSerializationProvider);
|
|
}
|
|
}
|
|
|
|
public dispose(): void {
|
|
this._toDispose = dispose(this._toDispose);
|
|
}
|
|
|
|
public $registerSerializationProvider(handle: number): Promise<any> {
|
|
let self = this;
|
|
|
|
this._registrations[handle] = this.serializationService.addEventListener(handle, {
|
|
onSaveAs(saveFormat: string, savePath: string, results: string, appendToFile: boolean): Thenable<azdata.SaveResultRequestResult> {
|
|
return self._proxy.$saveAs(saveFormat, savePath, results, appendToFile);
|
|
}
|
|
});
|
|
|
|
return undefined;
|
|
}
|
|
|
|
public $unregisterSerializationProvider(handle: number): Promise<any> {
|
|
let registration = this._registrations[handle];
|
|
if (registration) {
|
|
registration.dispose();
|
|
delete this._registrations[handle];
|
|
}
|
|
return undefined;
|
|
}
|
|
}
|