public TickerController(
     IQueryRepositoryFactory repositoryFactory,
     IUnitOfWorkAsync uow,
     MyExchangeService.ExchangeServiceClient exchangeServiceClient)
 {
     _repositoryFactory = repositoryFactory;
     _uow = uow;
     _exchangeServiceClient = exchangeServiceClient;
 }
示例#2
0
 public void ConfigureServices(IServiceCollection services)
 {
     services.AddMongoDbTemplate(null, (svc, resolver) =>
     {
         var config  = resolver.GetService <IConfiguration>();
         var channel = new Channel(config["RpcClients:ExchangeService"], ChannelCredentials.Insecure);
         var client  = new MyExchangeService.ExchangeServiceClient(channel);
         services.AddSingleton(typeof(MyExchangeService.ExchangeServiceClient), client);
     });
 }
示例#3
0
 public PingController(MyExchangeService.ExchangeServiceClient exchangeServiceClient)
 {
     _exchangeServiceClient = exchangeServiceClient;
 }
示例#4
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddFeatureToggle();

            using (var scope = services.BuildServiceProvider().GetService <IServiceScopeFactory>().CreateScope())
            {
                var svcProvider = scope.ServiceProvider;
                var config      = svcProvider.GetRequiredService <IConfiguration>();
                var env         = svcProvider.GetRequiredService <IHostingEnvironment>();
                var feature     = svcProvider.GetRequiredService <IFeature>();

                // preDbWorkHook?.Invoke(services);

                if (feature.IsEnabled("Mongo"))
                {
                    if (feature.IsEnabled("EfCore"))
                    {
                        throw new Exception("Should turn EfCore feature off.");
                    }
                    services.AddMongoDb();
                }

                // postDbWorkHook?.Invoke(services, svcProvider);

                services.AddRestClientCore();

                services.AddSingleton <IDomainEventDispatcher, MemoryDomainEventDispatcher>();

                services.AddAutoMapperCore(config.LoadFullAssemblies());
                services.AddMediatRCore(config.LoadFullAssemblies());

                if (feature.IsEnabled("CleanArch"))
                {
                    services.AddCleanArch();
                }

                services.AddCacheCore();

                if (feature.IsEnabled("ApiVersion"))
                {
                    services.AddApiVersionCore(config);
                }

                var mvcBuilder = services.AddMvcCore(config);

                if (feature.IsEnabled("MessagePack"))
                {
                    mvcBuilder.AddMvcOptions(option =>
                    {
                        option.OutputFormatters.Clear();
                        option.OutputFormatters.Add(
                            new MessagePackOutputFormatter(ContractlessStandardResolver.Instance));
                        option.InputFormatters.Clear();
                        option.InputFormatters.Add(
                            new MessagePackInputFormatter(ContractlessStandardResolver.Instance));
                    });
                }

                services.AddDetailExceptionCore();

                if (feature.IsEnabled("AuthN"))
                {
                    services.AddAuthNCore(config, env);
                }

                if (feature.IsEnabled("OpenApi"))
                {
                    services.AddOpenApiCore(config, feature);
                }

                services.AddCorsCore();

                services.AddHeaderForwardCore(env);

                if (feature.IsEnabled("OpenApi:Profiler"))
                {
                    services.AddApiProfilerCore();
                }

                services.AddBeatPulse();

                if (feature.IsEnabled("ResponseCompression"))
                {
                    services.AddResponseCompression();
                }

                var channel = new Channel(config["RpcClients:ExchangeService"], ChannelCredentials.Insecure);
                var client  = new MyExchangeService.ExchangeServiceClient(channel);
                services.AddSingleton(typeof(MyExchangeService.ExchangeServiceClient), client);
            }
        }