Partager via


ICodeLensCallbackListener Interface

Definition

Represents an object in VS process that listens and responds to callback from CodeLens OOP extensions. The remote CodeLens extension calls back to VS via one of the InvokeAsync overloads on ICodeLensCallbackService.

public interface class ICodeLensCallbackListener
public interface ICodeLensCallbackListener
type ICodeLensCallbackListener = interface
Public Interface ICodeLensCallbackListener

Examples

The implementer of this interface should make sure that the implementation has the callback method that exactly matches the target name passed to the InvokeAsync call in order to receive the callback.

For example, the remote CodeLens extension originates a callback with JSON-RPC method "MyCallbackListener.Callback":

[Import]
ICodeLensCallbackService callbackService;
...
// Invoke the callback for the data point
var result = await callbackService.InvokeAsync<MyDataType>("MyCallbackListener.Callback", argument);

The ICodeLensCallbackListener implementation that has the following JsonRpcMethodAttribute will receive the callback:

[Export(typeof(ICodeLensCallbackListener))]
public sealed class CodeLensCallbackListener : ICodeLensCallbackListener
{
    [JsonRpcMethod("MyCallbackListener.Callback")]
    public async Task<MyDataType> OnCallbackAsync(object argument)
    {
        ...
        MyDataType result = await CalculateResult(argument);
        return result;
    }
}

Remarks

This is a MEF component part loaded in to VS process and exported by CodeLens data point provider extenders.

Applies to