mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-03 17:24:53 -05:00
* Adding useful unit tests for this functionality * Adding callback functionality for when a file is closed * Fixing bad data issue w/closing/opening untitled doc * Adding useful unit tests for this functionality * Adding callback functionality for when a file is closed * Moving from public to internal
40 lines
1.0 KiB
C#
40 lines
1.0 KiB
C#
//
|
|
// Copyright (c) Microsoft. All rights reserved.
|
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
//
|
|
|
|
using System.Threading.Tasks;
|
|
using Microsoft.SqlTools.ServiceLayer.Hosting.Protocol.Contracts;
|
|
|
|
namespace Microsoft.SqlTools.ServiceLayer.Hosting.Protocol
|
|
{
|
|
/// <summary>
|
|
/// Provides context for a received event so that handlers
|
|
/// can write events back to the channel.
|
|
/// </summary>
|
|
public class EventContext
|
|
{
|
|
private readonly MessageWriter messageWriter;
|
|
|
|
/// <summary>
|
|
/// Parameterless constructor required for mocking
|
|
/// </summary>
|
|
public EventContext() { }
|
|
|
|
public EventContext(MessageWriter messageWriter)
|
|
{
|
|
this.messageWriter = messageWriter;
|
|
}
|
|
|
|
public async Task SendEvent<TParams>(
|
|
EventType<TParams> eventType,
|
|
TParams eventParams)
|
|
{
|
|
await this.messageWriter.WriteEvent(
|
|
eventType,
|
|
eventParams);
|
|
}
|
|
}
|
|
}
|
|
|