internal void Init(
            CosmosClientOptions clientOptions,
            DocumentClient documentClient)
        {
            this.ClientOptions  = clientOptions;
            this.DocumentClient = documentClient;

            //Request pipeline
            ClientPipelineBuilder clientPipelineBuilder = new ClientPipelineBuilder(
                this,
                this.DocumentClient.ResetSessionTokenRetryPolicy,
                this.ClientOptions.CustomHandlers);

            // DocumentClient is not initialized with any consistency overrides so default is backend consistency
            this.AccountConsistencyLevel = (ConsistencyLevel)this.DocumentClient.ConsistencyLevel;

            this.RequestHandler = clientPipelineBuilder.Build();

            this.ResponseFactory = new CosmosResponseFactory(
                defaultJsonSerializer: this.ClientOptions.SettingsSerializer,
                userJsonSerializer: this.ClientOptions.CosmosSerializerWithWrapperOrDefault);

            this.ClientContext = new CosmosClientContextCore(
                client: this,
                clientOptions: this.ClientOptions,
                userJsonSerializer: this.ClientOptions.CosmosSerializerWithWrapperOrDefault,
                defaultJsonSerializer: this.ClientOptions.SettingsSerializer,
                cosmosResponseFactory: this.ResponseFactory,
                requestHandler: this.RequestHandler,
                documentClient: this.DocumentClient,
                documentQueryClient: new DocumentQueryClient(this.DocumentClient));

            this.offerSet = new Lazy <CosmosOffers>(() => new CosmosOffers(this.DocumentClient), LazyThreadSafetyMode.PublicationOnly);
        }
예제 #2
0
 internal ClientContextCore(
     CosmosClient client,
     CosmosClientOptions clientOptions,
     CosmosSerializerCore serializerCore,
     CosmosResponseFactory cosmosResponseFactory,
     RequestInvokerHandler requestHandler,
     DocumentClient documentClient)
 {
     this.Client          = client;
     this.ClientOptions   = clientOptions;
     this.SerializerCore  = serializerCore;
     this.ResponseFactory = cosmosResponseFactory;
     this.RequestHandler  = requestHandler;
     this.DocumentClient  = documentClient;
 }
예제 #3
0
        internal static CosmosClientContext Create(
            CosmosClient cosmosClient,
            DocumentClient documentClient,
            CosmosClientOptions clientOptions,
            RequestInvokerHandler requestInvokerHandler = null)
        {
            if (cosmosClient == null)
            {
                throw new ArgumentNullException(nameof(cosmosClient));
            }

            if (documentClient == null)
            {
                throw new ArgumentNullException(nameof(documentClient));
            }

            clientOptions = ClientContextCore.CreateOrCloneClientOptions(clientOptions);

            if (requestInvokerHandler == null)
            {
                //Request pipeline
                ClientPipelineBuilder clientPipelineBuilder = new ClientPipelineBuilder(
                    cosmosClient,
                    clientOptions.ConsistencyLevel,
                    clientOptions.CustomHandlers);

                requestInvokerHandler = clientPipelineBuilder.Build();
            }

            CosmosSerializerCore serializerCore = CosmosSerializerCore.Create(
                clientOptions.Serializer,
                clientOptions.SerializerOptions);

            CosmosResponseFactory responseFactory = new CosmosResponseFactory(serializerCore);

            return(new ClientContextCore(
                       client: cosmosClient,
                       clientOptions: clientOptions,
                       serializerCore: serializerCore,
                       cosmosResponseFactory: responseFactory,
                       requestHandler: requestInvokerHandler,
                       documentClient: documentClient,
                       userAgent: documentClient.ConnectionPolicy.UserAgentContainer.UserAgent,
                       encryptionProcessor: new EncryptionProcessor(),
                       dekCache: new DekCache(),
                       batchExecutorCache: new BatchAsyncContainerExecutorCache()));
        }
 internal CosmosClientContextCore(
     CosmosClient client,
     CosmosClientConfiguration clientConfiguration,
     CosmosJsonSerializer cosmosJsonSerializer,
     CosmosResponseFactory cosmosResponseFactory,
     CosmosRequestHandler requestHandler,
     DocumentClient documentClient,
     IDocumentQueryClient documentQueryClient)
 {
     this.Client = client;
     this.ClientConfiguration = clientConfiguration;
     this.JsonSerializer      = cosmosJsonSerializer;
     this.ResponseFactory     = cosmosResponseFactory;
     this.RequestHandler      = requestHandler;
     this.DocumentClient      = documentClient;
     this.DocumentQueryClient = documentQueryClient;
 }
예제 #5
0
 internal ClientContextCore(
     CosmosClient client,
     CosmosClientOptions clientOptions,
     CosmosSerializer userJsonSerializer,
     CosmosSerializer defaultJsonSerializer,
     CosmosResponseFactory cosmosResponseFactory,
     RequestInvokerHandler requestHandler,
     DocumentClient documentClient,
     IDocumentQueryClient documentQueryClient)
 {
     this.Client               = client;
     this.ClientOptions        = clientOptions;
     this.CosmosSerializer     = userJsonSerializer;
     this.PropertiesSerializer = defaultJsonSerializer;
     this.ResponseFactory      = cosmosResponseFactory;
     this.RequestHandler       = requestHandler;
     this.DocumentClient       = documentClient;
     this.DocumentQueryClient  = documentQueryClient;
 }
예제 #6
0
 private ClientContextCore(
     CosmosClient client,
     CosmosClientOptions clientOptions,
     CosmosSerializerCore serializerCore,
     CosmosResponseFactory cosmosResponseFactory,
     RequestInvokerHandler requestHandler,
     DocumentClient documentClient,
     string userAgent,
     EncryptionProcessor encryptionProcessor,
     BatchAsyncContainerExecutorCache batchExecutorCache)
 {
     this.client              = client;
     this.clientOptions       = clientOptions;
     this.serializerCore      = serializerCore;
     this.responseFactory     = cosmosResponseFactory;
     this.requestHandler      = requestHandler;
     this.documentClient      = documentClient;
     this.userAgent           = userAgent;
     this.encryptionProcessor = encryptionProcessor;
     this.batchExecutorCache  = batchExecutorCache;
 }
 internal ClientContextCore(
     CosmosClient client,
     CosmosClientOptions clientOptions,
     CosmosSerializerCore serializerCore,
     CosmosResponseFactory cosmosResponseFactory,
     RequestInvokerHandler requestHandler,
     DocumentClient documentClient,
     string userAgent,
     EncryptionProcessor encryptionProcessor = null,
     DekCache dekCache = null)
 {
     this.Client              = client;
     this.ClientOptions       = clientOptions;
     this.SerializerCore      = serializerCore;
     this.ResponseFactory     = cosmosResponseFactory;
     this.RequestHandler      = requestHandler;
     this.DocumentClient      = documentClient;
     this.UserAgent           = userAgent;
     this.EncryptionProcessor = encryptionProcessor;
     this.DekCache            = dekCache;
 }