Show / Hide Table of Contents

# Class WorkspaceService<TConfig>

Class for handling requests/events that deal with the state of the workspace, including the opening and closing of files, the changing of configuration, etc.

##### Inheritance

System.Object
WorkspaceService<TConfig>

##### Inherited Members

System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()

###### Namespace:Microsoft.SqlTools.ServiceLayer.Workspace

###### Assembly:Microsoft.SqlTools.ServiceLayer.dll

##### Syntax

    public class WorkspaceService<TConfig>
        where TConfig : class, new ()

##### Type Parameters

Name | Description
--- | ---
TConfig | The type of the class used for serializing and deserializing the configuration. Must be the actual type of the instance otherwise deserialization will be incomplete.

### Constructors

| Improve this Doc View Source

#### WorkspaceService()

Default, parameterless constructor. TODO: Figure out how to make this truely singleton even with dependency injection for tests

##### Declaration

    public WorkspaceService()

### Properties

| Improve this Doc View Source

#### CurrentSettings

Current settings for the workspace

##### Declaration

    public TConfig CurrentSettings { get; }

##### Property Value

Type | Description
--- | ---
TConfig |

| Improve this Doc View Source

#### Instance

##### Declaration

    public static WorkspaceService<TConfig> Instance { get; }

##### Property Value

Type | Description
--- | ---
WorkspaceService<TConfig> |

| Improve this Doc View Source

#### Workspace

Workspace object for the service. Virtual to allow for mocking

##### Declaration

    public virtual Workspace Workspace { get; }

##### Property Value

Type | Description
--- | ---
Workspace |

### Methods

| Improve this Doc View Source

#### InitializeService(ServiceHost)

##### Declaration

    public void InitializeService(ServiceHost serviceHost)

##### Parameters

Type | Name | Description
--- | --- | ---
ServiceHost | serviceHost |

| Improve this Doc View Source

#### RegisterConfigChangeCallback(WorkspaceService<TConfig>.ConfigChangeCallback)

Adds a new task to be called when the configuration has been changed. Use this to handle changing configuration and changing the current configuration.

##### Declaration

    public void RegisterConfigChangeCallback(WorkspaceService<TConfig>.ConfigChangeCallback task)

##### Parameters

Type | Name | Description
--- | --- | ---
WorkspaceService.ConfigChangeCallback<> | task | Task to handle the request

| Improve this Doc View Source

#### RegisterTextDocChangeCallback(WorkspaceService<TConfig>.TextDocChangeCallback)

Adds a new task to be called when the text of a document changes.

##### Declaration

    public void RegisterTextDocChangeCallback(WorkspaceService<TConfig>.TextDocChangeCallback task)

##### Parameters

Type | Name | Description
--- | --- | ---
WorkspaceService.TextDocChangeCallback<> | task | Delegate to call when the document changes

| Improve this Doc View Source

#### RegisterTextDocCloseCallback(WorkspaceService<TConfig>.TextDocCloseCallback)

Adds a new task to be called when a text document closes.

##### Declaration

    public void RegisterTextDocCloseCallback(WorkspaceService<TConfig>.TextDocCloseCallback task)

##### Parameters

Type | Name | Description
--- | --- | ---
WorkspaceService.TextDocCloseCallback<> | task | Delegate to call when the document closes

| Improve this Doc View Source

#### RegisterTextDocOpenCallback(WorkspaceService<TConfig>.TextDocOpenCallback)

Adds a new task to be called when a file is opened

##### Declaration

    public void RegisterTextDocOpenCallback(WorkspaceService<TConfig>.TextDocOpenCallback task)

##### Parameters

Type | Name | Description
--- | --- | ---
WorkspaceService.TextDocOpenCallback<> | task | Delegate to call when a document is opened