/// <summary> /// Adds a named Npgsql Grain Storage Provider. /// </summary> /// <param name="builder">The <see cref="ISiloBuilder"/>.</param> /// <param name="storageName">The Grain Storage name.</param> /// <param name="configuration">The <see cref="IConfiguration"/> which binds to <see cref="NpgsqlOptions"/>.</param> /// <returns>The<see cref="ISiloBuilder"/>.</returns> public static ISiloBuilder AddNpgsqlGrainStorage([NotNull] this ISiloBuilder builder, [NotNull] string storageName, [NotNull] IConfiguration configuration) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } return(builder.AddNpgsqlGrainStorage(storageName, configuration, storageName)); }
/// <summary> /// Adds a named Npgsql Grain Storage Provider using Default Storage Provider. /// </summary> /// <param name="builder">The <see cref="ISiloBuilder"/>.</param> /// <param name="configuration">The <see cref="IConfiguration"/> which binds to <see cref="NpgsqlOptions"/>.</param> /// <returns>The<see cref="ISiloBuilder"/>.</returns> public static ISiloBuilder AddNpgsqlGrainStorageAsDefault([NotNull] this ISiloBuilder builder, [NotNull] IConfiguration configuration) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } return(builder.AddNpgsqlGrainStorage(ProviderConstants.DEFAULT_STORAGE_PROVIDER_NAME, configuration)); }
/// <summary> /// Adds a named Npgsql Grain Storage Provider. /// </summary> /// <param name="builder">The <see cref="ISiloBuilder"/>.</param> /// <param name="storageName">The Grain Storage name.</param> /// <param name="configuration">The <see cref="IConfiguration"/> which binds to <see cref="NpgsqlOptions"/>.</param> /// <param name="storageSectionName">The Storage Provider section name.</param> /// <returns>The <see cref="ISiloBuilder"/>.</returns> public static ISiloBuilder AddNpgsqlGrainStorage([NotNull] this ISiloBuilder builder, [NotNull] string storageName, [NotNull] IConfiguration configuration, [NotNull] string storageSectionName) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } if (string.IsNullOrWhiteSpace(storageName)) { throw new ArgumentException($"'{nameof(storageName)}' must not be null, empty or whitespace.", nameof(storageName)); } if (string.IsNullOrWhiteSpace(storageSectionName)) { throw new ArgumentException($"'{nameof(storageSectionName)}' must not be null, empty or whitespace.", nameof(storageSectionName)); } var namedStorageSectionName = $"{NpgsqlOptions.DefaultSectionName}:{storageSectionName}"; var storageConfigSection = configuration.GetSection(namedStorageSectionName); return(builder.AddNpgsqlGrainStorage(storageName, storageConfigSection)); }