Added a new request handler to return back the service version

This commit is contained in:
Leila Lali
2016-08-22 15:08:44 -07:00
parent 4631f2083e
commit 3f1d3cb9db
2 changed files with 28 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
//
// 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.ServiceLayer.Hosting.Protocol.Contracts;
namespace Microsoft.SqlTools.ServiceLayer.Hosting.Contracts
{
public class VersionRequest
{
public static readonly
RequestType<string, string> Type =
RequestType<string, string>.Create("version");
}
}

View File

@@ -11,6 +11,7 @@ using Microsoft.SqlTools.EditorServices.Utility;
using Microsoft.SqlTools.ServiceLayer.Hosting.Contracts;
using Microsoft.SqlTools.ServiceLayer.Hosting.Protocol;
using Microsoft.SqlTools.ServiceLayer.Hosting.Protocol.Channel;
using System.Reflection;
namespace Microsoft.SqlTools.ServiceLayer.Hosting
{
@@ -55,6 +56,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Hosting
// Register the requests that this service host will handle
this.SetRequestHandler(InitializeRequest.Type, this.HandleInitializeRequest);
this.SetRequestHandler(ShutdownRequest.Type, this.HandleShutdownRequest);
this.SetRequestHandler(VersionRequest.Type, HandleVersionRequest);
}
#endregion
@@ -69,6 +71,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Hosting
private readonly List<InitializeCallback> initializeCallbacks;
private static Version _serviceServion = Assembly.GetEntryAssembly().GetName().Version;
#endregion
#region Public Methods
@@ -149,6 +153,14 @@ namespace Microsoft.SqlTools.ServiceLayer.Hosting
});
}
private static async Task HandleVersionRequest(
string workspaceSymbolParams,
RequestContext<string> requestContext)
{
Logger.Write(LogLevel.Verbose, "HandleVersionRequest");
await requestContext.SendResult(_serviceServion.ToString());
}
#endregion
}
}