mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-23 01:25:42 -05:00
added change database handler (#505)
This commit is contained in:
@@ -863,6 +863,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection
|
||||
serviceHost.SetRequestHandler(CancelConnectRequest.Type, HandleCancelConnectRequest);
|
||||
serviceHost.SetRequestHandler(DisconnectRequest.Type, HandleDisconnectRequest);
|
||||
serviceHost.SetRequestHandler(ListDatabasesRequest.Type, HandleListDatabasesRequest);
|
||||
serviceHost.SetRequestHandler(ChangeDatabaseRequest.Type, HandleChangeDatabase);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1165,6 +1166,17 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection
|
||||
return connectionBuilder;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles a request to change the database for a connection
|
||||
/// </summary>
|
||||
public async Task HandleChangeDatabase(
|
||||
ChangeDatabaseParams changeDatabaseParams,
|
||||
RequestContext<bool> requestContext)
|
||||
{
|
||||
ChangeConnectionDatabaseContext(changeDatabaseParams.OwnerUri, changeDatabaseParams.NewDatabase);
|
||||
await requestContext.SendResult(true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Change the database context of a connection.
|
||||
/// </summary>
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.Connection.Contracts
|
||||
{
|
||||
/// <summary>
|
||||
/// Parameters for the List Databases Request.
|
||||
/// </summary>
|
||||
public class ChangeDatabaseParams
|
||||
{
|
||||
/// <summary>
|
||||
/// URI of the owner of the connection requesting the list of databases.
|
||||
/// </summary>
|
||||
public string OwnerUri { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The database to change to
|
||||
/// </summary>
|
||||
public string NewDatabase { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
using Microsoft.SqlTools.Hosting.Protocol.Contracts;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.Connection.Contracts
|
||||
{
|
||||
/// <summary>
|
||||
/// List databases request mapping entry
|
||||
/// </summary>
|
||||
public class ChangeDatabaseRequest
|
||||
{
|
||||
public static readonly
|
||||
RequestType<ChangeDatabaseParams, bool> Type =
|
||||
RequestType<ChangeDatabaseParams, bool>.Create("connection/changedatabase");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user