added change database handler (#505)

This commit is contained in:
Anthony Dresser
2017-10-18 19:09:55 -07:00
committed by GitHub
parent 705a89624a
commit 680f9f47d0
3 changed files with 54 additions and 0 deletions

View File

@@ -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>

View File

@@ -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; }
}
}

View File

@@ -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");
}
}