Esempio n. 1
0
        public static GrpcCqrsAspNetCoreConfiguration ToConfiguration(this GrpcCqrsAspNetCoreRawConfiguration raw)
        {
            var cfg = new GrpcCqrsAspNetCoreConfiguration
            {
                ContractsAssemblies = raw.ContractsAssemblies.ToAssemblies(),
                ServiceNamePrefix   = raw.ServiceNamePrefix,
                TimeoutMs           = raw.TimeoutMs
            };

            return(cfg);
        }
        public static IServiceCollection AddCqrsGrpc(this IServiceCollection services,
                                                     GrpcCqrsAspNetCoreConfiguration configuration)
        {
            // resolve cqrs
            IEnumerable <CqrsInfo> cqrs = configuration.ContractsAssemblies.SelectMany(CqrsInfoResolverUtil.GetCqrsDefinitions).ToList();
            var cqrsAdapter             = new CqrsContractsAdapter(cqrs, configuration.ServiceNamePrefix);

            // register data to container
            var container = services.GetContainer();

            container.RegisterInstance(cqrsAdapter);
            container.RegisterInstance(configuration);
            container.Register <IGrpcCqrsServerProcessor, GrpcCqrsServerProcessor>();
            container.Register <IServiceMethodProvider <GrpcService>, ServiceMethodProvider>(Lifestyle.Singleton);

            // register grpc
            services.AddGrpc();
            services.AddSingleton(svc => container.GetInstance <IServiceMethodProvider <GrpcService> >());

            // return
            return(services);
        }
Esempio n. 3
0
 public ServiceMethodProvider(CqrsContractsAdapter cqrs, GrpcCqrsAspNetCoreConfiguration cfg, Container container)
 {
     _cfg       = cfg;
     _cqrs      = cqrs;
     _container = container;
 }