Class Workspace
Manages a "workspace" of script files that are open for a particular editing session. Also helps to navigate references between ScriptFiles.
Inheritance
Inherited Members
Namespace:Microsoft.SqlTools.ServiceLayer.Workspace
Assembly:Microsoft.SqlTools.ServiceLayer.dll
Syntax
public class Workspace : IDisposable
Constructors
| Improve this Doc View SourceWorkspace()
Creates a new instance of the Workspace class.
Declaration
public Workspace()
Properties
| Improve this Doc View SourceWorkspacePath
Gets or sets the root path of the workspace.
Declaration
public string WorkspacePath { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
Methods
| Improve this Doc View SourceCloseFile(ScriptFile)
Closes a currently open script file with the given file path.
Declaration
public void CloseFile(ScriptFile scriptFile)
Parameters
| Type | Name | Description |
|---|---|---|
| ScriptFile | scriptFile | The file path at which the script resides. |
Dispose()
Disposes of any Runspaces that were created for the services used in this session.
Declaration
public void Dispose()
Implements
GetFile(String)
Gets an open file in the workspace. If the file isn't open but exists on the filesystem, load and return it. Virtual method to allow for mocking
Declaration
public virtual ScriptFile GetFile(string filePath)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | filePath | The file path at which the script resides. |
Returns
| Type | Description |
|---|---|
| ScriptFile |
Exceptions
| Type | Condition |
|---|---|
| System.IO.FileNotFoundException | filePath is not found. |
| System.ArgumentException | filePath contains a null or empty string. |
GetFileBuffer(String, String)
Gets a new ScriptFile instance which is identified by the given file path and initially contains the given buffer contents.
Declaration
public ScriptFile GetFileBuffer(string filePath, string initialBuffer)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | filePath | |
| System.String | initialBuffer |
Returns
| Type | Description |
|---|---|
| ScriptFile |
GetOpenedFiles()
Gets an array of all opened ScriptFiles in the workspace.
Declaration
public ScriptFile[] GetOpenedFiles()
Returns
| Type | Description |
|---|---|
| ScriptFile[] | An array of all opened ScriptFiles in the workspace. |
UnescapePath(String)
Unescapes any escaped [, ] or space characters. Typically use this before calling a .NET API that doesn't understand PowerShell escaped chars.
Declaration
public static string UnescapePath(string path)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | path | The path to unescape. |
Returns
| Type | Description |
|---|---|
| System.String | The path with the ` character before [, ] and spaces removed. |