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);
        }
        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);
        }
        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));
        }