Esempio n. 1
0
        /// <summary>
        /// Calls the generic GetSnapshot method of the snapshot store object.
        /// </summary>
        /// <param name="root">Snapshot-capable aggregate Root to load</param>
        /// <param name="aggregateRoodId">ID of the persisted aggregate root instance</param>
        /// <returns>Snapshot of Type T casted as an object</returns>
        private object GetSnapshot(AggregateRoot root, Guid aggregateRoodId)
        {
            if (!(root is IAggregateRootWithSnapshot))
            {
                return(null);
            }

            var casted = (IAggregateRootWithSnapshot)root;

            var snapshotType = casted.GetGenericType();
            var method       = _snapshotStore.GetType().GetMethod("GetSnapshot").MakeGenericMethod(snapshotType);

            return(method.Invoke(_snapshotStore, new object[] { aggregateRoodId }));
        }