/// <summary> /// Create a new <see cref="JsonRpcNotificationHandler{TNotification}"/>. /// </summary> /// <param name="method"> /// The name of the method handled by the handler. /// </param> /// <param name="handler"> /// The underlying JSON-RPC <see cref="IJsonRpcNotificationHandler{TNotification}"/>. /// </param> public JsonRpcNotificationHandler(string method, IJsonRpcNotificationHandler <TNotification> handler) : base(method) { if (handler == null) { throw new ArgumentNullException(nameof(handler)); } Handler = handler; }
/// <summary> /// Register a handler for empty notifications. /// </summary> /// <param name="languageClient"> /// The <see cref="LanguageClient"/>. /// </param> /// <param name="method"> /// The name of the notification method to handle. /// </param> /// <param name="handler"> /// A JSON-RPC <see cref="IJsonRpcNotificationHandler"/> that implements the handler. /// </param> /// <returns> /// An <see cref="IDisposable"/> representing the registration. /// </returns> public static IDisposable HandleNotification(this LanguageClient languageClient, string method, IJsonRpcNotificationHandler handler) { if (languageClient == null) { throw new ArgumentNullException(nameof(languageClient)); } if (string.IsNullOrWhiteSpace(method)) { throw new ArgumentException($"Argument cannot be null, empty, or entirely composed of whitespace: {nameof(method)}.", nameof(method)); } if (handler == null) { throw new ArgumentNullException(nameof(handler)); } return(languageClient.RegisterHandler( new JsonRpcEmptyNotificationHandler(method, handler) )); }