private static void EnsureEndpoint(Endpoint endpoint) { if (endpoint == null) { throw new Exception("IncorrectEndpoint"); } }
public static async Task RunAsConsoleAsync(Endpoint endpoint, Func <IMessageSession, Task> consoleHolder = null) { EnsureEndpoint(endpoint); endpoint.StartAsync().Wait(); if (consoleHolder == null) { consoleHolder = instance => new HostBuilder().RunConsoleAsync(); } await consoleHolder(endpoint.Instance); await endpoint.StopAsync(); }