mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-15 01:25:36 -05:00
Creating a new database project, project items
* can create, open, and close sqlproj files * can add sql objects to projects
This commit is contained in:
@@ -13,13 +13,21 @@ import { SqlConnectionDataSource } from './sqlConnectionStringSource';
|
||||
export abstract class DataSource {
|
||||
public name: string;
|
||||
public abstract get type(): string;
|
||||
public abstract get friendlyName(): string;
|
||||
public abstract get typeFriendlyName(): string;
|
||||
|
||||
constructor(name: string) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
|
||||
export class NoDataSourcesFileError extends Error {
|
||||
constructor(message?: string) {
|
||||
super(message);
|
||||
Object.setPrototypeOf(this, new.target.prototype);
|
||||
this.name = NoDataSourcesFileError.name;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the specified file to load DataSource objects
|
||||
*/
|
||||
@@ -30,7 +38,8 @@ export async function load(dataSourcesFilePath: string): Promise<DataSource[]> {
|
||||
fileContents = await fs.readFile(dataSourcesFilePath);
|
||||
}
|
||||
catch (err) {
|
||||
throw new Error(constants.noDataSourcesFile);
|
||||
// TODO: differentiate between file not existing and other types of failures; need to know whether to prompt to create new
|
||||
throw new NoDataSourcesFileError(constants.noDataSourcesFile);
|
||||
}
|
||||
|
||||
const rawJsonContents = JSON.parse(fileContents.toString());
|
||||
|
||||
@@ -21,7 +21,7 @@ export class SqlConnectionDataSource extends DataSource {
|
||||
return SqlConnectionDataSource.type;
|
||||
}
|
||||
|
||||
public get friendlyName(): string {
|
||||
public get typeFriendlyName(): string {
|
||||
return constants.sqlConnectionStringFriendly;
|
||||
}
|
||||
|
||||
@@ -42,6 +42,10 @@ export class SqlConnectionDataSource extends DataSource {
|
||||
}
|
||||
}
|
||||
|
||||
public getSetting(settingName: string): string {
|
||||
return this.connectionStringComponents[settingName];
|
||||
}
|
||||
|
||||
public static fromJson(json: DataSourceJson): SqlConnectionDataSource {
|
||||
return new SqlConnectionDataSource(json.name, (json.data as unknown as SqlConnectionDataSourceJson).connectionString);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user