示例#1
0
        public void Populate(IServiceCollection serviceCollection)
        {
            if (serviceCollection == null)
            {
                throw new ArgumentNullException(nameof(serviceCollection));
            }

            foreach (KeyValuePair <NameString, ExecutorFactory> factory in
                     _execFacs)
            {
                serviceCollection.AddSingleton <IRemoteExecutorAccessor>(
                    services => new RemoteExecutorAccessor(
                        factory.Key,
                        factory.Value.Invoke(services)));
            }

            serviceCollection.TryAddSingleton(services =>
                                              StitchingFactory.Create(this, services));

            serviceCollection.TryAddScoped(services =>
                                           services.GetRequiredService <StitchingFactory>()
                                           .CreateStitchingContext(services));

            if (!serviceCollection.Any(d =>
                                       d.ImplementationType == typeof(RemoteQueryBatchOperation)))
            {
                serviceCollection.AddScoped <
                    IBatchOperation,
                    RemoteQueryBatchOperation>();
            }

            serviceCollection.TryAddSingleton <ISchema>(sp =>
                                                        sp.GetRequiredService <StitchingFactory>()
                                                        .CreateStitchedSchema(sp));

            serviceCollection.AddQueryExecutor(
                builder =>
            {
                foreach (Action <IQueryExecutionBuilder> configure in
                         _execConfigs)
                {
                    configure(builder);
                }
                builder.UseStitchingPipeline(_options);
            },
                _buildOnFirstRequest);
            serviceCollection.AddBatchQueryExecutor();
            serviceCollection.AddJsonQueryResultSerializer();
            serviceCollection.AddJsonArrayResponseStreamSerializer();


            serviceCollection.TryAddSingleton(services =>
                                              services.GetRequiredService <IQueryExecutor>()
                                              .Schema);
        }
示例#2
0
        public void Populate(IServiceCollection serviceCollection)
        {
            if (serviceCollection == null)
            {
                throw new ArgumentNullException(nameof(serviceCollection));
            }

            serviceCollection.TryAddSingleton <
                IQueryResultSerializer,
                JsonQueryResultSerializer>();

            foreach (KeyValuePair <NameString, ExecutorFactory> factory in
                     _execFacs)
            {
                serviceCollection.AddSingleton <IRemoteExecutorAccessor>(
                    services => new RemoteExecutorAccessor(
                        factory.Key,
                        factory.Value.Invoke(services)));
            }

            serviceCollection.TryAddSingleton(services =>
                                              StitchingFactory.Create(this, services));

            serviceCollection.TryAddScoped(services =>
                                           services.GetRequiredService <StitchingFactory>()
                                           .CreateStitchingContext(services));

            if (!serviceCollection.Any(d =>
                                       d.ImplementationType == typeof(RemoteQueryBatchOperation)))
            {
                serviceCollection.AddScoped <
                    IBatchOperation,
                    RemoteQueryBatchOperation>();
            }

            serviceCollection.TryAddSingleton <IQueryExecutor>(
                services => new LazyQueryExecutor(() =>

                                                  services.GetRequiredService <StitchingFactory>()
                                                  .CreateStitchedQueryExecuter()));

            serviceCollection.TryAddSingleton(services =>
                                              services.GetRequiredService <IQueryExecutor>()
                                              .Schema);
        }