Exemple #1
0
        public EventStore(IDocumentClient client, string database, string collection, string partition = null)
        {
            this.Client       = client ?? throw new ArgumentNullException(nameof(client));
            this.Database     = database ?? throw new ArgumentNullException(nameof(database));
            this.Collection   = collection ?? throw new ArgumentNullException(nameof(collection));
            this.Partition    = string.IsNullOrEmpty(partition) ? null : partition;
            this.PartitionKey = string.IsNullOrEmpty(this.Partition) ? null : new PartitionKey(this.Partition);

            this.DocumentCollectionUri = UriFactory.CreateDocumentCollectionUri(this.Database, this.Collection);

            this.JsonSerializerSettings =
                (JsonSerializerSettings)client.GetType().GetField("serializerSettings", BindingFlags.GetField | BindingFlags.Instance | BindingFlags.NonPublic).GetValue(this.Client)
                ?? JsonConvert.DefaultSettings?.Invoke()
                ?? new JsonSerializerSettings();

            this.JsonSerializer = JsonSerializer.Create(this.JsonSerializerSettings);
        }