private ValueTask DisposeFilter(IHubFilter filter)
 {
     if (filter is IAsyncDisposable asyncDispsable)
     {
         return(asyncDispsable.DisposeAsync());
     }
     if (filter is IDisposable disposable)
     {
         disposable.Dispose();
     }
     return(default);
Exemplo n.º 2
0
    /// <summary>
    /// Adds an instance of an <see cref="IHubFilter"/> to the <see cref="HubOptions"/>.
    /// </summary>
    /// <param name="options">The options to add a filter to.</param>
    /// <param name="hubFilter">The filter instance to add to the options.</param>
    public static void AddFilter(this HubOptions options, IHubFilter hubFilter)
    {
        _ = options ?? throw new ArgumentNullException(nameof(options));
        _ = hubFilter ?? throw new ArgumentNullException(nameof(hubFilter));

        if (options.HubFilters == null)
        {
            options.HubFilters = new List <IHubFilter>();
        }

        options.HubFilters.Add(hubFilter);
    }