Exemple #1
0
        public MongoEventStore(String connectionString, LogicSchema logicSchema, ILogger <MongoEventStore> logger)
        {
            if (String.IsNullOrWhiteSpace(connectionString))
            {
                throw new ArgumentNullException(nameof(connectionString));
            }
            var conventions = new ConventionPack
            {
                new IgnoreExtraElementsConvention(true)
            };

            ConventionRegistry.Register("Cleanic Conventions", conventions, t => true);
            _mongo = new MongoClient(connectionString);

            _logger      = logger ?? throw new ArgumentNullException(nameof(logger));
            _logicSchema = logicSchema ?? throw new ArgumentNullException(nameof(logicSchema));
            _bus         = new InMemoryEventBus(_logger);
            Db           = _mongo.GetDatabase("events");

            _serializationOptions = new JsonSerializerOptions
            {
                Encoder = JavaScriptEncoder.Create(UnicodeRanges.All)
            };
        }