Files
sqltoolsservice/ServiceHost/Server/DebugAdapterBase.cs
2016-07-15 11:02:03 -07:00

73 lines
2.3 KiB
C#

//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
#if false
using Microsoft.PowerShell.EditorServices.Protocol.DebugAdapter;
using Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol;
using Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.Channel;
using System.Threading.Tasks;
namespace Microsoft.PowerShell.EditorServices.Protocol.Server
{
public abstract class DebugAdapterBase : ProtocolEndpoint
{
public DebugAdapterBase(ChannelBase serverChannel)
: base (serverChannel, MessageProtocolType.DebugAdapter)
{
}
/// <summary>
/// Overridden by the subclass to provide initialization
/// logic after the server channel is started.
/// </summary>
protected abstract void Initialize();
/// <summary>
/// Can be overridden by the subclass to provide shutdown
/// logic before the server exits.
/// </summary>
protected virtual void Shutdown()
{
// No default implementation yet.
}
protected override Task OnStart()
{
// Register handlers for server lifetime messages
this.SetRequestHandler(InitializeRequest.Type, this.HandleInitializeRequest);
// Initialize the implementation class
this.Initialize();
return Task.FromResult(true);
}
protected override Task OnStop()
{
this.Shutdown();
return Task.FromResult(true);
}
private async Task HandleInitializeRequest(
object shutdownParams,
RequestContext<InitializeResponseBody> requestContext)
{
// Now send the Initialize response to continue setup
await requestContext.SendResult(
new InitializeResponseBody {
SupportsConfigurationDoneRequest = true,
SupportsConditionalBreakpoints = true,
SupportsFunctionBreakpoints = true
});
// Send the Initialized event so that we get breakpoints
await requestContext.SendEvent(
InitializedEvent.Type,
null);
}
}
}
#endif