コード例 #1
0
        /// <summary>
        /// Creates a new <see cref="IClusterClient"/> with default options.
        /// </summary>
        /// <param name="services">The <see cref="IServiceCollection" /> to add the services to.</param>
        /// <param name="configureClient">The <see cref="Action{ClientBuilder}"/> on which will be used to set the options for the client.</param>
        /// <returns>The <see cref="IServiceCollection" /> so that additional calls can be chained.</returns>
        public static IClusterClient CreateClusterClient([NotNull] this IServiceCollection services, [NotNull] Action <ClientBuilder> configureClient)
        {
            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }
            if (configureClient == null)
            {
                throw new ArgumentNullException(nameof(configureClient));
            }

            var builder = new ClientBuilder();

            configureClient.Invoke(builder);

            return(builder.BuildAndConnect());
        }