/// <inheritdoc /> void ISiloBuilderConfigurator.Configure(ISiloHostBuilder hostBuilder) { this.TestClusterOptions = hostBuilder.GetTestClusterOptions(); if (!hostBuilder.Properties.TryGetValue(nameof(ClusterConfiguration), out var configObj)) { var serializationManager = LegacyTestClusterConfiguration.CreateLegacyConfigurationSerializer(); var serializedClusterConfig = hostBuilder.GetConfigurationValue(LegacyTestClusterConfiguration.ClusterConfigurationKey); if (!string.IsNullOrWhiteSpace(serializedClusterConfig)) { this.ClusterConfiguration = LegacyTestClusterConfiguration.Deserialize <ClusterConfiguration>(serializationManager, serializedClusterConfig); hostBuilder.Properties[nameof(ClusterConfiguration)] = this.ClusterConfiguration; } } else { this.ClusterConfiguration = (ClusterConfiguration)configObj; } if (this.ClusterConfiguration == null) { throw new InvalidOperationException("There is no ClusterConfiguration, which is unexpected for the current set up."); } this.Configure(hostBuilder); }
/// <summary> /// Configures a <see cref="TestClusterBuilder"/> with legacy configuration objects, /// <see cref="Orleans.Runtime.Configuration.ClusterConfiguration"/> and <see cref="Orleans.Runtime.Configuration.ClientConfiguration"/>. /// </summary> /// <param name="builder">The test cluster builder.</param> /// <param name="configure">The configuration delegate.</param> public static void ConfigureLegacyConfiguration(this TestClusterBuilder builder, Action <LegacyTestClusterConfiguration> configure = null) { if (!builder.Properties.TryGetValue(nameof(LegacyTestClusterConfiguration), out var legacyConfigObj) || !(legacyConfigObj is LegacyTestClusterConfiguration legacyConfig)) { legacyConfig = new LegacyTestClusterConfiguration(builder); builder.Properties[nameof(LegacyTestClusterConfiguration)] = legacyConfig; builder.ConfigureHostConfiguration(legacyConfig.ConfigureHostConfiguration); builder.AddSiloBuilderConfigurator <AddLegacyConfigurationSiloConfigurator>(); builder.AddClientBuilderConfigurator <AddLegacyConfiguratorClientConfigurator>(); } builder.ConfigureBuilder(() => { configure?.Invoke(legacyConfig); }); }