public void BuildConfiguresFullNodeUsingConfiguration() { var nodeSettings = new NodeSettings(); nodeSettings.DataDir = "TestData/FullNodeBuilder/BuildConfiguresFullNodeUsingConfiguration"; this.fullNodeBuilder.ConfigureServices(e => { e.AddSingleton(nodeSettings); e.AddSingleton(nodeSettings.LoggerFactory); e.AddSingleton(nodeSettings.GetNetwork()); e.AddSingleton <FullNode>(); }); this.fullNodeBuilder.ConfigureFeature(e => { e.AddFeature <BlockStoreFeature>(); }); this.fullNodeBuilder.ConfigureServiceProvider(e => { var settings = e.GetService <NodeSettings>(); settings.Testnet = true; }); var result = this.fullNodeBuilder.Build(); Assert.NotNull(result); }
/// <summary> /// accepts a NodeSettings instance and register required services /// </summary> /// <param name="nodeSettings"></param> public FullNodeBuilder(NodeSettings nodeSettings) : base() { this.NodeSettings = nodeSettings ?? NodeSettings.Default(); this.Network = nodeSettings.GetNetwork(); ConfigureServices(service => { service.AddSingleton(this.NodeSettings); service.AddSingleton(this.Network); }); this.AddRequired(); }
/// <summary> /// Makes the full node builder use specific node settings. /// </summary> /// <param name="builder">Full node builder to change node settings for.</param> /// <param name="nodeSettings">Node settings to be used.</param> /// <returns>Interface to allow fluent code.</returns> public static IFullNodeBuilder UseNodeSettings(this IFullNodeBuilder builder, NodeSettings nodeSettings) { var nodeBuilder = builder as FullNodeBuilder; nodeBuilder.NodeSettings = nodeSettings; nodeBuilder.Network = nodeSettings.GetNetwork(); builder.ConfigureServices(service => { service.AddSingleton(nodeBuilder.NodeSettings); service.AddSingleton(nodeBuilder.Network); }); return(builder.UseBaseFeature()); }
internal FullNodeBuilder(NodeSettings nodeSettings, List <Action <IServiceCollection> > configureServicesDelegates, List <Action <IServiceProvider> > configureDelegates, List <Action <IFeatureCollection> > featuresRegistrationDelegates, IFeatureCollection features) : this(configureServicesDelegates, configureDelegates, featuresRegistrationDelegates, features) { this.NodeSettings = nodeSettings ?? NodeSettings.Default(); this.Network = nodeSettings.GetNetwork(); this.ConfigureServices(service => { service.AddSingleton(this.NodeSettings); service.AddSingleton(this.Network); }); this.UseBaseFeature(); }
public static IFullNodeBuilder UseNodeSettings(this IFullNodeBuilder builder, NodeSettings nodeSettings) { var nodeBuilder = builder as FullNodeBuilder; nodeBuilder.NodeSettings = nodeSettings; nodeBuilder.Network = nodeSettings.GetNetwork(); builder.ConfigureServices(service => { service.AddSingleton(nodeBuilder.NodeSettings); service.AddSingleton(nodeBuilder.Network); }); // the required services can be added once the args are set return(builder.AddRequired()); }
public void BuildTwiceThrowsException() { var nodeSettings = new NodeSettings(); nodeSettings.DataDir = "TestData/FullNodeBuilder/BuildConfiguresFullNodeUsingConfiguration"; Assert.Throws <InvalidOperationException>(() => { this.fullNodeBuilder.ConfigureServices(e => { e.AddSingleton(nodeSettings); e.AddSingleton(nodeSettings.GetNetwork()); e.AddSingleton <FullNode>(); }); this.fullNodeBuilder.Build(); this.fullNodeBuilder.Build(); }); }