示例#1
0
 public void SaveEvents(EventSource eventSource, IEnumerable<Event> es)
 {
     const int lastVersion = 1; // TODO : should find from some event source
     int version = lastVersion;
     foreach (var e in es)
     {
         version++;
         e.Version = version;
         _Persistente.Add(eventSource.GetType(), eventSource.Id, new EventDescription(eventSource.Id, eventSource.GetType().FullName, e.GetType().FullName, version));
         _Publisher.Publish(e);
     }
 }
示例#2
0
        public IEnumerable<Event> ListEvents(EventSource eventSource)
        {
            IEnumerable<EventDescription> descriptions = _Persistente.Load(eventSource.GetType(), eventSource.Id);

            foreach (var desc in descriptions)
            {
                Type eventType = Type.GetType(desc.EventTypeName);
                if (eventType == null) throw new ArgumentException(desc.EventTypeName + " not found in loaded assembly.");

                Event e = (Event) Activator.CreateInstance(eventType);
                e.Version = desc.Version;
                yield return e;
            }
        }