Exemplo n.º 1
0
        public void Persist(DomainObject <Guid, DomainEvent> entity)
        {
            foreach (var @event in entity.GetEvents())
            {
                Save(entity, @event);
            }

            entity.AcceptEvents();
        }
Exemplo n.º 2
0
    /// <summary>
    /// Persists the pending events raised by the given domain object.
    /// </summary>
    /// <param name="domainObject">The domain object raising the events.</param>
    public void Persist(DomainObject <Guid, TBaseEvent> domainObject)
    {
        foreach (var @event in domainObject.GetEvents().ToList())
        {
            SaveEvent(domainObject, @event);
        }

        domainObject.AcceptEvents();
    }
Exemplo n.º 3
0
			public void Persist(DomainObject<Guid, DomainEvent> entity)
			{
				foreach (var @event in entity.GetEvents())
				{
					this.events.Add(@event);
					Console.WriteLine("Saved event {0} to the store.", @event);
				}

				entity.AcceptEvents();
			}
Exemplo n.º 4
0
            public void Persist(DomainObject <Guid, DomainEvent> entity)
            {
                foreach (var @event in entity.GetEvents())
                {
                    this.events.Add(@event);
                    Console.WriteLine("Saved event {0} to the store.", @event);
                }

                entity.AcceptEvents();
            }
Exemplo n.º 5
0
    public void Persist(DomainObject <TObjectId, TBaseEvent> entity)
    {
        foreach (var change in entity.GetEvents())
        {
            this.pendingEvents.Add(new StoredEvent(entity, change)
            {
                Timestamp = change.Timestamp
            });
        }

        entity.AcceptEvents();
    }
Exemplo n.º 6
0
    public void Persist(DomainObject <TObjectId, TBaseEvent> entity)
    {
        var commitId = DateTimeOffset.Now.Ticks;
        var events   = entity.GetEvents().ToList();

        for (var eventId = 0; eventId < events.Count; eventId++)
        {
            var @event = events[eventId];

            // Ticks used as a timestamp for ordering
            var fileName = string.Format("{0}-{1}-{2:00}.json", entity.Id, commitId, eventId);
            var filePath = Path.Combine(this.directory, fileName);

            File.WriteAllBytes(filePath, this.serializer.Serialize(new FileStoredEvent <TObjectId, TBaseEvent>(entity, @event)));
        }

        entity.AcceptEvents();
    }