Exemple #1
0
 public Task SubscribeToEvents(long?initialPosition, IEnumerable <Type> eventTypes, DomainEventReceived domainEventReceived, LiveProcessingStarted liveProcessingStarted)
 {
     _domainEventReceived   = domainEventReceived;
     _liveProcessingStarted = liveProcessingStarted;
     LastStreamPosition     = initialPosition;
     IsListening            = true;
     return(Task.CompletedTask);
 }
        public EventsSubscription(long?initialPosition, IEnumerable <Type> eventTypes, DomainEventReceived domainEventReceived, LiveProcessingStarted liveProcessingStarted, ILogger logger)
        {
            _lastPosition          = initialPosition.HasValue ? new Position(initialPosition.Value, initialPosition.Value) : (Position?)null;
            _domainEventReceived   = domainEventReceived;
            _liveProcessingStarted = liveProcessingStarted;
            _logger          = logger;
            _nameToEventType = eventTypes.ToDictionary(x => x.Name);

            var jsonResolver = new PropertyCleanerSerializerContractResolver();

            jsonResolver.IgnoreProperty(typeof(IEvent), "Version");
            jsonResolver.RenameProperty(typeof(IEvent), "Id", "AggregateId");

            _serializerSettings = new JsonSerializerSettings {
                ContractResolver = jsonResolver,
                Formatting       = Formatting.Indented
            };
        }
        public async Task SubscribeToEvents(long?initialPosition, IEnumerable <Type> eventTypes, DomainEventReceived domainEventReceived, LiveProcessingStarted liveProcessingStarted = null)
        {
            var subscription = new EventsSubscription(
                initialPosition,
                eventTypes,
                domainEventReceived,
                liveProcessingStarted,
                _logger
                );

            _subscriptions.Add(subscription);

            subscription.DefineConnection(await GetOrCreateNewConnection());
        }