Ejemplo n.º 1
0
        public T Get <T, TId>(string bucketId, string id, int version)
            where T : class, IEventSource <TId>
        {
            Logger.Debug("Get event source Id '{0}', Type '{1}'", id, typeof(T).Name);

            if (string.IsNullOrEmpty(id) || string.IsNullOrWhiteSpace(id))
            {
                Logger.Warn("Try to read event store with Guid.Empty");
                return(null);
            }

            var eventSource = _eventSourceFactory.Create <T>();

            bool hasSnaphot = this.RestoreSnapshot <T, TId>(bucketId, id, eventSource, version);
            bool hasEvents  = this.Hydrate(bucketId, id, eventSource, version);

            if (!(hasSnaphot || hasEvents))
            {
                Logger.Debug("No event source found using the id {0}", id);
                return(null);
            }

            if (string.IsNullOrEmpty(eventSource.StringId))
            {
                Logger.Warn(string.Format("Source with id {0} found in eventstore, but after hydration the id was not set properly {1}", id, eventSource.StringId));
                return(null);
            }

            return(eventSource);
        }
Ejemplo n.º 2
0
        public T Get <T>(Guid id) where T : class, IEventSource
        {
            var eventSource = _eventSourceFactory.Create <T>();

            RestoreSnapshot(id, eventSource);
            Hydrate(id, eventSource);

            return(eventSource.Id != Guid.Empty ? eventSource : null);
        }
Ejemplo n.º 3
0
        public T Build()
        {
            _source = _aggregate = _eventSourceFactory.Create <T>();

            _source.Hydrate(_events);
            _source.Flush();

            return(_aggregate);
        }
Ejemplo n.º 4
0
        public T Get <T>(Guid id) where T : class, IEventSource
        {
            Logger.Debug("Get event source Id '{0}', Type '{1}'", id, typeof(T).Name);

            var eventSource = _eventSourceFactory.Create <T>();

            RestoreSnapshot(id, eventSource);
            Hydrate(id, eventSource);

            return(eventSource.Id != Guid.Empty ? eventSource : null);
        }