Esempio n. 1
0
 public TEventBase GetEvent <TEventBase>() where  TEventBase : EventBase, new ()
 {
     if (eventDictionary.ContainsKey(typeof(TEventBase)))
     {
         return((TEventBase)eventDictionary[typeof(TEventBase)]);
     }
     else
     {
         eventDictionary[typeof(TEventBase)] = new TEventBase();
         return((TEventBase)eventDictionary[typeof(TEventBase)]);
     }
 }
Esempio n. 2
0
            public async ValueTask <TEntityBase> ReplayAsync(TEventBase evt, TEntityBase entity)
            {
                if (evt == null)
                {
                    throw new ArgumentNullException(nameof(evt));
                }

                if (!(evt is TEvent typedEvent))
                {
                    throw new ArgumentException("The specified event is not of the expected type.");
                }

                if (!(entity is TEntity typedEntity))
                {
                    if (entity != null)
                    {
                        throw new ArgumentException("The specified entity is not of the specified type.");
                    }

                    typedEntity = default;
                }

                return(await _eventReplayer.ReplayAsync(typedEvent, typedEntity));
            }