Esempio n. 1
0
		public void Apply(object instance, string eventHandlingMethodName)
		{
			Guard.AgainstNull(instance, "instance");

            _canSnapshot = instance as ICanSnapshot;
            
			var events = new List<Event>(PastEvents());

			if (HasSnapshot)
			{
				events.Insert(0, Snapshot);
			}

            var instanceType = instance.GetType();
            
            foreach (var @event in events)
			{
			    var method = instanceType.GetMethod(eventHandlingMethodName, new[] {@event.Data.GetType()});

				if (method == null)
				{
					throw new UnhandledEventException(string.Format(RecallResources.UnhandledEventException,
						instanceType.AssemblyQualifiedName, eventHandlingMethodName, @event.Data.GetType().AssemblyQualifiedName));
				}

				method.Invoke(instance, new[] {@event.Data});
			}
		}
Esempio n. 2
0
 private static void TakeSnapshot(ICanSnapshot snap)
 {
     var shot = snap.TakeSnapshot();
     EventStore.TakeSnapshot(_snapshotCollection, shot);
 }