public CollectionManager (TComponent parent, Action <TEntityBaseEventClass> raiseEventThroughParent, IEventHandlerRegistrar <TEntityBaseEventInterface> appliersRegistrar) : base(parent, raiseEventThroughParent, appliersRegistrar) { }
/// <summary> /// Loads the module into the kernel. /// </summary> public override void Load() { Bind <IAkkaAggregateRepository <TAuthenticationToken> >().To <AkkaAggregateRepository <TAuthenticationToken> >().InSingletonScope(); Bind <IAkkaSagaRepository <TAuthenticationToken> >().To <AkkaSagaRepository <TAuthenticationToken> >().InSingletonScope(); Bind <IAkkaEventPublisher <TAuthenticationToken> >().To <AkkaEventBus <TAuthenticationToken> >().InSingletonScope(); Bind <IAkkaEventPublisherProxy <TAuthenticationToken> >().To <AkkaEventBusProxy <TAuthenticationToken> >().InSingletonScope(); Bind <IAkkaCommandPublisher <TAuthenticationToken> >().To <AkkaCommandBus <TAuthenticationToken> >().InSingletonScope(); Bind <IAkkaCommandPublisherProxy <TAuthenticationToken> >().To <AkkaCommandBusProxy <TAuthenticationToken> >().InSingletonScope(); BusRegistrar.GetEventHandlerRegistrar = (messageType, handlerDelegateTargetedType) => { bool isAnActor = messageType != null && messageType.GetNestedTypes().Any(type => type.Name == "Actor"); IEventHandlerRegistrar eventHandlerRegistrar = null; if (isAnActor) { eventHandlerRegistrar = Resolve <IAkkaEventPublisher <TAuthenticationToken> >() as IEventHandlerRegistrar; } return(eventHandlerRegistrar ?? Resolve <IEventHandlerRegistrar>()); }; BusRegistrar.GetCommandHandlerRegistrar = (messageType, handlerDelegateTargetedType) => { bool isAnActor = handlerDelegateTargetedType != null && handlerDelegateTargetedType.GetProperty("AggregateResolver", BindingFlags.Instance | BindingFlags.GetProperty | BindingFlags.NonPublic | BindingFlags.Public) != null; ICommandHandlerRegistrar commandHandlerRegistrar = null; if (isAnActor) { commandHandlerRegistrar = Resolve <IAkkaCommandPublisher <TAuthenticationToken> >() as ICommandHandlerRegistrar; } return(commandHandlerRegistrar ?? Resolve <ICommandHandlerRegistrar>()); }; }
protected NestedComponent (IUtcTimeTimeSource timeSource, Action <TNestedComponentBaseEventClass> raiseEventThroughParent, IEventHandlerRegistrar <TNestedComponentBaseEventInterface> appliersRegistrar, bool registerEventAppliers) : base(timeSource, raiseEventThroughParent, appliersRegistrar, registerEventAppliers) { }
protected EntityCollectionManagerBase (TParent parent, IEventHandlerRegistrar <TEntityBaseEventInterface> appliersRegistrar) { ManagedEntities = new EntityCollection <TEntity, TEntityId>(); _parent = parent; appliersRegistrar .For <TEntityBaseEventInterface>(e => ManagedEntities[IdGetter.GetId(e)].ApplyEvent(e)); }
protected NestedEntity (IUtcTimeTimeSource timeSource, Action <TEntityBaseEventClass> raiseEventThroughParent, IEventHandlerRegistrar <TEntityBaseEventInterface> appliersRegistrar) : base(timeSource, raiseEventThroughParent, appliersRegistrar, registerEventAppliers: false) { RegisterEventAppliers() .For <TEntityCreatedEventInterface>(e => Id = IdGetterSetter.GetId(e)); }
protected SlavedNestedEntity (IUtcTimeTimeSource timeSource, Action <TEntityBaseEventClass> raiseEventThroughParent, IEventHandlerRegistrar <TEntityBaseEventInterface> appliersRegistrar) : base(timeSource, raiseEventThroughParent, appliersRegistrar, registerEventAppliers: false) { RegisterEventAppliers() .IgnoreUnhandled <TEntityBaseEventInterface>(); }
protected EntityCollectionManager (TParent parent, Action <TEntityBaseEventClass> raiseEventThroughParent, IEventHandlerRegistrar <TEntityBaseEventInterface> appliersRegistrar) : base(parent, raiseEventThroughParent, appliersRegistrar) { appliersRegistrar.For <TEntityRemovedEventInterface>( e => { var id = IdGetter.GetId(e); ManagedEntities.Remove(id); }); }
protected EntityCollectionManager (TParent parent, Action <TEntityBaseEventClass> raiseEventThroughParent, IEventHandlerRegistrar <TEntityBaseEventInterface> appliersRegistrar) { ManagedEntities = new EntityCollection <TEntity, TEntityId>(); _raiseEventThroughParent = raiseEventThroughParent; _parent = parent; appliersRegistrar .For <TEntityCreatedEventInterface>( e => { var entity = ObjectFactory <TEntity> .CreateInstance(_parent); ManagedEntities.Add(entity, IdGetter.GetId(e)); }) .For <TEntityBaseEventInterface>(e => ManagedEntities[IdGetter.GetId(e)].ApplyEvent(e)); }
public static IUpCastEventHandlerRegistrar <TNewBaseEvent> UpCast <TBaseEvent, TNewBaseEvent>(this IEventHandlerRegistrar <TBaseEvent> @this) where TBaseEvent : class where TNewBaseEvent : class, TBaseEvent { return(new UpCastEventHandlerRegistrar <TBaseEvent, TNewBaseEvent>(@this)); }
public GenericEventHandlerRegistrar(IEventHandlerRegistrar <TBaseEventInterface> innerRegistrar) { _innerRegistrar = innerRegistrar; }
public static IGenericEventHandlerRegistrar MakeGeneric <TBaseEvent>(this IEventHandlerRegistrar <TBaseEvent> @this) where TBaseEvent : class { return(new GenericEventHandlerRegistrar <TBaseEvent>(@this)); }
public static IEventHandlerRegistrar <TNewBaseEvent> DownCast <TBaseEvent, TNewBaseEvent>(this IEventHandlerRegistrar <TBaseEvent> @this) where TBaseEvent : class where TNewBaseEvent : class, TBaseEvent { return(@this); }
public static IEventHandlerRegistrar <TBaseEvent> AfterHandlers <TBaseEvent> (this IEventHandlerRegistrar <TBaseEvent> @this, Action <TBaseEvent> handler) where TBaseEvent : class { return(@this.AfterHandlers <TBaseEvent>(handler)); }
public UpCastEventHandlerRegistrar(IEventHandlerRegistrar <TBaseEvent> innerRegistrar) { _innerRegistrar = innerRegistrar; }
internal Component(IUtcTimeTimeSource timeSource, Action <TComponentBaseEventClass> raiseEventThroughParent, IEventHandlerRegistrar <TComponentBaseEventInterface> appliersRegistrar, bool registerEventAppliers) { TimeSource = timeSource; _raiseEventThroughParent = raiseEventThroughParent; _eventHandlersEventDispatcher.Register() .IgnoreUnhandled <TComponentBaseEventInterface>(); if (registerEventAppliers) { appliersRegistrar .For <TComponentBaseEventInterface>(ApplyEvent); } }