File: HubClientProxy.g.cs
Project: src\src\SignalR\clients\csharp\Client\test\UnitTests\Microsoft.AspNetCore.SignalR.Client.Tests.csproj (Microsoft.AspNetCore.SignalR.Client.Tests)
// <auto-generated>
// Generated by Microsoft.AspNetCore.Client.SourceGenerator
// </auto-generated>
#nullable enable
 
using Microsoft.AspNetCore.SignalR.Client;
 
namespace Microsoft.AspNetCore.SignalR.Client.Tests
{
    internal static partial class RegisterCallbackProviderExtensions
    {
        public static partial System.IDisposable SetHubClient<T>(this HubConnection conn, T p)
        {
            if (p is null)
            {
                throw new System.ArgumentNullException("p");
            }
 
            if (typeof(T) == typeof(Microsoft.AspNetCore.SignalR.Client.Tests.HubClientProxyGeneratorTests.IMyClient))
            {
                return (System.IDisposable) new CallbackProviderRegistration(RegisterMicrosoftAspNetCoreSignalRClientTestsHubClientProxyGeneratorTestsIMyClient(conn, (Microsoft.AspNetCore.SignalR.Client.Tests.HubClientProxyGeneratorTests.IMyClient) p));
            }
 
            throw new System.ArgumentException(nameof(T));
        }
 
        private sealed class CallbackProviderRegistration : System.IDisposable
        {
            private System.IDisposable[]? registrations;
            public CallbackProviderRegistration(params System.IDisposable[] registrations)
            {
                this.registrations = registrations;
            }
 
            public void Dispose()
            {
                if (this.registrations is null)
                {
                    return;
                }
 
                System.Collections.Generic.List<System.Exception>? exceptions = null;
                foreach(var registration in this.registrations)
                {
                    try
                    {
                        registration.Dispose();
                    }
                    catch (System.Exception exc)
                    {
                        if (exceptions is null)
                        {
                            exceptions = new ();
                        }
 
                        exceptions.Add(exc);
                    }
                }
                this.registrations = null;
                if (exceptions is not null)
                {
                    throw new System.AggregateException(exceptions);
                }
            }
        }
    }
}