/// <summary> /// Create a new <see cref="DelegateEmptyNotificationHandler"/>. /// </summary> /// <param name="method"> /// The name of the method handled by the handler. /// </param> /// <param name="handler"> /// The <see cref="EmptyNotificationHandler"/> delegate that implements the handler. /// </param> public DelegateEmptyNotificationHandler(string method, EmptyNotificationHandler handler) : base(method) { if (handler == null) { throw new ArgumentNullException(nameof(handler)); } Handler = handler; }
/// <summary> /// Register a handler for empty notifications. /// </summary> /// <param name="clientConnection"> /// The <see cref="LspConnection"/>. /// </param> /// <param name="method"> /// The name of the notification method to handle. /// </param> /// <param name="handler"> /// A <see cref="EmptyNotificationHandler"/> delegate that implements the handler. /// </param> /// <returns> /// An <see cref="IDisposable"/> representing the registration. /// </returns> public static IDisposable HandleEmptyNotification(this LspConnection clientConnection, string method, EmptyNotificationHandler handler) { if (clientConnection == null) { throw new ArgumentNullException(nameof(clientConnection)); } 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(clientConnection.RegisterHandler( new DelegateEmptyNotificationHandler(method, handler) )); }