public DocumentDbEventStoreConfiguration(
            string entityName,
            IDocumentClientFactory clientFactory,
            string database,
            string collectionName,
            object partitionKey,
            IMessageTypeResolver messageTypeResolver,
            JsonSerializerSettings serializerSettings)
        {
            Arg.NotNullOrEmpty(entityName, nameof(entityName));
            Arg.NotNull(clientFactory, nameof(clientFactory));
            Arg.NotNullOrEmpty(database, nameof(database));
            Arg.NotNullOrEmpty(collectionName, nameof(collectionName));
            Arg.NotNull(messageTypeResolver, nameof(messageTypeResolver));
            Arg.NotNull(serializerSettings, nameof(serializerSettings));

            EntityName          = entityName;
            this.clientFactory  = clientFactory;
            Database            = database;
            CollectionName      = collectionName;
            CollectionLink      = CreateDocumentCollectionUri(database, collectionName);
            PartitionKey        = partitionKey;
            MessageTypeResolver = messageTypeResolver;
            JsonSerializer      = Create(serializerSettings);
        }
Exemplo n.º 2
0
 /// <summary>
 /// TODO: GenericCollectionProvider register in DI
 /// </summary>
 /// <param name="documentClientFactory"></param>
 /// <param name="databaseProvider"></param>
 public GenericRepository(IDocumentClientFactory documentClientFactory, IDatabaseProvider databaseProvider) : this(
         documentClientFactory.GetClient(),
         new GenericCollectionProvider <TDocument>(
             documentClientFactory,
             databaseProvider))
 {
 }
Exemplo n.º 3
0
 protected DocumentRepository(DocumentDbSettings settings,
                              IDocumentClientFactory clientFactory,
                              ILogger logger)
 {
     _settings   = settings;
     _clientTask = clientFactory.GetClientAsync();
     _logger     = logger;
 }
        public GenericCollectionProviderTestFixture(IDocumentClientFactory documentClientFactory)
        {
            _documentClient = documentClientFactory.GetClient();
            _databaseId     = documentClientFactory.GetDatabaseId();

            _collectionProvider = new GenericCollectionProvider <TestDocument>(
                documentClientFactory,
                new DatabaseProvider(documentClientFactory));
        }
Exemplo n.º 5
0
        public DatabaseProvider(IDocumentClientFactory documentClientFactory)
        {
            if (documentClientFactory == null)
            {
                throw new ArgumentNullException(nameof(documentClientFactory));
            }

            _documentClient = documentClientFactory.GetClient();
            _databaseId     = documentClientFactory.GetDatabaseId();
        }
Exemplo n.º 6
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="clientFactory">Document db client factory.</param>
        /// <param name="config">Document db settings config.</param>
        public DocumentDbAdapter(IDocumentClientFactory clientFactory, DocumentDbSettingsConfig config = null)
        {
            Code.ExpectsArgument(clientFactory, nameof(clientFactory), TaggingUtilities.ReserveTag(0x2381b1dc /* tag_961h2 */));

            DocumentClientFactory = clientFactory;

            m_DocumentClient = new Lazy <Task <IDocumentClient> >(
                () => DocumentClientFactory.GetDocumentClientAsync(config),
                LazyThreadSafetyMode.ExecutionAndPublication);
        }
 public GenericCollectionProvider(
     IDocumentClientFactory documentClientFactory,
     IDatabaseProvider databaseProvider)
 {
     if (documentClientFactory == null)
     {
         throw new ArgumentNullException(nameof(documentClientFactory));
     }
     _databaseProvider = databaseProvider ?? throw new ArgumentNullException(nameof(databaseProvider));
     _documentClient   = documentClientFactory.GetClient();
 }
Exemplo n.º 8
0
        public TestDocumentClient()
        {
            config          = ConfigurationHelper.GetIConfigurationRoot(AppDomain.CurrentDomain.BaseDirectory, Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT"));
            telemetryClient = new TelemetryClientWrap(config);
            var authKey = config.Get("TestDataSettings:AuthKey").MakeSecureString();

            databaseId = config.Get("TestDataSettings:DatabaseId");
            // need to get a few parameters for connectionpolicy
            documentClientFactory = new DocumentClientFactory(new Uri(config.Get("TestDataSettings:Endpoint")), authKey, authKey, new List <string>()
            {
                "East US"
            });
            var fakeDbManager = new FakeDbManager(documentClientFactory.ReadOnlyDocumentClient, databaseId);

            repositoryRead      = new TestRepository(documentClientFactory.ReadOnlyDocumentClient, fakeDbManager, telemetryClient, databaseId, collectionName, @"\id");
            repositoryReadWrite = new TestRepository(documentClientFactory.ReadWriteDocumentClient, fakeDbManager, telemetryClient, databaseId, collectionName, @"\id");
        }
        public TaskSubjectCommand(
            ILogger <TaskSubjectCommand> logger,
            IOptions <CosmosDbOptions> cosmosDb,
            IOptions <TaskSubjectCollectionOptions> taskSubjectCollectionOptions,
            IDocumentClientFactory clientFactory)
        {
            _logger = logger;
            var cosmosDbOptions = cosmosDb?.Value ?? new CosmosDbOptions();
            var taskSubjectCollectionOptionsLocal = taskSubjectCollectionOptions.Value;

            _logger.LogInformation(MyLogEvents.CreateDbClient, "Create document client. URL: {name}", cosmosDbOptions.AccountURL);
            _client = clientFactory.GetNewDocumentClient(new Uri(cosmosDbOptions.AccountURL), cosmosDbOptions.PrimaryKey);

            _logger.LogDebug(MyLogEvents.CreateDbClient, "Database id: {id} / Container id: {id}",
                             taskSubjectCollectionOptionsLocal.DatabaseId, taskSubjectCollectionOptionsLocal.ContainerId);
            _documentUri = UriFactory.CreateDocumentCollectionUri(taskSubjectCollectionOptionsLocal.DatabaseId,
                                                                  taskSubjectCollectionOptionsLocal.ContainerId);
        }
 public AccountProviderLegalEntitiesReadOnlyRepository(IDocumentClientFactory documentClientFactory)
     : base(documentClientFactory.CreateDocumentClient(), DocumentSettings.DatabaseName, DocumentSettings.AccountProviderLegalEntitiesCollectionName)
 {
 }
Exemplo n.º 11
0
 public GetPaymentQuery(IDocumentClientFactory documentClientFactory, IOptions <DocumentDbSettings> dbSettings)
 {
     this.dbSettings     = dbSettings.Value;
     this.documentClient = documentClientFactory.Create(this.dbSettings).Result;
 }
 public GenericRepositoryTestFixture(IDocumentClientFactory documentClientFactory)
 {
     this.repository = new GenericRepository <TestDocument>(documentClientFactory, new DatabaseProvider(documentClientFactory));
 }
 public PaymentsRepository(IDocumentClientFactory documentClientFactory, IOptions <DocumentDbSettings> settings)
 {
     this.settings = settings.Value;
     this.documentClientFactory = documentClientFactory.Create(this.settings).Result;
 }
Exemplo n.º 14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DatabaseAccess"/> class.
 /// </summary>
 /// <param name="documentClientFactory">The document client factory.</param>
 /// <param name="requestChargeService">Request charge service.</param>
 /// <param name="cosmosOptions">Cosmos options.</param>
 public DatabaseAccess(IDocumentClientFactory documentClientFactory, RequestChargeService requestChargeService, IOptions <CosmosDbSettings> cosmosOptions)
 {
     _documentClientFactory = documentClientFactory;
     _requestChargeService  = requestChargeService;
     _bypassSsl             = cosmosOptions.Value.BypassSsl;
 }
Exemplo n.º 15
0
 public PingQueryHandler(IDocumentClientFactory documentClientFactory)
 {
     _documentClient = documentClientFactory.CreateDocumentClient();
 }
Exemplo n.º 16
0
 public SavePaymentCommand(IDocumentClientFactory documentClientFactory, IOptions <DocumentDbSettings> dbSettings)
 {
     this.dbSettings     = dbSettings.Value;
     this.documentClient = documentClientFactory.Create(this.dbSettings).Result;
 }
Exemplo n.º 17
0
 /// <summary>
 /// Initialise a new instance of <see cref="TearDownDatabase"/>.
 /// </summary>
 /// <param name="logger">Logger to output to.</param>
 /// <param name="service">Service to import documents.</param>
 /// <param name="settings">Seed settings.</param>
 public TearDownDatabase(ILogger <TearDownDatabase> logger, IDocumentClientFactory service, IOptions <CosmosDbSettings> settings)
 {
     _logger   = logger;
     _service  = service;
     _settings = settings;
 }
Exemplo n.º 18
0
 public AccountUsersReadOnlyRepository(IDocumentClientFactory documentClientFactory)
     : base(documentClientFactory.CreateDocumentClient(), DocumentSettings.DatabaseName, DocumentSettings.AccountUsersCollectionName)
 {
 }
 public DatabaseProviderTestFixture(IDocumentClientFactory documentClientFactory)
 {
     _documentClient   = documentClientFactory.GetClient();
     _databaseId       = documentClientFactory.GetDatabaseId();
     _databaseProvider = new DatabaseProvider(null);
 }
Exemplo n.º 20
0
 public ItemRepository(DocumentDbSettings settings, IDocumentClientFactory clientFactory, ILogger <ItemRepository> logger) : base(settings, clientFactory, logger)
 {
 }