Пример #1
0
 public OrleansHostedClientService(
     ILogger <OrleansHostedClientService> logger,
     OrleansHostedClientStore clientStore,
     OrleansHostedConection connection,
     NamedOrleansHostedClientBuilder namedClientBuilder)
 {
     this.connection         = connection;
     this.logger             = logger;
     this.clientStore        = clientStore;
     this.namedClientBuilder = namedClientBuilder;
 }
        public static IOrleansHostedClientBuilder AddOrleansClient(this IOrleansHostedClientBuilder builder,
                                                                   string name,
                                                                   Action <IClientBuilder> clientBuilder)
        {
            IClientBuilder clientBuilderObj = new ClientBuilder();

            clientBuilder(clientBuilderObj);

            builder.Services.AddSingleton <IHostedService, OrleansHostedClientService>((sp) =>
            {
                var namedClientBuilder = new NamedOrleansHostedClientBuilder()
                {
                    Name          = name,
                    ClientBuilder = clientBuilderObj
                };

                return(ActivatorUtilities.CreateInstance <OrleansHostedClientService>(sp, namedClientBuilder));
            });
            return(builder);
        }