Пример #1
0
        private ApplierRetriever GetApplierFromUnindexed(EventAndStateTypes index)
        {
            var applier = unindexedAppliers
                          .FirstOrDefault(x => x.GetApplier(index)?.CanApplyEvent(index.stateType, index.eventType) == true);

            if (applier.IsDefault)
            {
                throw new ApplierNotFoundException(index.stateType, index.eventType);
            }

            return(applier);
        }
Пример #2
0
        public IApplyEventsInternal GetApplier(EventAndStateTypes types, bool withCheck = false)
        {
            var applier = GetApplier();

            if (withCheck && !applier.CanApplyEvent(types.stateType, types.eventType))
            {
                throw new ArgumentException(
                          $"Type of event {types.eventType} is not supported. Applier type: {applier.GetType().Name}");
            }

            return(applier);
        }
Пример #3
0
        private object ApplyAssumeWritable(Type stateType, object state, Type eventType, object @event)
        {
            var key = new EventAndStateTypes(stateType, eventType);

            if (!indexedStateAppliers.TryGetValue(key, out var indexedApplier))
            {
                indexedApplier = GetApplierFromUnindexed(key);

                indexedStateAppliers.Add(key, indexedApplier);
            }

            return(indexedApplier.GetApplier()
                   .Apply(state, @event));
        }