Пример #1
0
        public static AgentFrameworkBuilder AddAgent <TAgent, TConfiguration>(this AgentFrameworkBuilder frameworkBuilder, Func <TConfiguration> createConfiguration)
            where TAgent : class, IAgent
            where TConfiguration : ProvisioningConfiguration
        {
            var configuration = createConfiguration.Invoke();

            frameworkBuilder.Services.Configure <WalletOptions>(obj =>
            {
                obj.WalletConfiguration = configuration.WalletConfiguration;
                obj.WalletCredentials   = configuration.WalletCredentials;
            });

            frameworkBuilder.Services.Configure <PoolOptions>(obj =>
            {
                obj.PoolName        = configuration.PoolName;
                obj.GenesisFilename = configuration.GenesisFilename;
            });

            frameworkBuilder.AddAgentProvider();
            frameworkBuilder.Services.AddDefaultMessageHandlers();
            frameworkBuilder.Services.AddSingleton <ProvisioningConfiguration>(configuration);
            frameworkBuilder.Services.AddSingleton <IAgent, TAgent>();
            frameworkBuilder.Services.AddSingleton <IHostedService>(s => new ProvisioningHostedService(
                                                                        configuration,
                                                                        s.GetRequiredService <IProvisioningService>(),
                                                                        s.GetRequiredService <IPoolService>(),
                                                                        s.GetRequiredService <IOptions <PoolOptions> >()));

            return(frameworkBuilder);
        }
Пример #2
0
        /// <summary>
        /// Registers and provisions an agent configured as Issuer.
        /// </summary>
        /// <param name="builder"></param>
        /// <param name="options"></param>
        /// <returns></returns>
        public static AgentFrameworkBuilder RegisterIssuerAgent <T>(
            this AgentFrameworkBuilder builder,
            Action <AgentOptions> options)
            where T : class, IAgent
        {
            builder.AddAgentProvider();
            builder.Services.AddDefaultMessageHandlers();
            builder.Services.AddSingleton <IAgent, T>();
            builder.Services.Configure(options);
            builder.Services.AddHostedService <IssuerProvisioningHostedService>();

            return(builder);
        }