Пример #1
0
        public IAggregateRoot Get(Type aggregateRootType, string aggregateRootId)
        {
            if (aggregateRootId == null)
            {
                throw new ArgumentNullException("aggregateRootId");
            }

            var aggregateRoot = default(IAggregateRoot);

            CompatibleStyle compatibleStyle = CompatibleStyle.EventSourcingOnly;

            ICompatibleStoreHandler aggregateInitEventHandler = _compatibleStoreHandlerProvider.GetHandler(aggregateRootType);

            if (aggregateInitEventHandler != null)
            {
                compatibleStyle = aggregateInitEventHandler.GetCompatibleStyle();
            }

            if (compatibleStyle == CompatibleStyle.EventSourcingOnly)
            {
                if (TryGetFromSnapshot(aggregateRootId, aggregateRootType, out aggregateRoot))
                {
                    return(aggregateRoot);
                }
            }

            if (TryGetFromCompatibleAggregateStore(aggregateRootId, aggregateRootType, aggregateInitEventHandler, compatibleStyle, out aggregateRoot))
            {
                return(aggregateRoot);
            }

            return(null);
        }
Пример #2
0
 public CompatibleStyle GetCompatibleStyle()
 {
     return(_aggregateInitEvent.GetCompatibleStyle(null));
 }